From 87695bddb7b63b32f40ffa362591df6087fb0ee9 Mon Sep 17 00:00:00 2001 From: Jon Brown Date: Mon, 5 Mar 2018 10:30:05 -1000 Subject: [PATCH 1/3] Checking class exists is insufficient allows for a fatal error when Jetpack class is defined without specific method There are a half dozen stripped-down versions of JetPack's modules like JP Custom CSS, JP Widget visibility, etc... these all define a class called "Jetpack" but don't define all the methods. --- includes/class-wc-regenerate-images.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-regenerate-images.php b/includes/class-wc-regenerate-images.php index 407e42833f0..766f91898e6 100644 --- a/includes/class-wc-regenerate-images.php +++ b/includes/class-wc-regenerate-images.php @@ -43,7 +43,7 @@ class WC_Regenerate_Images { } // Not required when Jetpack Photon is in use. - if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) { + if ( method_exists('Jetpack', 'is_module_active') && Jetpack::is_module_active( 'photon' ) ) { return; } From e6f2126b119f9983298d39ae5566d2cfa45eeeb5 Mon Sep 17 00:00:00 2001 From: Jon Brown Date: Mon, 5 Mar 2018 11:08:40 -1000 Subject: [PATCH 2/3] opps... not DRY Photon check should probably should be abstracted, but this works for now --- includes/class-wc-regenerate-images.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-regenerate-images.php b/includes/class-wc-regenerate-images.php index 766f91898e6..5ea380a7cbe 100644 --- a/includes/class-wc-regenerate-images.php +++ b/includes/class-wc-regenerate-images.php @@ -84,7 +84,7 @@ class WC_Regenerate_Images { // See if the image size has changed from our settings. if ( ! self::image_size_matches_settings( $data, $size ) ) { // If Photon is running we can just return false and let Jetpack handle regeneration. - if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) { + if ( method_exists('Jetpack', 'is_module_active') && Jetpack::is_module_active( 'photon' ) ) { return false; } else { // If we get here, Jetpack is not running and we don't have the correct image sized stored. Try to return closest match. From cc08eff0b0a0050bf3fe4e7c7228d01790042395 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Wed, 7 Mar 2018 11:18:42 +0000 Subject: [PATCH 3/3] Standards --- includes/class-wc-regenerate-images.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/class-wc-regenerate-images.php b/includes/class-wc-regenerate-images.php index 5ea380a7cbe..9b5186ccfc7 100644 --- a/includes/class-wc-regenerate-images.php +++ b/includes/class-wc-regenerate-images.php @@ -43,7 +43,7 @@ class WC_Regenerate_Images { } // Not required when Jetpack Photon is in use. - if ( method_exists('Jetpack', 'is_module_active') && Jetpack::is_module_active( 'photon' ) ) { + if ( method_exists( 'Jetpack', 'is_module_active' ) && Jetpack::is_module_active( 'photon' ) ) { return; } @@ -84,7 +84,7 @@ class WC_Regenerate_Images { // See if the image size has changed from our settings. if ( ! self::image_size_matches_settings( $data, $size ) ) { // If Photon is running we can just return false and let Jetpack handle regeneration. - if ( method_exists('Jetpack', 'is_module_active') && Jetpack::is_module_active( 'photon' ) ) { + if ( method_exists( 'Jetpack', 'is_module_active' ) && Jetpack::is_module_active( 'photon' ) ) { return false; } else { // If we get here, Jetpack is not running and we don't have the correct image sized stored. Try to return closest match.