Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#821 closed Bug (fixed)

Incompatible method declaration in Piwik_Log_APICall

Reported by: hatbanger Owned by:
Priority: major Milestone: Piwik 0.4.1
Component: Core Keywords:
Cc: Sensitive:

Description

Hi,

I just upgraded to PHP 5.2.10 (from 5.2.9) and now I get the following error accessing piwik:

Declaration of Piwik_Log_APICall::log() should be compatible with that of Piwik_Log::log() 
in '/path/to/piwik/core/Log/APICall.php' at the line 52

Here's the stack trace:

# 0  Piwik_ErrorHandler(2048, Declaration of Piwik_Log_APICall::log() should be compatible with that of Piwik_Log::log(), /path/to/piwik/core/Log/APICall.php, 52, Array ()) called at [/path/to/piwik/core/Piwik.php:1232]
# 1  Piwik::createLogObject() called at [/path/to/piwik/core/Piwik.php:1232]
# 2  Piwik::createLogObject() called at [/path/to/piwik/core/FrontController.php:232]
# 3  Piwik_FrontController->init() called at [/path/to/piwik/index.php:53]

Benjamin

Attachments (2)

logger.patch (774 bytes) - added by hatbanger 5 years ago.
errorhandler.patch (667 bytes) - added by hatbanger 5 years ago.

Download all attachments as: .zip

Change History (9)

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

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

(In [1247]) fixes #821, refs #819

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

  • Resolution fixed deleted
  • Status changed from closed to reopened

Changed 5 years ago by hatbanger

comment:3 Changed 5 years ago by hatbanger

Hi,

I just wrote a detailed bug report concerning my reopening of the bug, but when I tried to add the attachment, Trac unfortunately killed the text content. Sorry for the inconvenience. Here it is again:

The method declaration mismatch still occurs, as you can see, in two lines of the piwik code:

Declaration of Piwik_Log_Error::log() should be compatible with that of Piwik_Log::log() 
in '/var/www/stats.genetsis.de/htdocs/piwik/core/Log/Error.php' at the line 65

and

Declaration of Piwik_Log_APICall::log() should be compatible with that of Piwik_Log::log() 
in '/var/www/stats.genetsis.de/htdocs/piwik/core/Log/APICall.php' at the line 62

Changing the method signatures would be a quick and working fix for that. See the attached file logger.patch.

Anyhow, I did some research regarding the PHP version issue and found this bug addressing an inconsistency issue between the PHP's documentation and its actual behaviour when using set_error_handler. PHP now always executes the custom error handler function regardless of any error_reporting() settings.

Because of that, and because of the two errors mentioned above, piwik's error handler now fails (see ErrorHandler.php, line 37) and as a result of that, it blindly exits the application.

A fix for that could be to ignore non-fatal errors such as E_NOTICE, E_USER_NOTICE and E_STRICT before exiting (see attached file errorhandler.patch), but I suggest that you do some detailed testing on that and PHP 5.2.10 in general. :-)

Benjamin

Changed 5 years ago by hatbanger

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

  • Milestone set to 1 - Piwik 0.4.1

comment:5 Changed 5 years ago by matt (mattab)

if it is a bug in PHP then we don't want to work around this, especially since the bug appears to have been fixed in PHP CVS.

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

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

(In [1249]) fixes #821 - rename the log() method in subclasses of Piwik_Log because
PHP (by design) isn't intended to support overloading to the extent of other
OOP languages (i.e., "multiple methods with the same name but different
quantities and types of arguments")

ref: http://ca.php.net/manual/en/language.oop5.overloading.php

this change arises because PHP 5.2.10 escalated the log message
priority for incompatible method declarations

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

(In [1250]) refs #821 - revised patch

Note: See TracTickets for help on using tickets.