Make WordPress Core


Ignore:
Timestamp:
09/16/2013 05:42:49 PM (11 years ago)
Author:
nacin
Message:

Always pass integer expirations to cache backends.

props SergeyBiryukov, andreasnrb.
fixes #25308.

File:
1 edited

Legend:

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

    r23328 r25451  
    2222 * @return bool False if cache key and group already exist, true on success
    2323 */
    24 function wp_cache_add($key, $data, $group = '', $expire = 0) {
    25     global $wp_object_cache;
    26 
    27     return $wp_object_cache->add($key, $data, $group, $expire);
     24function wp_cache_add( $key, $data, $group = '', $expire = 0 ) {
     25    global $wp_object_cache;
     26
     27    return $wp_object_cache->add( $key, $data, $group, (int) $expire );
    2828}
    2929
     
    155155 * @return bool False if not exists, true if contents were replaced
    156156 */
    157 function wp_cache_replace($key, $data, $group = '', $expire = 0) {
    158     global $wp_object_cache;
    159 
    160     return $wp_object_cache->replace($key, $data, $group, $expire);
     157function wp_cache_replace( $key, $data, $group = '', $expire = 0 ) {
     158    global $wp_object_cache;
     159
     160    return $wp_object_cache->replace( $key, $data, $group, (int) $expire );
    161161}
    162162
     
    174174 * @return bool False on failure, true on success
    175175 */
    176 function wp_cache_set($key, $data, $group = '', $expire = 0) {
    177     global $wp_object_cache;
    178 
    179     return $wp_object_cache->set($key, $data, $group, $expire);
     176function wp_cache_set( $key, $data, $group = '', $expire = 0 ) {
     177    global $wp_object_cache;
     178
     179    return $wp_object_cache->set( $key, $data, $group, (int) $expire );
    180180}
    181181
     
    321321     * @return bool False if cache key and group already exist, true on success
    322322     */
    323     function add( $key, $data, $group = 'default', $expire = '' ) {
     323    function add( $key, $data, $group = 'default', $expire = 0 ) {
    324324        if ( wp_suspend_cache_addition() )
    325325            return false;
     
    335335            return false;
    336336
    337         return $this->set($key, $data, $group, $expire);
     337        return $this->set( $key, $data, $group, (int) $expire );
    338338    }
    339339
     
    510510     * @return bool False if not exists, true if contents were replaced
    511511     */
    512     function replace( $key, $data, $group = 'default', $expire = '' ) {
     512    function replace( $key, $data, $group = 'default', $expire = 0 ) {
    513513        if ( empty( $group ) )
    514514            $group = 'default';
     
    521521            return false;
    522522
    523         return $this->set( $key, $data, $group, $expire );
     523        return $this->set( $key, $data, $group, (int) $expire );
    524524    }
    525525
     
    560560     * @return bool Always returns true
    561561     */
    562     function set($key, $data, $group = 'default', $expire = '') {
     562    function set( $key, $data, $group = 'default', $expire = 0 ) {
    563563        if ( empty( $group ) )
    564564            $group = 'default';
Note: See TracChangeset for help on using the changeset viewer.