Opened 4 years ago

Closed 3 years ago

#1769 closed Bug (fixed)

Live Plugin has a timezone problem

Reported by: Ilinsekt Owned by: vipsoft
Priority: normal Milestone: Piwik 1.1
Component: Core Keywords:
Cc: Sensitive: no

Description

As far as I can tell, visit_first_action_time is stored in the database in UTC, the Live visitor log, however, does not account for that (or does so insufficiently) in the WHERE clause.
For example: I have a website on UTC+02:00, and I had a visitor at 23:05. So this visitor was displayed, when the day of the recorded server time was selected in the calendar, however the displayed time was corrected for the timezone, which gave a very interesting effect: instead of displaying as 2010/10/13 23:05 it was displayed as 2010/10/14 01:05. After selecting 2010/10/14 in the calendar, it was not displayed at all.

The following patch needs to be applied, to make the visitors show up at the day they visited by the website timezone, not server time (description fits on trunk-r3248):

* plugins/Live/API.php  
  modify function loadLastVisitorDetailsFromDatabase, replace 
  $processedDate = Piwik_Date::factory($date,$currentTimezone);
  with
  $processedDate = Piwik_Date::factory($date)->setTimezone($currentTimezone);
  
  modify function loadLastVisitorDetailsFromDatabase, replace
  array_push(  $whereBind,
    $processedPeriod->getDateStart()->toString(),
    $processedPeriod->getDateEnd()->addDay(1)->toString());
    
  with
  array_push(  $whereBind,
    $processedPeriod->getDateStart()->toString('Y-m-d H:m:s'),
    $processedPeriod->getDateEnd()->addDay(1)->toString('Y-m-d H:m:s'));

Attachments (2)

piwik_live_bug01.png (60.7 KB) - added by Ilinsekt 4 years ago.
piwik_live_bug02.png (26.2 KB) - added by Ilinsekt 4 years ago.

Download all attachments as: .zip

Change History (7)

Changed 4 years ago by Ilinsekt

Changed 4 years ago by Ilinsekt

comment:1 Changed 4 years ago by peterb (peterbo)

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

Dupe of #1375

Please apply vipsoft's patch / changeset [3246]. Please come up with feedback for the patch and if it fixes the problem.

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

  • Keywords Live vistor log timezone removed
  • Milestone set to 1.1 - Piwik 1.1
  • Resolution duplicate deleted
  • Status changed from closed to reopened

I'll add some unit tests to the Live plugin.

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

  • Owner set to vipsoft
  • Status changed from reopened to new

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

At some point, I reverted [3026]. I'll re-test with UTC +/- offsets over a 24 hour period.

comment:5 Changed 3 years ago by vipsoft (robocoder)

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

(In [3390]) fixes #1769 - Live Visitor Log timezone problem; thanks Ilinsekt for the patch (the only problem was changing H:m:s to H:i:s)

Note: See TracTickets for help on using tickets.