Remove use of strencode() in buildLike()
authorKevin Israel <pleasestand@live.com>
Tue, 10 Jun 2014 19:51:33 +0000 (15:51 -0400)
committerKevin Israel <pleasestand@live.com>
Tue, 10 Jun 2014 19:51:33 +0000 (15:51 -0400)
This may cause unnecessary backslashes (in the case of a literal
% or _) to end up in the query when the DBMS uses C-style string
escaping; however, the query should still work.

Change-Id: I82681f83dd45fcbecf4bfd672f550cd4dba30949

includes/db/Database.php

index 16e1ef2..7bbcc2f 100644 (file)
@@ -2539,11 +2539,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
         * @return string
         */
        protected function escapeLikeInternal( $s ) {
-               $s = str_replace( '\\', '\\\\', $s );
-               $s = $this->strencode( $s );
-               $s = str_replace( array( '%', '_' ), array( '\%', '\_' ), $s );
-
-               return $s;
+               return addcslashes( $s, '\%_' );
        }
 
        /**
@@ -2579,7 +2575,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
                        }
                }
 
-               return " LIKE '" . $s . "' ";
+               return " LIKE {$this->addQuotes( $s )} ";
        }
 
        /**