From 4975a5ea211954cf9fe2ddd13f04875c12229b93 Mon Sep 17 00:00:00 2001 From: Jeff Stieler Date: Thu, 7 Oct 2021 16:06:08 -0400 Subject: [PATCH] Avoid reporting success when API key insertion fails. --- plugins/woocommerce/includes/class-wc-ajax.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/woocommerce/includes/class-wc-ajax.php b/plugins/woocommerce/includes/class-wc-ajax.php index 37731c7e106..5ffbbd92eba 100644 --- a/plugins/woocommerce/includes/class-wc-ajax.php +++ b/plugins/woocommerce/includes/class-wc-ajax.php @@ -2126,6 +2126,10 @@ class WC_AJAX { ) ); + if ( 0 === $wpdb->insert_id ) { + throw new Exception( __( 'There was an error generating your API Key.', 'woocommerce' ) ); + } + $key_id = $wpdb->insert_id; $response = $data; $response['consumer_key'] = $consumer_key;