Make WordPress Core


Ignore:
Timestamp:
06/10/2014 12:29:35 AM (11 years ago)
Author:
wonderboymusic
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r28708 r28711  
    31013101
    31023102/**
    3103  * Escapes text for SQL LIKE special characters % and _.
    3104  *
    3105  * @since 2.5.0
    3106  *
    3107  * @param string $text The text to be escaped.
    3108  * @return string text, safe for inclusion in LIKE query.
    3109  */
    3110 function like_escape($text) {
    3111     return str_replace(array("%", "_"), array("\\%", "\\_"), $text);
    3112 }
    3113 
    3114 /**
    31153103 * Convert full URL paths to absolute paths.
    31163104 *
Note: See TracChangeset for help on using the changeset viewer.