The WordPress command-line interface is incredibly useful when changing the domain URL of a website. When working on a client’s website I encountered the following warning when I ran the wp search-replace
command.
Warning: Some code is trying to do a URL redirect. Backtrace: #0 WP_CLI\Utils\wp_redirect_handler(http://example.com/) called at [/srv/users/serverpilot/apps/APPNAME/public/wp-includes/class-wp-hook.php:288] #1 WP_Hook->apply_filters(http://example.com/, Array ([0] => http://example.com/,[1] => 301)) called at [/srv/users/serverpilot/apps/APPNAME/public/wp-includes/plugin.php:203] #2 apply_filters(wp_redirect, http://example.com/, 301) called at [/srv/users/serverpilot/apps/APPNAME/public/wp-includes/pluggable.php:1199] #3 wp_redirect(http://example.com/, 301) called at [/srv/users/serverpilot/apps/APPNAME/public/wp-content/plugins/quick-pagepost-redirect-plugin/page_post_redirect_plugin.php:2151] #4 quick_page_post_reds->redirect() called at [/srv/users/serverpilot/apps/APPNAME/public/wp-includes/class-wp-hook.php:286] #5 WP_Hook->apply_filters(, Array ([0] => )) called at [/srv/users/serverpilot/apps/APPNAME/public/wp-includes/class-wp-hook.php:310] #6 WP_Hook->do_action(Array ([0] => )) called at [/srv/users/serverpilot/apps/APPNAME/public/wp-includes/plugin.php:453] #7 do_action(init) called at [/srv/users/serverpilot/apps/APPNAME/public/wp-settings.php:450] #8 require(/srv/users/serverpilot/apps/APPNAME/public/wp-settings.php) called at [phar:///opt/sp/bin/wp-cli.phar/php/WP_CLI/Runner.php:1174] #9 WP_CLI\Runner->load_wordpress() called at [phar:///opt/sp/bin/wp-cli.phar/php/WP_CLI/Runner.php:1100] #10 WP_CLI\Runner->start() called at [phar:///opt/sp/bin/wp-cli.phar/php/WP_CLI/Bootstrap/LaunchRunner.php:23] #11 WP_CLI\Bootstrap\LaunchRunner->process(WP_CLI\Bootstrap\BootstrapState Object ([WP_CLI\Bootstrap\BootstrapStatestate] => Array ())) called at [phar:///opt/sp/bin/wp-cli.phar/php/bootstrap.php:75] #12 WP_CLI\bootstrap() called at [phar:///opt/sp/bin/wp-cli.phar/php/wp-cli.php:23] #13 include(phar:///opt/sp/bin/wp-cli.phar/php/wp-cli.php) called at [phar:///opt/sp/bin/wp-cli.phar/php/boot-phar.php:8] #14 include(phar:///opt/sp/bin/wp-cli.phar/php/boot-phar.php) called at [/opt/sp/bin/wp-cli.phar:4]
Googling this warning message brought up several links to GitHub which all recommended using the --user=someadmin
parameter. I tried that too but got the same warning. Looking at the backtrace log it is clear that the quick-pagepost-redirect-plugin is causing this redirect, so I used the --skip-plugins=
parameter to skip loading this plugin.
wp search-replace --skip-plugins=quick-pagepost-redirect-plugin 'http://example.com' 'https://example.com' --skip-columns=guid
And I had no issues running the search and replace operation.
On a sidenote if you are looking for a shared web host with WP CLI support choose SiteGround (affiliate link). They also have other WordPress specific features like automated migration and caching.
Leave a Reply