Support » Plugin: VAT MOSS Returns » Warning Specified locale name is too long

  • I get this error message

    PHP Warning: setlocale(): Specified locale name is too long

    from submissions.php on line 45

    Any idea what the problem is?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author bseddon

    (@bseddon)

    Hi Ben

    The statement on line 45 is:

    setlocale( LC_ALL, $locale );

    The $locale variable is set by this statement:

    $locale = ( isset($_COOKIE[‘locale’]) )
    ? $_COOKIE[‘locale’]
    : (isset( $_SERVER[‘HTTP_ACCEPT_LANGUAGE’] )
    ? $_SERVER[‘HTTP_ACCEPT_LANGUAGE’]
    : ‘en_GB’
    );

    As you can see, it defaults to ‘en_GB’ will first try to obtain the locale value from your cookie (the one set by WordPress) or from the HTTP header value ‘HTTP_ACCEPT_LANGUAGE’ set by your browser.

    My guess is that one of these values exceeds the length of a valid value permitted by the PHP ‘setlocale’ function (which is 255 characters).

    This Stack Overflow post suggests that on some Linux operating systems distributions the locale is not stored as an array but instead a string and that this causes the error.

    The issue is that I have not anticipated this possibility and it seem I should be checking for a string and converting it to an array and passing the array to the ‘setlocale’ function.

    You immediate solution is to edit submissions.php and edit line 45 to read something like:

    setlocale( LC_ALL, ‘en_GB’ );

    In the meantime I will have to figure out how to replicate this scenartio.

    Thanks for your prompt reply!

    What’s the effect of this warning? What will visitors of my website see as a result of this warning, or what might not work due to it?

    Plugin Author bseddon

    (@bseddon)

    The VAT MOSS plugin is an admin only plugin. This code should only be executed by someone using the WordPress backend functions so visitors should not see any effect because for them this line should not execute.

    If you look in the plugin’s main file (vat-moss.php) on line 502 you will see that there are no plugin files included unless a number of conditions are met. One of those conditions is that the WordPress function ‘is_admin’ returns true.

    Even for an admin there should be no effect because the call to ‘setlocale’ fails so the locale remains unchanged.

    Ok, then I’ll await the update of the plugin.

    Thanks again for helping out!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Warning Specified locale name is too long’ is closed to new replies.