Zend Framework

Zend_Filter_Inflector cause PHP-error when "nothing to do"

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.5.1
  • Fix Version/s: 1.5.3
  • Component/s: Zend_Filter_Inflector
  • Labels:
    None
  • Fix Version Priority:
    Must Have

Description

Sample:

$bla = new Zend_Filter_Inflector('abc');
$bla->addRules(array(':xys'=>array()));
echo $bla->filter (array('xy'=>'ab'));

This causes a php-error

Notice: /Zend/Zend/Filter/Inflector.php line 451 - Undefined variable: processedParts
Debug Warning: /Zend/Zend/Filter/Inflector.php line 451 - array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array
Notice: /Zend/Zend/Filter/Inflector.php line 451 - Undefined variable: processedParts
Debug Warning: /Zend/Zend/Filter/Inflector.php line 451 - array_values() [<a href='function.array-values'>function.array-values</a>]: The argument should be an array
Debug Warning: /Zend/Zend/Filter/Inflector.php line 451 - preg_replace() [<a href='function.preg-replace'>function.preg-replace</a>]: Empty regular expression
and the return value is null. I my mind it should be abc or at least an empty string.

I had a look at line 451

$inflectedTarget = preg_replace(array_keys($processedParts), array_values($processedParts), $this->_target);

and when I debug it, it seems to me, that the array processedParts doesnt exists, if there are no replacements to do (see first notice "undefined variable"). In the example above there is a rule and there is something in filter(), but they dont match. The most simple example is this

$bla = new Zend_Filter_Inflector('');
var_dump($bla->filter (array()));

The array is never initialized. The file revision is 8226 (trunk).

Activity

Hide
Ralph Schindler added a comment -

Fixed in trunk in r9045.

Lemme know if that fixes it..

-ralph

Show
Ralph Schindler added a comment - Fixed in trunk in r9045. Lemme know if that fixes it.. -ralph
Hide
Ralph Schindler added a comment -

Fixed in 1.5.3 with r10431

Show
Ralph Schindler added a comment - Fixed in 1.5.3 with r10431

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: