• Resolved Clifford Paulick

    (@cliffpaulick)


    Using Local Flywheel WP-CLI, running this command with Redirection v5.0.1:

    wp post meta list 496 --fields=meta_key,meta_value --format=json > data.json;

    It generates this error:

    PHP Fatal error:  Uncaught Error: Class "WP_CLI" not found in /wp-content/plugins/redirection/redirection-cli.php:297
    Stack trace:
    #0 /wp-content/plugins/redirection/redirection.php(96): require_once()
    #1 /wp-settings.php(388): include_once('/Users/cliff/Lo...')
    #2 phar:///Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1237): require('/Users/cliff/Lo...')
    #3 phar:///Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1158): WP_CLI\Runner->load_wordpress()
    #4 phar:///Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(23): WP_CLI\Runner->start()
    #5 phar:///Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/wp-cli.phar/vendor/wp-cli/wp-cli/php/bootstrap.php(74): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState))
    #6 phar:///Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/wp-cli.phar/vendor/wp-cli/wp-cli/php/wp-cli.php(27): WP_CLI\bootstrap()
    #7 phar:///Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/wp-cli.phar/php/boot-phar.php(11): include('phar:///Applica...')
    #8 /Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/wp-cli.phar(4): include('phar:///Applica...')
    #9 {main}
      thrown in /wp-content/plugins/redirection/redirection-cli.php on line 297
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author John Godley

    (@johnny5)

    I’m not able to reproduce this problem, and I use Local to develop Redirection. Do you have local changes that may be changing how WP works?

    Thread Starter Clifford Paulick

    (@cliffpaulick)

    Thanks for the quick reply. Are you using the same?

    WP 5.6.1
    nginx
    PHP 7.4.1
    MySQL 8.0.16
    Local v5.9.8+5191 on macOS 11.2.1

    Plugin Author John Godley

    (@johnny5)

    Yes, pretty much. I’m using PHP 8 now, but it worked just the same with PHP 7

    Thread Starter Clifford Paulick

    (@cliffpaulick)

    The only place in my WP root folder and down that I find class WP_CLI_Command (which your class file is extending) is within my own plugin’s Composer vendor directory.

    Oddly, running composer why wp-cli says:

    [InvalidArgumentException]
    Could not find package “wp-cli” in your project

    so I’m unsure how/why it’s installed there anyway…

    But this error pointing to your plugin happens whether or not my plugin is active during the WP-CLI command.

    So maybe you could try running the WP-CLI command while the production/zip version of Redirection is installed on your site instead of the dev version?

    Plugin Author John Godley

    (@johnny5)

    WP CLI is not part of WP, and needs to be installed separately.

    WP CLI has been part of the plugin for many years and there have been no reports of problems.

    There’s no difference between the dev and production plugin, when it comes to WP CLI. Usually it is installed at a global level, not within a plugin directory. That may be part of the problem.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘PHP Fatal error: Class “WP_CLI” not found in redirection-cli.php:297’ is closed to new replies.