WordPress.org

Make WordPress Core

Ticket #11630: 11630.2.patch

File 11630.2.patch, 1.5 KB (added by hakre, 8 years ago)

Alternate patch allowing 0 to better reflect the API. various comment and naming-consistency improvements.

  • wp-includes/cache.php

     
    7676}
    7777
    7878/**
    79  * Retrieves the cache contents from the cache by ID and flag.
     79 * Retrieves the cache contents from the cache by ID and group.
    8080 *
    81  * @since 2.0.0
    82  * @uses $wp_object_cache Object Cache Class
    83  * @see WP_Object_Cache::get()
     81 * @since  2.0.0
     82 * @global WP_Object_Cache
     83 * @uses   $wp_object_cache Object Cache Class
     84 * @see    WP_Object_Cache::get()
    8485 *
    85  * @param int|string $id What the contents in the cache are called
    86  * @param string $flag Where the cache contents are grouped
    87  * @return bool|mixed False on failure to retrieve contents or the cache
    88  *              contents on success
     86 * @param  int|string $id    id/key to identify the cache entry
     87 * @param  string     $group (optional) cache group, defaults to 'default' group
     88 * @return bool|mixed FALSE on failure to retrieve contents or the actual
     89 *                    cache contents on success (which can be FALSE as well)
    8990 */
    90 function wp_cache_get($id, $flag = '') {
     91function wp_cache_get( $id, $group = 'default' ) {
     92        /* @var $wp_object_cache WP_Object_Cache */
    9193        global $wp_object_cache;
    9294
    93         return $wp_object_cache->get($id, $flag);
     95        // sanitize input
     96        if ( !is_string($id) || !is_int($id) ) 
     97                return false;
     98               
     99        if ( !is_string($group) )
     100                return false;
     101
     102        return $wp_object_cache->get($id, $group);
    94103}
    95104
    96105/**