Bug #19601
closedt3lib_div::trimExplode limit parameter leads to wrong result with non-empty requirement
0%
Description
First, look at the function that was extended during TYPO3 4.3 development:
trimExplode($delim, $string, $onlyNonEmptyValues = false, $limit = 0)
Imagine a list like this:
$string = 'aa,,bb';
1) trimExplode(',', $string, false, 2) returns array('aa', ',bb') -> fine
2) trimExplode(',', $string, true, 2) returns array('aa', ',bb') -> false since it should be array('aa', 'bb') and the empty value removed <b>before</b>
(issue imported from #M9779)
Files
Updated by Franz Holzinger almost 16 years ago
I also think that a final reset($array) is missing. This had been done in former versions of TYPO3.
Updated by Ingo Renner almost 16 years ago
The behavior of the $limit parameter is correct according to http://php.net/explode
Updated by Ingo Renner almost 16 years ago
... currently the either the documentation for the $limit parameter is wrong or the implementation for the documented behavior
Updated by Ingo Renner almost 16 years ago
the documentation of the parameter however fits the one of http://www.php.net/manual/en/function.array-slice.php
Updated by Ingo Renner over 15 years ago
the attached patch makes the method behave like advertised in the description
Updated by Oliver Hader about 15 years ago
Reopened... the behaviour will be reworked...
Updated by Oliver Hader about 15 years ago
Added a follow-up patch, that come back to the behaviour of the original explode() function in PHP:
Example:
t3lib_div::trimExplode(",", " a , b , c , d, ,e, f , , ", true, 3); will be array("a", "b", "c,d,e,f")
Updated by Oliver Hader about 15 years ago
Using the RegExp "t3lib_div::trimExplode\([^)]+,\s*[2-9]\s*\)" to find parts where this is used in the core I got the following:
t3lib_extMgm:544: $itemDetails = t3lib_div::trimExplode(';', $itemPart, false, 5);
Updated by Oliver Hader about 15 years ago
Committed the follow-up patch to SVN Trunk (rev. 6180)