Opened 6 years ago
Last modified 6 years ago
#44429 new defect (bug)
WP-CLI incompatibility with wp_redirect( https://... )
Reported by: | ecahost7 | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | major | Version: | |
Component: | General | Keywords: | dev-feedback has-patch 2nd-opinion |
Focuses: | Cc: |
Description (last modified by )
Hello,
My wordpress wouldn't update and I see errors below,
I also trying to update my site URL to include www to it but I can't change it due update failure.
Warning: The system could not load some of this WordPress installation’s data. Certain sections of this interface may not function correctly. (XID nw85up) The system failed to run the wp-cli batch commands with the following issues: Warning: Some code is trying to do a URL redirect. Backtrace: #0 WP_CLI\Utils\wp_redirect_handler(https://) #1 call_user_func_array(WP_CLI\Utils\wp_redirect_handler, Array ([0] => https://)) called at [/home/rsed43dqsw/public_html/wp-includes/class-wp-hook.php:288] #2 WP_Hook->apply_filters(https://, Array ([0] => https://,[1] => 301)) called at [/home/rsed43dqsw/public_html/wp-includes/plugin.php:203] #3 apply_filters(wp_redirect, https://, 301) called at [/home/rsed43dqsw/public_html/wp-includes/pluggable.php:1196] #4 wp_redirect(https://, 301) called at [/home/rsed43dqsw/public_html/wp-content/plugins/force-https-littlebizzy/core/redirect.php:91] #5 FHTTPS_Core_Redirect->redirect() called at [/home/rsed43dqsw/public_html/wp-content/plugins/force-https-littlebizzy/core/redirect.php:68] #6 FHTTPS_Core_Redirect->start() #7 call_user_func_array(Array ([0] => FHTTPS_Core_Redirect Object (),[1] => start), Array ([0] => )) called at [/home/rsed43dqsw/public_html/wp-includes/class-wp-hook.php:286] #8 WP_Hook->apply_filters(, Array ([0] => )) called at [/home/rsed43dqsw/public_html/wp-includes/class-wp-hook.php:310] #9 WP_Hook->do_action(Array ([0] => )) called at [/home/rsed43dqsw/public_html/wp-includes/plugin.php:453] #10 do_action(plugins_loaded) called at [/home/rsed43dqsw/public_html/wp-settings.php:327] #11 require(/home/rsed43dqsw/public_html/wp-settings.php) called at [phar:///usr/local/cpanel/3rdparty/share/wp-cli/wp-cli.phar/php/WP_CLI/Runner.php:1174] #12 WP_CLI\Runner->load_wordpress() called at [phar:///usr/local/cpanel/3rdparty/share/wp-cli/wp-cli.phar/php/WP_CLI/Runner.php:1100] #13 WP_CLI\Runner->start() called at [phar:///usr/local/cpanel/3rdparty/share/wp-cli/wp-cli.phar/php/WP_CLI/Bootstrap/LaunchRunner.php:23] #14 WP_CLI\Bootstrap\LaunchRunner->process(WP_CLI\Bootstrap\BootstrapState Object ([] => Array ())) called at [phar:///usr/local/cpanel/3rdparty/share/wp-cli/wp-cli.phar/php/bootstrap.php:75] #15 WP_CLI\bootstrap() called at [phar:///usr/local/cpanel/3rdparty/share/wp-cli/wp-cli.phar/php/wp-cli.php:23] #16 include(phar:///usr/local/cpanel/3rdparty/share/wp-cli/wp-cli.phar/php/wp-cli.php) called at [phar:///usr/local/cpanel/3rdparty/share/wp-cli/wp-cli.phar/php/boot-phar.php:8] #17 include(phar:///usr/local/cpanel/3rdparty/share/wp-cli/wp-cli.phar/php/boot-phar.php) called at [/usr/local/cpanel/3rdparty/share/wp-cli/wp-cli.phar:4]
Attachments (3)
Change History (14)
#4
@
6 years ago
- Summary changed from WordPress update Failure to WP-CLI incompatibility with wp_redirect( https://... )
This ticket was mentioned in Slack in #core by afragen. View the logs.
6 years ago
#6
@
6 years ago
- Keywords 2nd-opinion added
The question arises, is this an issue in WP-CLI or in core? I don’t have a deep enough understanding of WP-CLI to be able to make that determination.
Any thoughts @schlessera ?
#7
follow-up:
↓ 8
@
6 years ago
@afragen I'd say it is actually an issue in the plugin that causes the redirect. Basically, the plugin does a "web-request-only" operation when it is not actually dealing with a web request.
That being said, there's a general assumption with WordPress that the code is only ever run in a web server context, so it is an easy trap for plugin developers to fall into... which means it might make sense to fix it from within Core.
However, if this is to be fixed in Core, I would suggest fixing it in a more general way by checking for the cli
SAPI, not for WP-CLI specifically.
I have to admit that I ignore what the possible combinations of use cases vs environments are, though, so I'm a bit worried we will just break something else in the process.
#8
in reply to:
↑ 7
@
6 years ago
Replying to schlessera:
@afragen I'd say it is actually an issue in the plugin that causes the redirect. Basically, the plugin does a "web-request-only" operation when it is not actually dealing with a web request.
That being said, there's a general assumption with WordPress that the code is only ever run in a web server context, so it is an easy trap for plugin developers to fall into... which means it might make sense to fix it from within Core.
However, if this is to be fixed in Core, I would suggest fixing it in a more general way by checking for the
cli
SAPI, not for WP-CLI specifically.
I can create another patch that does this check instead.
I have to admit that I ignore what the possible combinations of use cases vs environments are, though, so I'm a bit worried we will just break something else in the process.
And that’s precisely my problem too. I can’t really see all the far reaching effects this might have. On the surface it would seem to be straightforward as it would simply skip the function if the user is using a CLI.
Is there ever a use case for a redirect when using the CLI?
There is likely an error in https://core.trac.wordpress.org/home/rsed43dqsw/public_html/wp-content/plugins/force-https-littlebizzy/core/redirect.php:68 that needs to return when using in WP-CLI.
The issue is
wp_redirect()
doesn’t play well with HTTPS and WP-CLI and you will need to modify the code to exit early and not perform thewp_redirect()
call when using in WP-CLI.Adding something like the following at the beginning of that
redirect()
function should fix it.