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.
This commit is contained in:
Tatu 2019-07-11 23:40:56 +03:00 committed by GitHub
parent 968a0561bb
commit c52e7bd75a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

View File

@ -239,7 +239,7 @@ class WC_Session_Handler extends WC_Session {
* *
* @param int $old_session_key session ID before user logs in. * @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. // Dirty if something changed - prevents saving nothing new.
if ( $this->_dirty && $this->has_session() ) { if ( $this->_dirty && $this->has_session() ) {
global $wpdb; 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() ); wp_cache_set( $this->get_cache_prefix() . $this->_customer_id, $this->_data, WC_SESSION_CACHE_GROUP, $this->_session_expiration - time() );
$this->_dirty = false; $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 ( get_current_user_id() != $old_session_key ) {
if ( $allow_guest_session_removal && get_current_user_id() !== $old_session_key ) {
$this->delete_session( $old_session_key ); $this->delete_session( $old_session_key );
} }
} }