Issues

ZF-7099: Translate_Adapter: setOptions calls setLocale with wrong parameter

Issue Type: Bug Created: 2009-06-23T07:28:02.000+0000 Last Updated: 2009-08-02T07:02:59.000+0000 Status: Resolved Fix version(s): - 1.9.0 (31/Jul/09)

Reporter: Bert Van Hauwaert (becoded) Assignee: Thomas Weidner (thomas) Tags: - Zend_Translate

Related issues: - ZF-7443

Attachments:

Description

In the setOptions, you search for the 'locale' key and if found you set the variable $locale. Then, if all the options are processed, you will set the locale by calling setLocale with as parameter the latest option you processed. And that isn't always the locale option. So you call the setLocale with an unpredictable value.

<pre class="highlight">
public function setOptions(array $options = array())
    {
        // *****
        $locale = null;
        foreach ($options as $key => $option) {
            if ($key == 'locale') {
                $locale = $option;
            } else if ((isset($this->_options[$key]) and ($this->_options[$key] != $option)) or
                // ****
            }
        }

        if ($locale !== null) {
            $this->setLocale($option);
        }
        //******
    }

Fix is of course use the $locale variable:

<pre class="highlight">
public function setOptions(array $options = array())
    {
        // *****
        $locale = null;
        foreach ($options as $key => $option) {
           //****
        }

        if ($locale !== null) {
            $this->setLocale($locale);
        }
        //******
    }

Comments

Posted by Thomas Weidner (thomas) on 2009-06-27T09:54:30.000+0000

In Incubator since r16320, waiting for code review of r16247

Posted by Thomas Weidner (thomas) on 2009-07-20T12:12:29.000+0000

Accepted and integrated into core with r16883.

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