Issue Details (XML | Word | Printable)

Key: ZF-7742
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Matthew Weier O'Phinney
Reporter: Michiel Thalen
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Google issue summary
Zend Framework

getOption not working with uppercase $key

Created: 31/Aug/09 03:34 PM   Updated: 13/Oct/09 05:57 PM   Resolved: 18/Sep/09 12:46 PM
Component/s: Zend_Application
Affects Version/s: 1.9.2
Fix Version/s: 1.9.3

Time Tracking:
Original Estimate: Not Specified
Remaining Estimate: 0 minutes
Remaining Estimate - 0 minutes
Time Spent: 1 minute
Time Spent - 1 minute

File Attachments: 1. Text File 7742.patch (2 kB)

Issue Links:
Related


 Description  « Hide
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:

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:

public function hasOption($key)
    {
        return in_array(strtolower($key), $this->_optionKeys);
    }


Travis Pew added a comment - 18/Sep/09 05:49 AM

This is related to ZF-6679

Basically, the intention was that getOptions would preserve the original case, but lookups (getOption and hasOption) would work if you supply a lowercase key or a case sensitive key.

But, passing a key with a capital letter does not work.


Travis Pew added a comment - 18/Sep/09 05:58 AM

Unit tests and fix to allow passing keys with capital letters to getOption and hasOption. getOption didn't need a fix since it was already coded to be case-insensitive, but relied on hasOption which was case-sensitive.


Benjamin Eberlei added a comment - 18/Sep/09 06:12 AM

I agree with Travis that hasOption is missing the strtolower functionality and therefore this bug occurs.


Matthew Weier O'Phinney added a comment - 18/Sep/09 12:46 PM

Fixed in trunk and 1.9 release branch


Michiel Thalen added a comment - 13/Oct/09 03:24 PM

How come i don't see it in the repository?



Michiel Thalen added a comment - 13/Oct/09 05:57 PM

Ah, but it is still missing in BootstrapAbstract.php