Strange PHP fatal error (but doesn't appear to really be fatal) with one particular function call
-
I've been frustratingly trying to troubleshoot a very strange issue which made no sense to me. It seems to have everyone perplexed in the communities I've been trying to get support from. It seems like the latest theory though is this might have something to do with the package used in Cloudron or rather maybe the cron part of it.
I've got a detailed post here about it but the summary is that I am trying to use a Bricks Builder function in a code snippet and no matter how I apply the snippet (via MainWP or WPCodeBox for example), it always throws a fatal PHP error even though it seems to still function correctly. What's strange is it works perfectly fine is the code snippet is in the functions.php file. That last part is why I thought initially this was a weird issue of the snippet manager I was using but then I tested others and they all had the same behaviour.
I was wondering if anyone had any thoughts on this from the Cloudron side, thinking maybe there's something perhaps in the way it's packaged where the cron is running and perhaps looking for any "undefined" functions even if it is actually defined but perhaps somehow ignoring the order of operations for example. That's the theory from the last forum post here btw which may be worth a read for his thoughts (he's a very talented developer in the WordPress community). The reason that's a theory currently is due to the behaviour persisting no matter what code snippet plugin or method (even my own custom plugin for example) is used, as well as the fact that it only is thrown during the cron task.
Mar 14 22:02:16 => Run cron job Mar 14 22:02:16 PHP Fatal error: Uncaught Error: Call to undefined function bricks_is_builder_main() in /app/data/public/wp-content/plugins/wpcodebox/src/Runner/PhpSnippetRunner.php(22) : eval()'d code:6 Mar 14 22:02:16 Stack trace: Mar 14 22:02:16 #0 /app/data/public/wp-includes/class-wp-hook.php(308): Wpcb\Runner\PhpSnippetRunner->{closure}() Mar 14 22:02:16 #1 /app/data/public/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters() Mar 14 22:02:16 #2 /app/data/public/wp-includes/plugin.php(517): WP_Hook->do_action() Mar 14 22:02:16 #3 /app/data/public/wp-settings.php(617): do_action() Mar 14 22:02:16 #4 phar:///app/pkg/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1336): require('...') Mar 14 22:02:16 #5 phar:///app/pkg/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1254): WP_CLI\Runner->load_wordpress() Mar 14 22:02:16 #6 phar:///app/pkg/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start() Mar 14 22:02:16 #7 phar:///app/pkg/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(78): WP_CLI\Bootstrap\LaunchRunner->process() Mar 14 22:02:16 #8 phar:///app/pkg/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap() Mar 14 22:02:16 #9 phar:///app/pkg/wp/php/boot-phar.php(11): include('...') Mar 14 22:02:16 #10 /app/pkg/wp(4): include('...') Mar 14 22:02:16 #11 {main} Mar 14 22:02:16 thrown in /app/data/public/wp-content/plugins/wpcodebox/src/Runner/PhpSnippetRunner.php(22) : eval()'d code on line 6 Mar 14 22:02:16 Fatal error: Uncaught Error: Call to undefined function bricks_is_builder_main() in /app/data/public/wp-content/plugins/wpcodebox/src/Runner/PhpSnippetRunner.php(22) : eval()'d code:6 Mar 14 22:02:16 Stack trace: Mar 14 22:02:16 #0 /app/data/public/wp-includes/class-wp-hook.php(308): Wpcb\Runner\PhpSnippetRunner->{closure}() Mar 14 22:02:16 #1 /app/data/public/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters() Mar 14 22:02:16 #2 /app/data/public/wp-includes/plugin.php(517): WP_Hook->do_action() Mar 14 22:02:16 #3 /app/data/public/wp-settings.php(617): do_action() Mar 14 22:02:16 #4 phar:///app/pkg/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1336): require('...') Mar 14 22:02:16 #5 phar:///app/pkg/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1254): WP_CLI\Runner->load_wordpress() Mar 14 22:02:16 #6 phar:///app/pkg/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start() Mar 14 22:02:16 #7 phar:///app/pkg/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(78): WP_CLI\Bootstrap\LaunchRunner->process() Mar 14 22:02:16 #8 phar:///app/pkg/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap() Mar 14 22:02:16 #9 phar:///app/pkg/wp/php/boot-phar.php(11): include('...') Mar 14 22:02:16 #10 /app/pkg/wp(4): include('...') Mar 14 22:02:16 #11 {main} Mar 14 22:02:16 thrown in /app/data/public/wp-content/plugins/wpcodebox/src/Runner/PhpSnippetRunner.php(22) : eval()'d code on line 6 Mar 14 22:02:16 Error: There has been a critical error on this website.Learn more about troubleshooting WordPress. There has been a critical error on this website. Mar 14 22:02:20 - - - [15/Mar/2023:05:02:20 +0000] "GET /wp-includes/version.php HTTP/1.1" 200 - "-" "Mozilla (CloudronHealth)"
Thankfully I now have a solution by using the "if function exists" code, but my concern is I wasted many hours trying to figure this out (didn't want every website logging this error every 60 seconds as I deploy it slowly to more and more websites under my management) and am starting to think maybe this was something unique to the way WordPress is configured with Cloudron specifically and possible other issues that may stem from this down the road. Wanted to just bring this up as a possible concern.
-
@d19dotca I could be way off, but possibly something to do with PHP versions?
I recently hit a PHP fatal error too and I think that was the cause in my case: the plugin I w as using is seemingly not compatible with PHP 8.1 (nor actually with 8.0.27 - which is what you get if you use the Cloudron LAMP app and chose PHP 8.0 - even though the plugin is compatible with 8.0.21).
So until the plugin is updated to work with PHP 8.1 to use this plugin on Cloudron I need to use the LAMP app with PHP 7.4 which isn't even getting security updates any more.
-
@jdaviescoates I was thinking about this too but I don't think that's the case only because in another Facebook post I had it was confirmed they were running the same version of PHP when they didn't see the same behaviour. And for Bricks Builder, it (supposedly) supports PHP up to 8.1 as far as I'm aware, though of course there could still be some PHP defects I suppose.
Also it works fine if using the theme's functions.php file and only triggered on cron tasks for some unknown reason, so leads me to think the package itself may be the explanation for the strange behaviour. I may be poking the wrong areas though too.
-
@d19dotca Looks like this comes from the cron part, indeed.
Can you please try this in the web terminal manually:
sudo -u www-data -i -- /app/pkg/wp --skip-themes --path=/app/data/public/ cron event run --due-now
Hopefully, the above gives the error. Next, try to run the command without
--skip-themes
. Does that make it work ? -
@girish Looks like you narrowed it down!
I ran the test and it threw the error right away as-is, and then when I removed the
--skip-themes
from the command then it ran without issue.I take it this means the current cron task in the Cloudron package for WordPress skips the theme when running which is causing the issue? Or have I misunderstood?
Command I ran first:
sudo -u www-data -i -- /app/pkg/wp --skip-themes --path=/app/data/public/ cron event run --due-now
PHP Fatal error: Uncaught Error: Call to undefined function bricks_is_builder_main() in /app/data/public/wp-content/plugins/mainwp-child/class/class-mainwp-utility.php(87) : eval()'d code:6 Stack trace: #0 /app/data/public/wp-includes/class-wp-hook.php(308): MainWP\Child\MainWP_Utility::{closure}() #1 /app/data/public/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters() #2 /app/data/public/wp-includes/plugin.php(517): WP_Hook->do_action() #3 /app/data/public/wp-settings.php(617): do_action() #4 phar:///app/pkg/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1336): require('...') #5 phar:///app/pkg/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1254): WP_CLI\Runner->load_wordpress() #6 phar:///app/pkg/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start() #7 phar:///app/pkg/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(78): WP_CLI\Bootstrap\LaunchRunner->process() #8 phar:///app/pkg/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap() #9 phar:///app/pkg/wp/php/boot-phar.php(11): include('...') #10 /app/pkg/wp(4): include('...') #11 {main} thrown in /app/data/public/wp-content/plugins/mainwp-child/class/class-mainwp-utility.php(87) : eval()'d code on line 6 Fatal error: Uncaught Error: Call to undefined function bricks_is_builder_main() in /app/data/public/wp-content/plugins/mainwp-child/class/class-mainwp-utility.php(87) : eval()'d code:6 Stack trace: #0 /app/data/public/wp-includes/class-wp-hook.php(308): MainWP\Child\MainWP_Utility::{closure}() #1 /app/data/public/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters() #2 /app/data/public/wp-includes/plugin.php(517): WP_Hook->do_action() #3 /app/data/public/wp-settings.php(617): do_action() #4 phar:///app/pkg/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1336): require('...') #5 phar:///app/pkg/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1254): WP_CLI\Runner->load_wordpress() #6 phar:///app/pkg/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start() #7 phar:///app/pkg/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(78): WP_CLI\Bootstrap\LaunchRunner->process() #8 phar:///app/pkg/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap() #9 phar:///app/pkg/wp/php/boot-phar.php(11): include('...') #10 /app/pkg/wp(4): include('...') #11 {main} thrown in /app/data/public/wp-content/plugins/mainwp-child/class/class-mainwp-utility.php(87) : eval()'d code on line 6 Error: There has been a critical error on this website.Learn more about troubleshooting WordPress. There has been a critical error on this website.
When running this command (without
--skip-themes
) :sudo -u www-data -i -- /app/pkg/wp --path=/app/data/public/ cron event run --due-now
Executed the cron event 'wp_privacy_delete_old_export_files' in 0.004s. Executed the cron event 'rediscache_discard_metrics' in 0.004s. Executed the cron event 'seopress_404_cron_cleaning' in 0.003s.
Do we need to fix the package in this case? Or is there something unique I need to do in my setups only?
-
@girish thank you, I’ll test his soon! Appreciate the quick responses to this very mysterious issue (I spent way too much time trying to figure it out before realizing it was maybe a Cloudron app package thing since nobody else I’d discuss it with had the issue, haha). I’ll update here when I’ve completed the test.
-
-