Warning: Some code is trying to do a URL redirect. Backtrace:
#0 WP_CLI\Utils\wp_redirect_handler(https://localhost)
#1 call_user_func_array(WP_CLI\Utils\wp_redirect_handler, Array ([0] => https://localhost)) called at [/www/site/wp-includes/plugin.php:213]
#2 apply_filters(wp_redirect, https://localhost, 302) called at [/www/site/wp-includes/pluggable.php:1158]
#3 wp_redirect(https://localhost) called at [/www/site/wp-content/plugins/qtranslate-x/qtranslate_core.php:131]
#4 qtranxf_detect_language(Array ([cookie_enabled] => ,[scheme] => http,[host] => ,[path] => ,[original_url] => )) called at [/www/site/wp-content/plugins/qtranslate-x/qtranslate_core.php:64]
#5 qtranxf_init_language()
#6 call_user_func_array(qtranxf_init_language, Array ([0] => )) called at [/www/site/wp-includes/plugin.php:496]
#7 do_action(plugins_loaded) called at [phar:///usr/local/bin/wp/php/wp-settings-cli.php:249]
#8 require(phar:///usr/local/bin/wp/php/wp-settings-cli.php) called at [phar:///usr/local/bin/wp/php/wp-cli.php:26]
#9 include(phar:///usr/local/bin/wp/php/wp-cli.php) called at [phar:///usr/local/bin/wp/php/boot-phar.php:5]
#10 include(phar:///usr/local/bin/wp/php/boot-phar.php) called at [/usr/local/bin/wp:4]
As soon as I removed the qtranslate-x directory from the /wp-content/plugins directory, the tool works fine.
wp-cli version: 0.19.2
qTranslate-x version: 3.4.1
I did come up with a potential solution would require updating line 121 in qtranslate_core.php.
Was:
if(defined(‘WP_ADMIN’)){
Replace with:
if(defined(‘WP_ADMIN’) || defined(‘WP_CLI’)){
The change would not affect the plugin in any other way and, after making this change, the problem disappears.
I did some additional research for you on the topic. This search in Google might help.
Let me know if you have any questions or concerns or would like any additional information.
Best regards,
Michael Milette
]]>While I haven’t actually traced through the code, I suspect the wp-cli tool is not looking for admin access but rather just outputting some text in an admin context which is why it would be processing through WordPress filters like qTranslate-x. I get the error even when I just run the wp-cli tool without any parameters. That said, if you look at the types of functions wp-cli does, they are mostly administrative type functions.
With the fix, I was not just able run the wp-cli command but also use many of its functions without any trouble at all though I haven’t tried them all.
Best regards,
Michael
]]>Actually, it is kind of strange, if you call admin page via cli, would not WP_ADMIN be defined? If you call frontend page, then redirection might be prevented with a proper/canonical URL? What kind of URL do you call?
]]>