From 570bdff71935c3d232e83e004a38fb392f5221f5 Mon Sep 17 00:00:00 2001 From: tynanbe Date: Fri, 22 Dec 2023 23:44:15 -0600 Subject: [PATCH 1/4] Prettier --- src/img-optm.cls.php | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/img-optm.cls.php b/src/img-optm.cls.php index f1659dc30..79c9c0040 100644 --- a/src/img-optm.cls.php +++ b/src/img-optm.cls.php @@ -1031,7 +1031,17 @@ public function pull($manual = false) } else { // handle error $image_url = $server_info['server'] . '/' . $server_info[$row_type]; - self::debug('❌ failed to pull image (' . $row_type . '): ' . (!empty($response->status_code) ? $response->status_code : '') . ' [Local: ' . $row_img->src . '] / [remote: ' . $image_url . ']'); + self::debug( + '❌ failed to pull image (' . + $row_type . + '): ' . + (!empty($response->status_code) ? $response->status_code : '') . + ' [Local: ' . + $row_img->src . + '] / [remote: ' . + $image_url . + ']' + ); return; } } @@ -1161,9 +1171,9 @@ public function pull($manual = false) // Notify IAPI images taken foreach ($server_list as $server => $img_list) { $data = array( - 'action' => self::CLOUD_ACTION_TAKEN, - 'list' => $img_list, - 'server' => $server, + 'action' => self::CLOUD_ACTION_TAKEN, + 'list' => $img_list, + 'server' => $server, ); // TODO: improve this so we do not call once per server, but just once and then filter on the server side Cloud::post(Cloud::SVC_IMG_OPTM, $data); @@ -2052,10 +2062,10 @@ public function handler() self::start_async(); break; - /** - * Batch switch - * @since 1.6.3 - */ + /** + * Batch switch + * @since 1.6.3 + */ case self::TYPE_BATCH_SWITCH_ORI: case self::TYPE_BATCH_SWITCH_OPTM: $this->_batch_switch($type); From c3137afb22b1985a1e680a063328924cd820a2c6 Mon Sep 17 00:00:00 2001 From: tynanbe Date: Sat, 23 Dec 2023 00:29:47 -0600 Subject: [PATCH 2/4] Fix an issue where images won't be pulled with older versions of WordPress --- src/img-optm.cls.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/img-optm.cls.php b/src/img-optm.cls.php index 79c9c0040..ef96f98eb 100644 --- a/src/img-optm.cls.php +++ b/src/img-optm.cls.php @@ -1134,7 +1134,7 @@ public function pull($manual = false) $total_pulled_ori++; }; - if (class_exists('Requests')) { + if (class_exists('\WpOrg\Requests\Requests') && class_exists('\WpOrg\Requests\Autoload')) { // Make sure Requests can load internal classes. Autoload::register(); From 3b21b3821c1714360284f680d3b8e224683ffa7c Mon Sep 17 00:00:00 2001 From: tynanbe Date: Sat, 23 Dec 2023 00:49:54 -0600 Subject: [PATCH 3/4] Add a PHP version constraint --- src/img-optm.cls.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/img-optm.cls.php b/src/img-optm.cls.php index ef96f98eb..c6f6c30bc 100644 --- a/src/img-optm.cls.php +++ b/src/img-optm.cls.php @@ -1134,7 +1134,7 @@ public function pull($manual = false) $total_pulled_ori++; }; - if (class_exists('\WpOrg\Requests\Requests') && class_exists('\WpOrg\Requests\Autoload')) { + if (class_exists('\WpOrg\Requests\Requests') && class_exists('\WpOrg\Requests\Autoload') && !version_compare(PHP_VERSION, '5.6.0', '<')) { // Make sure Requests can load internal classes. Autoload::register(); From 4d95f08f03a308d140750c0cd5671d522a954799 Mon Sep 17 00:00:00 2001 From: tynanbe Date: Tue, 2 Jan 2024 14:15:45 -0600 Subject: [PATCH 4/4] Revise version_compare --- src/img-optm.cls.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/img-optm.cls.php b/src/img-optm.cls.php index c6f6c30bc..f31032e49 100644 --- a/src/img-optm.cls.php +++ b/src/img-optm.cls.php @@ -1134,7 +1134,7 @@ public function pull($manual = false) $total_pulled_ori++; }; - if (class_exists('\WpOrg\Requests\Requests') && class_exists('\WpOrg\Requests\Autoload') && !version_compare(PHP_VERSION, '5.6.0', '<')) { + if (class_exists('\WpOrg\Requests\Requests') && class_exists('\WpOrg\Requests\Autoload') && version_compare(PHP_VERSION, '5.6.0', '>=')) { // Make sure Requests can load internal classes. Autoload::register();