Page 1 of 1

Solved: PHP Fatal Error in Debug Mode

Posted: Thu Sep 27, 2018 3:35 pm
by rjo
Usually debug mode works fine (J! 3.8.12), but on a very (!) long list of (K2) articles I recently encountered a white screen with the following error log on the server:

Code: Select all

PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 129805252 bytes) in .../plugins/system/debug/debug.php on line 347
Allocating more memory did not help.

Solution:
plugins/system/debug/debug.php on line 347 can be made more robust:
Replace...

Code: Select all

echo str_replace('</body>', implode('', $html) . '</body>', $contents);
...with...

Code: Select all

echo str_replace('</body>', '', $contents);
echo implode('', $html) . '</body>';
This is less compact but less memory consuming as well. With this fix it took quite some time to load the page, but the fatal error was gone.
Hope that helps someone,