From c52e7bd75ab2a407419be18883cb8465e1638785 Mon Sep 17 00:00:00 2001 From: Tatu <17417945+rekkitatu@users.noreply.github.com> Date: Thu, 11 Jul 2019 23:40:56 +0300 Subject: [PATCH] Dropped redundant persistent cart check code Changing the not equal check between current_user_id and old_session_key to loose type allowed leaving out persistent cart related check. --- includes/class-wc-session-handler.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/includes/class-wc-session-handler.php b/includes/class-wc-session-handler.php index 83a5038e6e6..32e36c38f72 100644 --- a/includes/class-wc-session-handler.php +++ b/includes/class-wc-session-handler.php @@ -239,7 +239,7 @@ class WC_Session_Handler extends WC_Session { * * @param int $old_session_key session ID before user logs in. */ - public function save_data( $old_session_key = 0 ) { + public function save_data( $old_session_key ) { // Dirty if something changed - prevents saving nothing new. if ( $this->_dirty && $this->has_session() ) { global $wpdb; @@ -256,8 +256,7 @@ class WC_Session_Handler extends WC_Session { wp_cache_set( $this->get_cache_prefix() . $this->_customer_id, $this->_data, WC_SESSION_CACHE_GROUP, $this->_session_expiration - time() ); $this->_dirty = false; - $allow_guest_session_removal = apply_filters( 'woocommerce_persistent_cart_enabled', true ) ? true : (bool) get_user_meta( get_current_user_id(), '_woocommerce_load_saved_cart_after_login', true ); - if ( $allow_guest_session_removal && get_current_user_id() !== $old_session_key ) { + if ( get_current_user_id() != $old_session_key ) { $this->delete_session( $old_session_key ); } }