From 6deac5cf4b5e3b9662e618c120229c636a5bfcf4 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 1 Apr 2014 14:51:41 +0100 Subject: [PATCH] Chunk option names in cleanup_sessions() Closes #5225 --- includes/class-wc-session-handler.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/includes/class-wc-session-handler.php b/includes/class-wc-session-handler.php index a2b78cbf715..ec968ca303a 100644 --- a/includes/class-wc-session-handler.php +++ b/includes/class-wc-session-handler.php @@ -181,8 +181,11 @@ class WC_Session_Handler extends WC_Session { } if ( ! empty( $expired_sessions ) ) { - $option_names = implode( "','", $expired_sessions ); - $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name IN ('$option_names')" ); + $expired_sessions_chunked = array_chunk( $expired_sessions, 100 ); + foreach ( $expired_sessions_chunked as $chunk ) { + $option_names = implode( "','", $chunk ); + $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name IN ('$option_names')" ); + } } } }