Issue Bug Closed

#65123GeneralUtility::rmFromList() regression bug

Gregor Favre 02/17/15, 13:12 updated 10/02/18, 11:46

Description

Using TYPO3 6.2.9.

GeneralUtility::rmFromList() suffers from a regression bug. It is not handling the removal of list items properly, if the list contains the item several times. The behaviour of str_replace() is documented in the PHP documentation (see http://php.net/manual/en/function.str-replace.php section “Caution: Replacement order gotcha”.

The old implementation not using str_replace() but looping through the elements was working as expected.

*Reproducible code:*
$param1 = “A”;
$param2 = “A,A,A,A,A,A,A,A”;
$result = GeneralUtility::rmFromList($param1, $param2);

*Expected result:*
$result should be empty

*Returned result:*
$result is “A,A,A,A”

Reviews 3