[wp-trac] [WordPress Trac] #4540: wp_cahce_delete don't work with
option autoloaded
WordPress Trac
wp-trac at lists.automattic.com
Tue Jun 26 07:58:57 GMT 2007
#4540: wp_cahce_delete don't work with option autoloaded
---------------------+------------------------------------------------------
Reporter: xorax | Owner: anonymous
Type: defect | Status: new
Priority: normal | Milestone: 2.2.2
Component: General | Version: 2.2
Severity: major | Keywords: cache database options
---------------------+------------------------------------------------------
WP_Object_Cache::delete not remove the cache of an option set with
autoload property.
So wp_cache_delete not work with the options autoloaded.
And so, there is no others way exepts get the 'alloptions' cache, delete
manualy the key of the option, and reset the cache of 'alloptions'.
for example :
{{{
add_option('myoption','myvalue') //imply the autoload param is 'yes'
// the cache of myoption is set in the group 'alloptions'
// simulation of a modification made by an other script :
$wpdb->query("UPDATE $wpdb->options SET option_value = 'mynewvalue' WHERE
option_name = 'myoption'");
//do nothing because myoption is not cached in the group 'options'
wp_cache_delete('myoption','options');
echo get_option('myoption'); // output myvalue and not mynewvalue
//the real cache of myoption is now really deleted
$alloptions = wp_load_alloptions();
if ( isset($alloptions['readthis_posts2get']) ) {
unset($alloptions['readthis_posts2get']);
wp_cache_set('alloptions', $alloptions, 'options');
}
echo get_option('myoption'); //output mynewvalue
}}}
All plugins which used the wp_cache_delete function in WP < 2.2 don't work
now.
--
Ticket URL: <http://trac.wordpress.org/ticket/4540>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list