Issues

ZF-10114: Undefined index: HTTP_ACCEPT_LANGUAGE

Issue Type: Bug Created: 2010-07-06T07:05:07.000+0000 Last Updated: 2010-07-07T14:47:08.000+0000 Status: Resolved Fix version(s): - 1.10.7 (28/Jul/10)

Reporter: Eugene Leonovich (rybakit) Assignee: Thomas Weidner (thomas) Tags: - Zend_Locale

Related issues: Attachments:

Description

The line

<pre class="highlight">
$locale = new Zend_Locale();

triggers a PHP notice: Undefined index: HTTP_ACCEPT_LANGUAGE in Zend/Locale.php on line 430 when the script runs from the CLI mode.

Comments

Posted by Andrew Bredow (abredow) on 2010-07-06T10:38:37.000+0000

To expand on this report a little: Zend_Locale::getBrowser() is run every time the class is instantiated, even if a locale is manually passed into the class. In the past, this has not caused any issues because the function just returned an empty array when it wasn't able to detect the locale by "getenv('HTTP_ACCEPT_LANGUAGE')"

However, a recent change (r. 22529) added support for the $_SERVER variable "HTTP_ACCEPT_LANGUAGE" as well. The actual bug is that it assumes this $_SERVER variable is always set, when, in fact, it is not usually set by non-browser clients like cURL unless the developer has set it explicitly. In theory, we just need to make sure the index exists:

<pre class="highlight">
$httplanguages = getenv('HTTP_ACCEPT_LANGUAGE');
if (empty($httplanguages) && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
    $httplanguages = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
}

Posted by Thomas Weidner (thomas) on 2010-07-07T14:47:08.000+0000

Closing as fixed

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts