Fixed bug #14997: Performance: t3lib_db->escapeStrForLike() is using preg_replace...
authorFrancois Suter <francois.suter@typo3.org>
Thu, 30 Sep 2010 16:30:19 +0000 (16:30 +0000)
committerFrancois Suter <francois.suter@typo3.org>
Thu, 30 Sep 2010 16:30:19 +0000 (16:30 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@8940 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_db.php
tests/t3lib/t3lib_dbTest.php

index 3b2a627..f05b4e3 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2010-09-30  Francois Suter  <francois@typo3.org>
 
        * Fixed bug #15639: Scheduler: Add missing classes and interface to autoload registry (Thanks to Marcus Krause)
+       * Fixed bug #14997: Performance: t3lib_db->escapeStrForLike() is using preg_replace, which is not necessary (Thanks to Caspar Stuebs and Marcus Krause)
 
 2010-09-30  Steffen Gebert  <steffen@steffen-gebert.de>
 
index d256312..afba221 100644 (file)
@@ -828,7 +828,7 @@ class t3lib_DB {
         * @see quoteStr()
         */
        function escapeStrForLike($str, $table) {
-               return preg_replace('/[_%]/', '\\\$0', $str);
+               return addcslashes($str, '_%');
        }
 
        /**
index 78ba48c..277fe7e 100644 (file)
@@ -135,5 +135,19 @@ class t3lib_dbTest extends tx_phpunit_testcase {
                );
        }
 
+
+       /////////////////////////////////////////////////
+       // Tests concerning escapeStringForLikeComparison
+       /////////////////////////////////////////////////
+
+       /**
+        * @test
+        */
+       public function escapeStringForLikeComparison() {
+               $this->assertEquals(
+                       'foo\_bar\%',
+                       $this->fixture->escapeStrForLike('foo_bar%', 'table')
+               );
+       }
 }
 ?>
\ No newline at end of file