WP Toolkit is probably the go to feature of WHM’s cPanel hosting. However, at time, the scanner breaks down with nasty error. An example is below:
Scanning for WordPress websites was performed with errors: Failed to register instance at '/home/example/public_html': Failed to reset cache for the instance #104: [error]FailedToExecuteWpCliCommand: exit status 255[/error] Fatal error: Uncaught Error: Undefined constant "�WP_MEMORY_LIMIT�" in /usr/local/cpanel/3rdparty/wp-toolkit/plib/vendor/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1343) : eval()'d code:104 Stack trace: #0 /usr/local/cpanel/3rdparty/wp-toolkit/plib/vendor/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1343): eval() #1 /usr/local/cpanel/3rdparty/wp-toolkit/plib/vendor/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1302): WP_CLI\Runner->load_wordpress() #2 /usr/local/cpanel/3rdparty/wp-toolkit/plib/vendor/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start() #3 /usr/local/cpanel/3rdparty/wp-toolkit/plib/vendor/wp-cli/vendor/wp-cli/wp-cli/php/bootstrap.php(83): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState)) #4 /usr/local/cpanel/3rdparty/wp-toolkit/plib/vendor/wp-cli/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap() #5 /usr/local/cpanel/3rdparty/wp-toolkit/plib/vendor/wp-cli/vendor/wp-cli/wp-cli/php/boot-fs.php(17): require_once('/usr/local/cpan...') #6 /usr/local/cpanel/3rdparty/wp-toolkit/plib/vendor/wp-cli/wpt-wp-cli.php(31): require_once('/usr/local/cpan...') #7 Command line code(1): require('/usr/local/cpan...') #8 {main} thrown in /usr/local/cpanel/3rdparty/wp-toolkit/plib/vendor/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1343) : eval()'d code on line 104 Failed to register instance at '/home/example/public_html': Failed to reset cache for the instance #105: [error]FailedToExecuteWpCliCommand: exit status 255[/error] Fatal error: Uncaught Error: Undefined constant "�WP_MEMORY_LIMIT�" in /usr/local/cpanel/3rdparty/wp-toolkit/plib/vendor/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1343) : eval()'d code:104 Stack trace: #0 /usr/local/cpanel/3rdparty/wp-toolkit/plib/vendor/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1343): eval() #1 /usr/local/cpanel/3rdparty/wp-toolkit/plib/vendor/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1302): WP_CLI\Runner->load_wordpress() #2 /usr/local/cpanel/3rdparty/wp-toolkit/plib/vendor/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start() #3 /usr/local/cpanel/3rdparty/wp-toolkit/plib/vendor/wp-cli/vendor/wp-cli/wp-cli/php/bootstrap.php(83): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState)) #4 /usr/local/cpanel/3rdparty/wp-toolkit/plib/vendor/wp-cli/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap() #5 /usr/local/cpanel/3rdparty/wp-toolkit/plib/vendor/wp-cli/vendor/wp-cli/wp-cli/php/boot-fs.php(17): require_once('/usr/local/cpan...') #6 /usr/local/cpanel/3rdparty/wp-toolkit/plib/vendor/wp-cli/wpt-wp-cli.php(31): require_once('/usr/local/cpan...') #7 Command line code(1): require('/usr/local/cpan...') #8 {main} thrown in /usr/local/cpanel/3rdparty/wp-toolkit/plib/vendor/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1343) : eval()'d code on line 104
As you can see, it’s a right old mess. The problem isn’t the site’s memory limit, but rather the toolkit’s memory limit which is defined by the cPanel PHP binaries. How to fix?
Why this happens
WP Toolkit tries to bootstrap WordPress. It does so by checking the wp-config.php
file and finding some errors. In this instance, the error was this nasty line of code right at the end:
cat wp-config.php ... define(�WP_MEMORY_LIMIT�, �64M�);
Please also note first WP Toolkit couldn’t scan the folder because I had to delete this:
rm .wp-toolkit-ignore
Anyway, fixing the corrupted WP_MEMORY_LIMIT
with the correct line, e.g.:
define('WP_MEMORY_LIMIT', '64M');
Makes the scan go further.
Then we get this error, because now at least WP Toolkit can try to load the site:
Scanning for WordPress websites was performed with errors: Failed to register instance at '/home/example/public_html': Failed to reset cache for the instance #111: Fatal error: Uncaught Error: Call to undefined function create_function() in /home/example/public_html/wp-content/plugins/better-recent-posts-widget-pro/better-recent-posts-widget-pro.php:245
Next our Google needs refinement, so we google this:
Call to undefined function create_function() in /home/example/public_html/wp-content/plugins/better-recent-posts-widget-pro
Quickly we find out that we have a PHP 7/8 compatibility issue.
So this site is so old we cannot run the toolkit without downgrading to PHP 7.
Oops. The server doesn’t even have PHP 7 anymore. Moving it to a another server.