diff --git a/includes/oauth/class-google-login.php b/includes/oauth/class-google-login.php index f3267108aa..dd12031acb 100644 --- a/includes/oauth/class-google-login.php +++ b/includes/oauth/class-google-login.php @@ -122,7 +122,8 @@ public static function oauth_callback() { } if ( ! wp_verify_nonce( sanitize_text_field( $_GET[ self::AUTH_CALLBACK ] ), self::AUTH_CALLBACK ) ) { - self::handle_error( __( 'Nonce verification failed.', 'newspack-plugin' ) ); + /* translators: %s is a unique user id */ + self::handle_error( sprintf( __( 'Nonce verification failed for id: %s', 'newspack-plugin' ), OAuth::get_unique_id() ) ); wp_die( esc_html__( 'Invalid nonce.', 'newspack-plugin' ) ); return; } diff --git a/includes/oauth/class-oauth.php b/includes/oauth/class-oauth.php index 1d1f4afa45..6fc37c8757 100644 --- a/includes/oauth/class-oauth.php +++ b/includes/oauth/class-oauth.php @@ -36,6 +36,12 @@ public static function get_unique_id() { if ( ! $id ) { $id = session_id(); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.session_session_id } + if ( ! $id ) { + if ( session_status() !== PHP_SESSION_ACTIVE ) { // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.session_session_status + session_start(); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.session_session_start + } + $id = session_id(); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.session_session_id + } return $id; }