From: Kevin Israel Date: Tue, 10 Jun 2014 19:51:33 +0000 (-0400) Subject: Remove use of strencode() in buildLike() X-Git-Tag: 1.31.0-rc.0~15327^2 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=f2f49c0f2182f8fdc1ed60d6cb963c80d0dd840a;p=lhc%2Fweb%2Fwiklou.git Remove use of strencode() in buildLike() 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 --- diff --git a/includes/db/Database.php b/includes/db/Database.php index 16e1ef231d..7bbcc2ffe4 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -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 )} "; } /**