Skip to content

Commit fec01e2

Browse files
authored
Merge pull request #79 from wp-cli/use-utils-esc_like
Use Utils\esc_like() and remove internal esc_like().
2 parents e4fbd42 + df558e4 commit fec01e2

File tree

2 files changed

+7
-27
lines changed

2 files changed

+7
-27
lines changed

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
"minimum-stability": "dev",
1818
"prefer-stable": true,
1919
"autoload": {
20-
"psr-4": {"": "src/"},
20+
"psr-4": {
21+
"": "src/"
22+
},
2123
"files": [ "db-command.php" ]
2224
},
23-
"require": {
24-
"wp-cli/wp-cli": "*"
25-
},
25+
"require": {},
2626
"require-dev": {
27-
"behat/behat": "~2.5"
27+
"behat/behat": "~2.5",
28+
"wp-cli/wp-cli": "^1.5"
2829
},
2930
"extra": {
3031
"branch-alias": {

src/DB_Command.php

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ public function search( $args, $assoc_args ) {
950950
}
951951
} else {
952952
$search_regex = '#' . preg_quote( $search, '#' ) . '#i';
953-
$esc_like_search = '%' . self::esc_like( $search ) . '%';
953+
$esc_like_search = '%' . Utils\esc_like( $search ) . '%';
954954
}
955955

956956
$encoding = null;
@@ -1179,27 +1179,6 @@ private static function is_text_col( $type ) {
11791179
return false;
11801180
}
11811181

1182-
/**
1183-
* Escapes a MySQL string for inclusion in a `LIKE` clause. BC wrapper around different WP versions of this.
1184-
*
1185-
* @param string $old String to escape.
1186-
* @param string Escaped string.
1187-
*/
1188-
private static function esc_like( $old ) {
1189-
global $wpdb;
1190-
1191-
// Remove notices in 4.0 and support backwards compatibility
1192-
if ( method_exists( $wpdb, 'esc_like' ) ) {
1193-
// 4.0
1194-
$old = $wpdb->esc_like( $old );
1195-
} else {
1196-
// 3.9 or less
1197-
$old = like_escape( esc_sql( $old ) );
1198-
}
1199-
1200-
return $old;
1201-
}
1202-
12031182
/**
12041183
* Escapes (backticks) MySQL identifiers (aka schema object names) - i.e. column names, table names, and database/index/alias/view etc names.
12051184
* See https://dev.mysql.com/doc/refman/5.5/en/identifiers.html

0 commit comments

Comments
 (0)