r70159 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70158‎ | r70159 | r70160 >
Date:18:37, 29 July 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Mark escapeLike deprecated, since it is broken
Modified paths:
  • /trunk/phase3/includes/db/Database.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/Database.php
@@ -1507,8 +1507,14 @@
15081508 * Escape string for safe LIKE usage.
15091509 * WARNING: you should almost never use this function directly,
15101510 * instead use buildLike() that escapes everything automatically
 1511+ * Deprecated in 1.17, warnings in 1.17, removed in ???
15111512 */
1512 - function escapeLike( $s ) {
 1513+ public function escapeLike( $s ) {
 1514+ wfDeprecated( __METHOD__ );
 1515+ return $this->escapeLikeInternal( $s );
 1516+ }
 1517+
 1518+ protected function escapeLikeInternal( $s ) {
15131519 $s = str_replace( '\\', '\\\\', $s );
15141520 $s = $this->strencode( $s );
15151521 $s = str_replace( array( '%', '_' ), array( '\%', '\_' ), $s );
@@ -1524,7 +1530,7 @@
15251531 * for subpages of 'My page title'.
15261532 * Alternatively: $pattern = array( 'My_page_title/', $dbr->anyString() ); $query .= $dbr->buildLike( $pattern );
15271533 *
1528 - * @ return String: fully built LIKE statement
 1534+ * @return String: fully built LIKE statement
15291535 */
15301536 function buildLike() {
15311537 $params = func_get_args();
@@ -1537,7 +1543,7 @@
15381544 if( $value instanceof LikeMatch ) {
15391545 $s .= $value->toString();
15401546 } else {
1541 - $s .= $this->escapeLike( $value );
 1547+ $s .= $this->escapeLikeInternal( $value );
15421548 }
15431549 }
15441550 return " LIKE '" . $s . "' ";

Status & tagging log