[TYPO3-core] RFC #9779: t3lib_div::trimExplode limit parameter leads to wrong result with non-empty requirement

Ingo Renner ingo at typo3.org
Mon Mar 2 12:37:15 CET 2009


Hi *,

This is a SVN patch request

Type: bugfix

Branches: trunk

BT reference: http://bugs.typo3.org/view.php?id=9779

Problem:
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 
before


Solution:
* Adjust the unit tests for t3lib_div::trimExplode() to the expected 
behavior
* the tests should then fail with the current implementation
* apply the patch
* the tests should then succeed and adhere to the behavior described in 
the method's documentation


all the best
Ingo


-- 
Ingo Renner
TYPO3 Core Developer, Release Manager TYPO3 4.2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 9779.diff
Type: text/x-diff
Size: 695 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20090302/8925dacb/attachment.diff 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 9779_tests.diff
Type: text/x-diff
Size: 1394 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20090302/8925dacb/attachment-0001.diff 


More information about the TYPO3-team-core mailing list