This Q&A thread addresses the warning about trying to access $GLOBALS in the Worker plugin’s Context.php file. It walks through inspecting the code, testing plugin conflicts, updating PHP settings, and using site_url() instead of raw globals.
Cannot acquire reference to $GLOBALS in /data/sites/web/sani-heatingbe/subsites/dev.sani-heating.be/wp-content/plugins/worker/src/MWP/WordPress/Context.php on line 31
That warning usually pops up when a plugin tries to use the global scope incorrectly. Here’s a quick rundown of steps you can run through:
Context.php around line 31.$GLOBALS is being used. Is it reading, assigning, or something else?wp-config.php, add or update:define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
wp-content/debug.log for extra clues.If line 31 looks like this:
$site_url = $GLOBALS['siteurl'];
That could blow up if $GLOBALS['siteurl'] isn’t set. Instead of tapping into $GLOBALS, you can grab the same value via a WordPress function:
$site_url = site_url();
WP Assistant is a free tool created by Atiba Software, a WordPress design and development company located in Nashville, TN. If you need more personalized WordPress assistance let us know, and we’ll get back to you ASAP!