Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ErrorHandler - Nesting level too deep - recursive dependency #2499

Closed
peterbo opened this issue Jun 20, 2011 · 16 comments
Closed

ErrorHandler - Nesting level too deep - recursive dependency #2499

peterbo opened this issue Jun 20, 2011 · 16 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc. Critical Indicates the severity of an issue is very critical and the issue has a very high priority.
Milestone

Comments

@peterbo
Copy link
Contributor

peterbo commented Jun 20, 2011

See reportings in http://forum.piwik.org/read.php?5,77659 and http://forum.piwik.org/read.php?5,78118.

Reason for the error seems to be the use of var_export in connection with debug_backtrace, see http://bugs.php.net/bug.php?id=30471 (bugs.php.net down atm)

PHP 5.2

Other configurations affected, see below

@anonymous-matomo-user
Copy link

Replying to peterb:

I'm using PHP 5.1.6 and just started getting this problem with my upgrade to Piwik 1.5 from 1.4.

Using XDebug, I tracked it down to a problem with Zend_Session. It's failing to write sessions to the database table, possibly because the database handle is no longer available when Zend_Session::writeClose() is called in the destructor of Zend_Session_SaveHandler_DbTable (I'm not 100% certain.)

At any rate, I changed the file core/Session.php, adding:

register_shutdown_function(array( "Zend_Session", "writeClose" ), true);

...after the line:

Zend_Session::start();

...and it now seems to work for me (no more nesting level errors, and I can also log into Piwik again.) But I haven't tested it on any other version of PHP.

@peterbo
Copy link
Contributor Author

peterbo commented Jun 20, 2011

