ZF-7742: getOption not working with uppercase $key
Description
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);
}
Comments
Posted by Travis Pew (travisp) on 2009-09-18T05:49:42.000+0000
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.
Posted by Travis Pew (travisp) on 2009-09-18T05:58:00.000+0000
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.
Posted by Benjamin Eberlei (beberlei) on 2009-09-18T06:12:15.000+0000
I agree with Travis that hasOption is missing the strtolower functionality and therefore this bug occurs.
Posted by Matthew Weier O'Phinney (matthew) on 2009-09-18T12:46:00.000+0000
Fixed in trunk and 1.9 release branch
Posted by Michiel Thalen (chielsen) on 2009-10-13T15:24:53.000+0000
How come i don't see it in the repository?
Posted by Dolf Schimmel (Freeaqingme) (freak) on 2009-10-13T15:31:58.000+0000
Look here: http://framework.zend.com/code/viewrep/…
Posted by Michiel Thalen (chielsen) on 2009-10-13T17:57:42.000+0000
Ah, but it is still missing in BootstrapAbstract.php