• The WordPress Command Line Interface (wp-cli) tool produces the following error when you use it on a site where qTranslate-x is installed.

    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

    https://www.ads-software.com/plugins/qtranslate-x/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author John Clause

    (@johnclause)

    What if wp-cli calls a non-admin page? Probably, more sophisticated fix is needed?

    Thread Starter Michael Milette

    (@mjm4842)

    I can’t say for sure. You might be right. In my research, 90% of these error with other plugins have always been related to WP_ADMIN.

    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

    Plugin Author John Clause

    (@johnclause)

    I guess, I can put your fix in for the next release, and wait when somebody complains that it does not work on non-admin pages, which may never happen. Do you think it would be acceptable?

    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?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wp-cli doesn’t work with qtranslate-x installed’ is closed to new replies.