From 8f0f22c11b33f653e597f42607911da940dd35ac Mon Sep 17 00:00:00 2001 From: Refael Iliaguyev Date: Wed, 23 Jan 2019 14:49:21 +0200 Subject: [PATCH 1/2] Fix ssl check in case shop page does not exists. --- includes/admin/class-wc-admin-notices.php | 2 +- includes/api/v2/class-wc-rest-system-status-v2-controller.php | 2 +- tests/unit-tests/api/system-status.php | 2 +- tests/unit-tests/api/v2/system-status.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/admin/class-wc-admin-notices.php b/includes/admin/class-wc-admin-notices.php index b190b1caede..9828ba32732 100644 --- a/includes/admin/class-wc-admin-notices.php +++ b/includes/admin/class-wc-admin-notices.php @@ -404,7 +404,7 @@ class WC_Admin_Notices { * @since 3.5.1 */ protected static function is_ssl() { - $shop_page = 0 < wc_get_page_id( 'shop' ) ? get_permalink( wc_get_page_id( 'shop' ) ) : get_home_url(); + $shop_page = wc_get_page_permalink( 'shop' ); return ( is_ssl() && 'https' === substr( $shop_page, 0, 5 ) ); } diff --git a/includes/api/v2/class-wc-rest-system-status-v2-controller.php b/includes/api/v2/class-wc-rest-system-status-v2-controller.php index 3a9a71444d5..2ff978ce92a 100644 --- a/includes/api/v2/class-wc-rest-system-status-v2-controller.php +++ b/includes/api/v2/class-wc-rest-system-status-v2-controller.php @@ -989,7 +989,7 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller { * @return array */ public function get_security_info() { - $check_page = 0 < wc_get_page_id( 'shop' ) ? get_permalink( wc_get_page_id( 'shop' ) ) : get_home_url(); + $check_page = wc_get_page_permalink( 'shop' ); return array( 'secure_connection' => 'https' === substr( $check_page, 0, 5 ), 'hide_errors' => ! ( defined( 'WP_DEBUG' ) && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG && WP_DEBUG_DISPLAY ) || 0 === intval( ini_get( 'display_errors' ) ), diff --git a/tests/unit-tests/api/system-status.php b/tests/unit-tests/api/system-status.php index d0940bb02c8..b277c4260e5 100644 --- a/tests/unit-tests/api/system-status.php +++ b/tests/unit-tests/api/system-status.php @@ -183,7 +183,7 @@ class WC_Tests_REST_System_Status extends WC_REST_Unit_Test_Case { $settings = (array) $data['security']; $this->assertEquals( 2, count( $settings ) ); - $this->assertEquals( 'https' === substr( get_permalink( wc_get_page_id( 'shop' ) ), 0, 5 ), $settings['secure_connection'] ); + $this->assertEquals( 'https' === substr( wc_get_page_permalink( 'shop' ), 0, 5 ), $settings['secure_connection'] ); $this->assertEquals( ! ( defined( 'WP_DEBUG' ) && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG && WP_DEBUG_DISPLAY ) || 0 === intval( ini_get( 'display_errors' ) ), $settings['hide_errors'] ); } diff --git a/tests/unit-tests/api/v2/system-status.php b/tests/unit-tests/api/v2/system-status.php index 7416a80af6b..dfcb16c9df6 100644 --- a/tests/unit-tests/api/v2/system-status.php +++ b/tests/unit-tests/api/v2/system-status.php @@ -180,7 +180,7 @@ class WC_Tests_REST_System_Status_V2 extends WC_REST_Unit_Test_Case { $settings = (array) $data['security']; $this->assertEquals( 2, count( $settings ) ); - $this->assertEquals( 'https' === substr( get_permalink( wc_get_page_id( 'shop' ) ), 0, 5 ), $settings['secure_connection'] ); + $this->assertEquals( 'https' === substr( wc_get_page_permalink( 'shop' ), 0, 5 ), $settings['secure_connection'] ); $this->assertEquals( ! ( defined( 'WP_DEBUG' ) && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG && WP_DEBUG_DISPLAY ) || 0 === intval( ini_get( 'display_errors' ) ), $settings['hide_errors'] ); } From 398bbe3754551f1f03b2c1f80d8526f4e66a7c91 Mon Sep 17 00:00:00 2001 From: Refael Iliaguyev Date: Wed, 23 Jan 2019 17:26:17 +0200 Subject: [PATCH 2/2] sniff fixes --- tests/unit-tests/api/system-status.php | 4 ++-- tests/unit-tests/api/v2/system-status.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit-tests/api/system-status.php b/tests/unit-tests/api/system-status.php index b277c4260e5..03c5170ef28 100644 --- a/tests/unit-tests/api/system-status.php +++ b/tests/unit-tests/api/system-status.php @@ -81,7 +81,7 @@ class WC_Tests_REST_System_Status extends WC_REST_Unit_Test_Case { $data = $response->get_data(); $environment = (array) $data['environment']; - // Make sure all expected data is present + // Make sure all expected data is present. $this->assertEquals( 32, count( $environment ) ); // Test some responses to make sure they match up. @@ -468,7 +468,7 @@ class WC_Tests_REST_System_Status extends WC_REST_Unit_Test_Case { * * This function is called by WP_HTTP_TestCase::http_request_listner(). * - * @param array $request Request arguments. + * @param array $request Request arguments. * @param string $url URL of the request. * * @return array|false mocked response or false to let WP perform a regular request. diff --git a/tests/unit-tests/api/v2/system-status.php b/tests/unit-tests/api/v2/system-status.php index dfcb16c9df6..6fe65d3e2df 100644 --- a/tests/unit-tests/api/v2/system-status.php +++ b/tests/unit-tests/api/v2/system-status.php @@ -78,7 +78,7 @@ class WC_Tests_REST_System_Status_V2 extends WC_REST_Unit_Test_Case { $data = $response->get_data(); $environment = (array) $data['environment']; - // Make sure all expected data is present + // Make sure all expected data is present. $this->assertEquals( 32, count( $environment ) ); // Test some responses to make sure they match up.