Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#1369 closed Bug (fixed)

Visitor Generator generates Future Visits

Reported by: vipsoft Owned by:
Priority: low Milestone: Piwik 0.6.2
Component: Core Keywords:
Cc: Sensitive: no

Description

At 23:55 PM EDT on May 20th, I ran misc/generateVisits.php. Looking in piwik_log_visit, the visits were generated for May 21st and May 22nd.

(daysToCompute is 1)

Attachments (1)

piwik.patch (1.1 KB) - added by JulienM 4 years ago.

Download all attachments as: .zip

Change History (5)

Changed 4 years ago by JulienM (JulienMoumne)

comment:1 Changed 4 years ago by JulienM (JulienMoumne)

To override default behaviors of a visit a subclass of /core/Tracker/Visit.php has been created : /core/Tracker/Generator/Visit.php.

This extension allows a fake generated timestamp to be assigned to a visit. In order to do so, an overridden method has been created in /core/Tracker/Generator/Visit.php : 33

	protected function getCurrentTimestamp()
	{
		self::$timestampToUse = max(@$this->visitorInfo['visit_last_action_time'],self::$timestampToUse);
		self::$timestampToUse += mt_rand(4,1840);
		return self::$timestampToUse;
	}

In /core/Tracker/Visit.php : 226, 254, 290, 356, 427, 572, 773 and 804, the method getCurrentTimestamp() is called.

The method getCurrentTimestamp() of class /core/Tracker/Visit.php is supposed to be an accessor method and not a computational one. Each call of the overridden method getCurrentTimestamp() of class /core/Tracker/Generator/Visit.php computes a new timestamp instead of reusing the first generated one. Because of those unnecessary increments, the time goes too much ahead.

Proposal: Remove the time increment from getCurrentTimestamp() and add a generateTimestamp() method. I have attached a patch to solve this issue. I have decided to access this method from /core/Tracker/Generator/Tracker.php after the creation of the visit. It could be done in the constructor of /core/Tracker/Generator/Visit.php.

comment:2 Changed 4 years ago by vipsoft (robocoder)

  • Milestone changed from 0 - Piwik 0.6.2 to 2 - Piwik 0.8 - A Web Analytics platform

comment:3 Changed 4 years ago by matt (mattab)

  • Resolution set to fixed
  • Status changed from new to closed

(In [2211]) Fixes #1369 Thanks JulienM!

comment:4 Changed 4 years ago by vipsoft (robocoder)

  • Milestone changed from 2 - Piwik 0.8 - A Web Analytics platform to 0 - Piwik 0.6.2
Note: See TracTickets for help on using tickets.