LIKE escape sanity:

* Deprecate `like_escape()`
* Add a method to `$wpdb`, `->esc_like()`, and add unit tests

`$wpdb::esc_like()` is not used yet. As such, many unit tests will throw `Unexpected deprecated notice for like_escape`. Subsequent commits will alleviate this.

Props miqrogroove.
See #10041.


git-svn-id: https://develop.svn.wordpress.org/trunk@28711 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2014-06-10 00:29:35 +00:00
parent 12ea157f2c
commit 2a551f57a4
5 changed files with 138 additions and 12 deletions

View File

@@ -3099,18 +3099,6 @@ function tag_escape($tag_name) {
return apply_filters( 'tag_escape', $safe_tag, $tag_name );
}
/**
* Escapes text for SQL LIKE special characters % and _.
*
* @since 2.5.0
*
* @param string $text The text to be escaped.
* @return string text, safe for inclusion in LIKE query.
*/
function like_escape($text) {
return str_replace(array("%", "_"), array("\\%", "\\_"), $text);
}
/**
* Convert full URL paths to absolute paths.
*