[TYPO3-core] RFC #14997: Performance: t3lib_db->escapeStrForLike() is using preg_replace, which is not necessary

François Suter fsu-lists at cobweb.ch
Sat Aug 28 17:38:26 CEST 2010


Hi,

> Problem:
> The function t3lib_db->escapeStrForLike() is using preg_replace to escape
> the values '%' and '_' with a '\' for a sql-like-statement.
> preg_replace takes a lot of recources and is not necessary for such a
> simple replacement.
>
> Solution:
> use str_replace instead.

+1 after reading and testing.

Attached v2 to which I have added a test case for 
t3lib_db::escapeStrForLike(). It's a very simple method, but I still 
thought it made sense to add unit testing for it since we were changing it.

Cheers

-- 

Francois Suter
Cobweb Development Sarl - http://www.cobweb.ch
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 14997_v2.diff
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20100828/7e0823d2/attachment.asc>


More information about the TYPO3-team-core mailing list