• I am using Wordfence with the database storage engine option. Like this WF help page suggests, I have the following in my wp-config.php:

    if( ! defined('WFWAF_STORAGE_ENGINE')) { 
    	define('WFWAF_STORAGE_ENGINE', 'mysqli'); 
    }

    That’s the only guidance I can find in terms of how wordfence interacts with the wp-cli. However, when I run a command such as wp plugin update or wp option get home, I always get the following error output, before the cli result:

    $ wp plugin update --dry-run --all
    An unexpected error occurred during WAF execution: Error: Call to undefined method mysqli_stmt::get_result() in /var/www/html/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/mysql.php:977
    
    Stack trace:
    #0 /var/www/html/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/mysql.php(995): wfWAFStorageEngineMySQLi->statementToArray()
    #1 /var/www/html/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/mysql.php(39): wfWAFStorageEngineMySQLi->get_var()
    #2 /var/www/html/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/mysql.php(53): wfWAFStorageMySQL->usingLowercase()
    #3 /var/www/html/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/mysql.php(628): wfWAFStorageMySQL->networkTable()
    #4 /var/www/html/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/mysql.php(594): wfWAFStorageMySQL->getStorageTable()
    #5 /var/www/html/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/mysql.php(317): wfWAFStorageMySQL->autoloadConfig()
    #6 /var/www/html/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/utils.php(1063): wfWAFStorageMySQL->getConfig()
    #7 /var/www/html/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/request.php(418): wfWAFUtils::rawPOSTBody()
    #8 /var/www/html/wp-content/plugins/wordfence/waf/bootstrap.php(55): wfWAFRequest::createFromGlobals()
    #9 /var/www/html/wp-content/plugins/wordfence/waf/bootstrap.php(939): wfWAFWordPressRequest::createFromGlobals()
    #10 /var/www/html/wp-content/plugins/wordfence/wordfence.php(117): require_once('...')
    #11 /var/www/html/wp-settings.php(407): include_once('...')
    #12 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1336): require('...')
    #13 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1254): WP_CLI\Runner->load_wordpress()
    #14 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
    #15 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(78): WP_CLI\Bootstrap\LaunchRunner->process()
    #16 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
    #17 phar:///usr/local/bin/wp/php/boot-phar.php(11): include('...')
    #18 /usr/local/bin/wp(4): include('...')
    #19 {main}
    No plugin updates available.

    I am running Wordfence 7.10.3 on our own server. Let me know if I can provide any other information to help troublshoot.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support wfpeter

    (@wfpeter)

    Hi @jakeparis, thanks for your question.

    The message?Call to undefined method mysqli_stmt::get_result()?suggests that the?mysqli?or mysqlnd extension isn’t being loaded when running PHP on the command line.

    Since this is your own server, I’d recommend checking the php.ini and related config files for the CLI, comparing them to the config for the web server or PHP-FPM (whichever you’re running), to make sure that they’re running the same MySQL extensions on both.

    Thanks,
    Peter.

    Thread Starter jakeparis

    (@jakeparis)

    Thanks for your response @wfpeter . I confirmed we are running both mysqli and mysqlnd extensions in both web server and cli environments, and they are the same configs and version on both.

    One possibility problem I can think of is that we are running an older version of MariaDB (10.3.27). I wonder if there are things that are not available in this earlier version Mariadb that might causing the problem. I do think that’s a long shot, however, due to the fact that WF seems to be running just fine from the UI.

    Would it make sense to attempt to bypass WF if the wp-cli is running? Or is wordfence providing some level of protection from there as well?

    Thread Starter jakeparis

    (@jakeparis)

    Hello @wfpeter . I just wanted to close the loop on this. My error was that I added the define('WFWAF_STORAGE_ENGINE', 'mysqli'); line to my wp-config.php. Which is ok, only if there is no wordfence-waf.php file. Since I had the wordfence-waf.php file, I should have added the constant there.

    I moved the constant definition to wordfence-waf.php and all the cli errors are gone.

    Thread Starter jakeparis

    (@jakeparis)

    Actually, I’m incorrect. Adding that to wordfence-waf.php stopped the errors during cli commands, but now there are plenty of errors (the same error) in our regular php logs. So I re-added

    if( ! defined(‘WFWAF_STORAGE_ENGINE’)) {
    define(‘WFWAF_STORAGE_ENGINE’, ‘mysqli’);
    }

    to our wp-config.php (so now I have both), but still the errors persist.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Error w/ WP-CLI: “unexpected error occurred during WAF execution…”’ is closed to new replies.