[TYPO3-core] RFC #13934: Side-effect of substr in t3lib_cs

Xavier Perseguers typo3 at perseguers.ch
Mon May 24 11:58:06 CEST 2010


Hi,

This is an SVN patch request in behalf of Rens Admiraal.

Type: Bugfix (nobrainer)

Bugtracker reference:
http://bugs.typo3.org/view.php?id=13934

Branches: all

Problem:
t3lib_cs::substr is said to return a string but when providing an empty string to be cut off:

$csConvObj = t3lib_div::makeInstance('t3lib_cs');
$foo = $csConvObj->substr('utf-8', '', 0, 10);
var_dump($foo);

$foo is the boolean FALSE instead of being an empty string. This is caused by underlying substr() PHP method.

Problem is that it seems that it prevents empty fields to be properly saved when using DBAL and a PostgreSQL (according to the bugtracker).

Solution:
Test if an empty string is provided and thus return an empty string without performing any additional substr/character set conversion operation.

I find it a real nobrainer but as the method is said to have been unit-tested by Kasper, I wanted to have a review here. Thanks.

-- 
Xavier Perseguers
http://xavier.perseguers.ch/en
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 13934.diff
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20100524/beffa969/attachment.txt>


More information about the TYPO3-team-core mailing list