• Resolved WPBot

    (@wpbot)


    Hello,
    I have the following problem with qTranslate X:

    Warning: Invalid argument supplied for foreach() in /path/wp-content/plugins/qtranslate-x/qtranslate_core.php on line 320
    
    Warning: Cannot modify header information - headers already sent by (output started at /path/wp-content/plugins/qtranslate-x/qtranslate_core.php:320) in /path/wp-content/plugins/qtranslate-x/qtranslate_core.php on line 115
    
    Warning: Cannot modify header information - headers already sent by (output started at /path/wp-content/plugins/qtranslate-x/qtranslate_core.php:320) in /path/wp-includes/pluggable.php on line 1178

    The problem occurs on initial page load when the “Detect the language of the browser and redirect accordingly.” option is enabled.
    I’ve tried using the latest beta version for the moment (2.9.7.7) but there was no change (the line numbers in the message above are displayed from the latest beta, they’re different in the latest stable version 306, 116 and 1178).
    If I set PHP not to display the errors everything works fine.

    This happens with every theme I’ve tried including the ones coming with WordPress, so the theme could be ruled out from the list of possible reasons.

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

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

    (@johnclause)

    Thank you, @wpbot, the latest on github has been adjusted. Next release will have the fix permanently.

    Thread Starter WPBot

    (@wpbot)

    I’ve tested it by downloading this file https://github.com/qTranslate-Team/qtranslate-x/archive/master.zip and replacing everything on the hosting with its contents but the error is still there.

    Perhaps you didn’t delete the wp_qtrans_front_language cookie when testing the fix and that’s why it’s working on your end?

    Plugin Author John Clause

    (@johnclause)

    Sorry, about this – updated again, new download with the same name should have it. Please, let me know. Thanks.

    Thread Starter WPBot

    (@wpbot)

    Thanks,
    Now the error is gone but three new problems appeared:

    1) I’ve added the language selector to the main menu of the theme and the flag for the current language is not displayed.
    This is the content of the image tag:
    <img src="https://lecheniebg.com/wp-content/plugins/qtranslate-x/flags/">
    When I hover over the menu all the available languages in the dropdown have their flags showing.

    2) When the option “Hide URL language information for default language.” is not enabled (and “Detect the language of the browser and redirect accordingly.” is enabled) the automatically selected language is not added to the URL.
    The URLs are generated by this option “Use Pre-Path Mode (Default, puts /en/ in front of URL). SEO friendly” but I suppose the same thing will happen even if I select “Use Query Mode (?lang=en). Most SEO unfriendly, not recommended.”.

    3) All the links in the menu are stripped of their href attributes (except for the ones that change the language).
    After I change the language the links are working again.

    I guess all the problems are caused by an empty value for the current language variable, but I don’t know the code that well in order to fix it myself.

    Plugin Author John Clause

    (@johnclause)

    #1 I am puzzled. Will not be able to help unless I have a login to your site.

    #2 There has been some recent changes on redirection rules, so it may be fixed on the latest version from GitHub https://github.com/qTranslate-Team/qtranslate-x

    #3 Same as for #1. I have never observed it and cannot reproduce. Current language variable is always defined. It is a default in the beginning and then gets set to the current one, when it is detected, with possible redirect first.

    Maybe your theme is doing something funny. It is hard to tell, unless I see it and can modify files to produce debugging information. Could you try to find a minimal broken configuration, which we could reproduce? One way is to start from theme Twenty Fifteen and q-X the only plugin, then add other stuff one by one to see when it gets broken. If you decide to create a copy of your site for testing you may send the info to me via qtranslateteam at g ma il d com.

    Thanks.

    Thread Starter WPBot

    (@wpbot)

    Does the plugin require any particular PHP extensions or any special server configuration in order to work?
    I’ve made a clean install with vanilla WordPress (with the 2015 theme) and the latest github version of the plugin on a few different machines and the results were mixed.

    On OpenShift (RedHat) and a Ubuntu VM of mine everything works fine, but on 2 different shared hosts all the problems I mentioned above occurred, which leads me to believe something server related causes the problem.

    On all the installs I’ve done the following:
    – change the permalink structure to /%postname%/
    – upload the plugin’s zip file, taken from github
    – change the plugin settings the following way:
    https://anonimg.com/img/90c88f1c0611b0fe03b82d8a143140e8.png

    – create a new menu from Appearance -> Menus, set it as primary and add the home page, the sample page and the language switcher
    – go to the home page for the first time and see whether it works
    – delete the cookies in order to repeat the test (the results are always the same)

    After doing the tests above I deleted all the WP files and DB tables from all the hosts and repeated everything one more time with absolutely the same results.

    On the hosts where the problem occurs the cookie is being set right and after a refresh everything works fine, which means the part of the code that handles the URL rewrites probably doesn’t receive the current language value for some reason.

    Plugin Author Gunu

    (@grafcom)

    @wpbot,

    Is it possible for you to make a copy of your site and to provide access to your configuration?

    My experience is that it is easier for John to help you (us)

    I am puzzled. Will not be able to help unless I have a login to your site.

    He does a great job!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Invalid argument supplied for foreach’ is closed to new replies.