Opened 3 years ago

Closed 3 years ago

#1963 closed Bug (fixed)

PDFReports: cron task stops with Error: Object of class Piwik_Date could not be converted to int (piwik/core/Date.php on line 47)

Reported by: ziegenberg Owned by:
Priority: normal Milestone: Piwik 1.1.1
Component: Core Keywords: nasty bug
Cc: Sensitive: no

Description

If some PDFReports are declared the Cron Task stops with an Error.
In the class Piwik_PDFReports the function getScheduledTasks (piwik/plugins/PDFReports/PDFReports.php, 40) calls Piwik_Date::factory (piwik/core/Date.php, 45) on line 49 and this factory expects a string as the first argument, but Piwik_PDFReports gives it a Piwik_Date Object. Solution to this problem was to call getTimestamp() on that Object to meet the requirements of the factory function. Actually I didn't know if you expect a UTC time or the Time with the Timezone in, so either getTimestamp() oder getTimestampUTC() might be correct.

I changed:

    $baseDate = Piwik_Date::factory("1971-01-01");
    foreach($sites as &$site)
    {
        $offsetDate = Piwik_Date::factory($baseDate,  $site['timezone']);

        // Earlier means a negative timezone
        if ( $offsetDate->isEarlier($baseDate) )
        {

to:

    $baseDate = Piwik_Date::factory("1971-01-01");
    foreach($sites as &$site)
    {
        $offsetDate = Piwik_Date::factory($baseDate->getTimestamp(),  $site['timezone']);

        // Earlier means a negative timezone
        if ( $offsetDate->isEarlier($baseDate) )
        {

Attachments (1)

backtrace.txt (3.3 KB) - added by ziegenberg 3 years ago.

Download all attachments as: .zip

Change History (2)

Changed 3 years ago by ziegenberg

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

  • Milestone set to Piwik 1.1.1
  • Resolution set to fixed
  • Status changed from new to closed

This was fixed in Piwik 1.1.1

Note: See TracTickets for help on using tickets.