Merge pull request #6909 from webaware/cleanup-sessions-cached

Delete cached sessions when clearing expired sessions
This commit is contained in:
Mike Jolley 2014-12-08 07:47:10 +00:00
commit 2874ef9947
1 changed files with 8 additions and 0 deletions

View File

@ -238,6 +238,14 @@ class WC_Session_Handler extends WC_Session {
if ( ! empty( $expired_sessions ) ) {
$expired_sessions_chunked = array_chunk( $expired_sessions, 100 );
foreach ( $expired_sessions_chunked as $chunk ) {
if ( wp_using_ext_object_cache() ) {
// delete from object cache first, to avoid cached but deleted options
foreach ( $chunk as $option ) {
wp_cache_delete( $option, 'options' );
}
}
// delete from options table
$option_names = implode( "','", $chunk );
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name IN ('$option_names')" );
}