ferment, could you please tell us, what a var_dump($bt) injected into the file core/ErrorHandler.php (directly before, after or instead of the line "//array_shift($bt);" echos? I think we would be a step further then, because there is somehow a recursion in that context, i suppose.

@anonymous-matomo-user
Copy link

On my side, the adding of register_shutdown_function doesn't work.

I have Piwik running with cronjobs and the error is only coming in the cronjob via email. Login into the Piwik web webinterface works without problems.

PHP Fatal error:  Nesting level too deep - recursive dependency? in /srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/core/ErrorHandler.php on line 36
PHP Fatal error:  Nesting level too deep - recursive dependency? in /srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/core/ErrorHandler.php on line 36
PHP Fatal error:  Nesting level too deep - recursive dependency? in /srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/core/ErrorHandler.php on line 36
PHP Fatal error:  Nesting level too deep - recursive dependency? in /srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/core/ErrorHandler.php on line 36

@anonymous-matomo-user
Copy link

Removing the line 36 brings out the following error:

Notice: Undefined offset: 7 in /srv/www/vhosts/pantanet.de/subdomains/piwik/httpdocs/core/ArchiveProcessing/Day.php on line 671 
#0 Piwik_ErrorHandler() called at [/srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/core/ArchiveProcessing/Day.php:671]
#1 Piwik_ArchiveProcessing_Day->updateInterestStats() called at [/srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/plugins/CustomVariables/CustomVariables.php:165]
#2 Piwik_CustomVariables->archiveDayAggregate() called at [/srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/plugins/CustomVariables/CustomVariables.php:138]
#3 Piwik_CustomVariables->archiveDay() called at [:]
#4 call_user_func_array() called at [/srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/libs/Event/Dispatcher.php:284]
#5 Event_Dispatcher->postNotification() called at [/srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/core/PluginsManager.php:609]
#6 Piwik_PostEvent() called at [/srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/core/ArchiveProcessing/Day.php:42]
#7 Piwik_ArchiveProcessing_Day->compute() called at [/srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/core/ArchiveProcessing.php:429]
#8 Piwik_ArchiveProcessing->launchArchiving() called at [/srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/core/Archive/Single.php:217]
#9 Piwik_Archive_Single->prepareArchive() called at [/srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/core/Archive/Single.php:246]
#10 Piwik_Archive_Single->get() called at [/srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/core/Archive/Single.php:424]
#11 Piwik_Archive_Single->getNumeric() called at [/srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/core/Archive/Array.php:89]
#12 Piwik_Archive_Array->getNumeric() called at [/srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/plugins/VisitsSummary/API.php:110]
#13 Piwik_VisitsSummary_API->getNumeric() called at [/srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/plugins/VisitsSummary/API.php:116]
#14 Piwik_VisitsSummary_API->getVisits() called at [:]
#15 call_user_func_array() called at [/srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/core/API/Proxy.php:179]
#16 Piwik_API_Proxy->call() called at [/srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/core/API/Request.php:121]
#17 Piwik_API_Request->process() called at [/srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/plugins/API/Controller.php:27]
#18 Piwik_API_Controller->index() called at [:]
#19 call_user_func_array() called at [/srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/core/FrontController.php:127]
#20 Piwik_FrontController->dispatch() called at [/srv/www/vhosts/xxx.de/subdomains/piwik/httpdocs/index.php:53]

@anonymous-matomo-user
Copy link

Attachment: var_dump($bt) from core/ErrorHandler.php
dump.html

@anonymous-matomo-user
Copy link

Replying to peterb:

ferment, could you please tell us, what a var_dump($bt) injected into the file core/ErrorHandler.php (directly before, after or instead of the line "//array_shift($bt);" echos? I think we would be a step further then, because there is somehow a recursion in that context, i suppose.

Sure. I've attached a copy of the dump to the thread.

@anonymous-matomo-user
Copy link

Replying to peterb:

I think what might be happening is that var_export() is getting stuck on a circular reference in one of the $bt args. I ran across a forum discussion about this while searching:

http://forum.kohanaframework.org/discussion/1631/var_dump-print_r-var_export/p1

@peterbo
Copy link
Contributor Author

peterbo commented Jun 21, 2011

Attachment: Thanks for the dump, ferment. The "Nesting level too deep"-Problem has nothing to do with other classes of piwik. It is a problem when one of the other classes throw an error, and contain a reference to itself (e.g. method chaining, &$object definition, etc.). This is often used within frameworks. Since var_export is not able to limit the depth of nesting, I propose the following patch for the ErrorHandler.
Refs_#2499.patch

@peterbo
Copy link
Contributor Author

peterbo commented Jun 21, 2011

Anthon, do we need to store executable PHP code in the logger (to reuse it somewhere for example), or would this patch make sense?

@anonymous-matomo-user
Copy link

Attachment: Applying this Patch doesn't work for me komplete, now i got many errors, see attachment.
errors.html

@peterbo
Copy link
Contributor Author

peterbo commented Jun 21, 2011

@GoSnA: yes, that's correct. As I stated, this is not related to the error that triggers the ErrorHandler. Now the Errors are displayed / handled correctly and we can track down the real root of the error(s).

@robocoder
Copy link
Contributor

Thanks Peter. I'll have to look at the preg_replace, but this evidently works better than var_export.

We should fix the Notices being emitted too.

@peterbo
Copy link
Contributor Author

peterbo commented Jun 21, 2011

GoSnA, this is strange - please make sure, all piwik files have been correctly updated to the newest version.

@mattab
Copy link
Member

mattab commented Jun 22, 2011

Could this somehow be linked to #2491 ?

@robocoder
Copy link
Contributor

(In [4949]) fixes #2499, refs #2409

@anonymous-matomo-user
Copy link

I strongly suggest to release 1.6 ASAP or at least 1.5.1 with this patch applied... My piwik was also broken and I fixed it by uploading the latest errorhandler.php.

@peterbo peterbo added this to the 1.5.1 Piwik 1.5.1 milestone Jul 8, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. Critical Indicates the severity of an issue is very critical and the issue has a very high priority.
Projects
None yet
Development

No branches or pull requests

4 participants