From 8f99b2a7ed6f04510fdf93d42ec26554bc47ce8f Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Mon, 23 Dec 2019 21:02:53 -0500 Subject: [PATCH] syntax error fixed. --- includes/utils/class-ql-session-handler.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/includes/utils/class-ql-session-handler.php b/includes/utils/class-ql-session-handler.php index c0f87613..54070ccb 100644 --- a/includes/utils/class-ql-session-handler.php +++ b/includes/utils/class-ql-session-handler.php @@ -88,9 +88,6 @@ class QL_Session_Handler extends \WC_Session_Handler { add_action( 'woocommerce_set_cart_cookies', array( $this, 'set_customer_session_token' ), 10 ); add_action( 'shutdown', array( $this, 'save_data' ), 20 ); - // Define Transaction ID. - define( 'WOOGRAPHQL_SESSION_TRANSACTION_ID', \uniqid() ); - add_action( 'graphql_before_resolve_field', array( $this, 'check_session_lock' ), 10, 8 ); add_action( 'graphql_execute', array( $this, 'pop_transaction_queue' ) ); // add_action( @@ -140,6 +137,11 @@ class QL_Session_Handler extends \WC_Session_Handler { return; } + // Define Transaction ID. + if ( ! defined( WOOGRAPHQL_SESSION_TRANSACTION_ID ) ) { + define( 'WOOGRAPHQL_SESSION_TRANSACTION_ID', \uniqid() ); + } + // Update transaction queue. $this->update_transaction_queue(); @@ -190,11 +192,15 @@ class QL_Session_Handler extends \WC_Session_Handler { * @throws UserError If Transaction ID is not on the top of the queue. */ public function pop_transaction_queue() { + if ( ! defined( 'WOOGRAPHQL_SESSION_TRANSACTION_ID' ) ) { + return; + } + $transactions = wp_cache_get( $this->_customer_id, 'woo_session_transactions_queue' ); // Throw if transaction ID not on top. if ( WOOGRAPHQL_SESSION_TRANSACTION_ID !== $transactions[0] ) { - throw new UserError( 'Woo session transaction executed out of order', 'wp-graphql-woocommerce' ); + throw new UserError( __( 'Woo session transaction executed out of order', 'wp-graphql-woocommerce' ) ); } else { // Remove Transaction ID and update queue.