Jesin's Blog

Welcome to the Portal of Technology

  • Facebook
  • GitHub
  • RSS
  • Twitter
  • Home
  • Categories
    • Domains
    • Linux
    • Networking
    • PHP
    • Virtualization
    • Web Design
    • Web Servers
    • Windows
  • WordPress Plugins
    • Custom Error Pages
    • HTTP Digest Authentication
    • Mailgun Email Validator
  • Toolbox
    • DNS Lookup Tool
    • htdigest Generator Tool Online
    • htpasswd Generator Tool Online
    • HTTP Headers Lookup Tool
    • MD5 Encryption Tool
    • Open Port Check Tool
    • SHA-1 Encryption Tool
    • URL Encoding/Decoding Tool
  • About Me
  • Contact Me
  • Sitemap
Home ›
wp-cli

WP CLI fix “Warning: Some code is trying to do a URL redirect.” error

July 22, 2018 Web Design Jesin A Leave a Comment

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.

Tags: wordpress, wp-cli

Get a wealth of information delivered to your inbox. Subscribe and never miss a single article.

  • Tutorials and howtos
  • Code, scripts and commands
  • Online Tools

* No spam, unsubscribe anytime

Hire Me

  • SSL installation and hardening (A+ on Qualys SSL test)
  • Apache & Nginx configuration
  • Email deliverability improvement (10/10 on Mail Tester & MailGenius)
  • WordPress customization, optimization and migration
  • and much more…

    Tools

    • DNS Lookup Tool
    • htdigest Generator Tool Online
    • htpasswd Generator Tool Online
    • HTTP Headers Lookup Tool
    • MD5 Encryption Tool
    • Open Port Check Tool
    • SHA-1 Encryption Tool
    • URL Encoding/Decoding Tool

    Nav

    • Home
    • About Me
    • Contact Me
    • Privacy Policy
    • Sitemap
    Vultr SSD VPS

    Creative Commons License
    Jesin's Blog by Jesin A is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
    Based on a work at websistent.com.