From a106b324bfb829f50d601c9bc357082af17ec754 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 3 Jul 2018 09:42:59 -0300 Subject: [PATCH 1/2] Ignore specific PHPCS rules instead of all rules --- includes/admin/class-wc-admin-setup-wizard.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/admin/class-wc-admin-setup-wizard.php b/includes/admin/class-wc-admin-setup-wizard.php index 71011b30eb8..e00b6384ec3 100644 --- a/includes/admin/class-wc-admin-setup-wizard.php +++ b/includes/admin/class-wc-admin-setup-wizard.php @@ -509,7 +509,8 @@ class WC_Admin_Setup_Wizard { */ public function wc_setup_store_setup_save() { check_admin_referer( 'wc-setup' ); - // @codingStandardsIgnoreStart + + // phpcs:disable WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.VIP.ValidatedSanitizedInput.InputNotValidated, WordPress.VIP.ValidatedSanitizedInput.MissingUnslash $address = sanitize_text_field( $_POST['store_address'] ); $address_2 = sanitize_text_field( $_POST['store_address_2'] ); $city = sanitize_text_field( $_POST['store_city'] ); @@ -520,7 +521,7 @@ class WC_Admin_Setup_Wizard { $product_type = sanitize_text_field( $_POST['product_type'] ); $sell_in_person = isset( $_POST['sell_in_person'] ) && ( 'yes' === sanitize_text_field( $_POST['sell_in_person'] ) ); $tracking = isset( $_POST['wc_tracker_checkbox'] ) && ( 'yes' === sanitize_text_field( $_POST['wc_tracker_checkbox'] ) ); - // @codingStandardsIgnoreEnd + // phpcs:enable if ( ! $state ) { $state = '*'; From 7cdcae5bffeb9de9e82189835373abb962acfeed Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 3 Jul 2018 09:48:35 -0300 Subject: [PATCH 2/2] Check if $_POST['store_state'] is set before using it Fixes #20684 --- includes/admin/class-wc-admin-setup-wizard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/admin/class-wc-admin-setup-wizard.php b/includes/admin/class-wc-admin-setup-wizard.php index e00b6384ec3..5651081ebae 100644 --- a/includes/admin/class-wc-admin-setup-wizard.php +++ b/includes/admin/class-wc-admin-setup-wizard.php @@ -515,7 +515,7 @@ class WC_Admin_Setup_Wizard { $address_2 = sanitize_text_field( $_POST['store_address_2'] ); $city = sanitize_text_field( $_POST['store_city'] ); $country = sanitize_text_field( $_POST['store_country'] ); - $state = sanitize_text_field( $_POST['store_state'] ); + $state = isset( $_POST['store_state'] ) ? sanitize_text_field( $_POST['store_state'] ) : false; $postcode = sanitize_text_field( $_POST['store_postcode'] ); $currency_code = sanitize_text_field( $_POST['currency_code'] ); $product_type = sanitize_text_field( $_POST['product_type'] );