Issues

ZF-10199: CLONE -getOption not working with uppercase $key

Issue Type: Bug Created: 2010-07-21T14:02:40.000+0000 Last Updated: 2010-10-26T02:16:59.000+0000 Status: Resolved Fix version(s): - 1.10.7 (28/Jul/10)

Reporter: Sandi Verdev (sverde1) Assignee: Ramon Henrique Ornelas (ramon) Tags: - Zend_Application

Related issues: - ZF-9075

Attachments: - 7742.patch

Description

<pre class="highlight">
    public function getOption($key)
    {
        if ($this->hasOption($key)) {
            $options = $this->getOptions();
            $options = array_change_key_case($options, CASE_LOWER);
            return $options[strtolower($key)];
        }
        return null;
    }

hasOption() is case sensitve so it never gets to the strtolowerpart

2 possible solutions:

make getOption() like this:

<pre class="highlight">
    public function getOption($key)
    {
       $key = strtolower($key);
        if ($this->hasOption($key)) {
            $options = $this->getOptions();
            $options = array_change_key_case($options, CASE_LOWER);
            return $options[$key];
        }
        return null;
    }

Or make hasOption, since all options get loaded into lowercase keys anyway:

<pre class="highlight">
    public function hasOption($key)
    {
        return in_array(strtolower($key), $this->_optionKeys);
    }

Comments

Posted by Sandi Verdev (sverde1) on 2010-07-21T14:05:30.000+0000

How can this be resolved if it is still not fixed in 1.10.6? :S Please take a look into this and write a test or something so it won't appear again :)

Posted by Ramon Henrique Ornelas (ramon) on 2010-07-24T17:42:54.000+0000

Fixed in trunk r22664, applied r22665 to 1.10 branch.

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