From 8b6c2e9600c74fa8dd140cc153682ec03086d62a Mon Sep 17 00:00:00 2001 From: Gabriel de Tassigny Date: Thu, 21 Aug 2025 14:24:39 +0900 Subject: [PATCH 1/2] Initialize sync_types array This ensures that even if the sync types aren't loaded, there's no fatal errors due to sync_types being null --- php/class-sync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/class-sync.php b/php/class-sync.php index 4ec29f346..fed8cf38d 100644 --- a/php/class-sync.php +++ b/php/class-sync.php @@ -51,7 +51,7 @@ class Sync implements Setup, Assets { * * @var array */ - protected $sync_types; + protected $sync_types = array(); /** * Holds a list of unsynced images to push on end. From 69b3bf407514338e656fa26e95856fcf9561619f Mon Sep 17 00:00:00 2001 From: Gabriel de Tassigny Date: Thu, 28 Aug 2025 08:50:03 +0900 Subject: [PATCH 2/2] Double-check sync_types emptiness --- php/class-sync.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/php/class-sync.php b/php/class-sync.php index fed8cf38d..53173f0aa 100644 --- a/php/class-sync.php +++ b/php/class-sync.php @@ -372,10 +372,13 @@ public function get_signature( $attachment_id, $cached = true ) { $signature = array(); } - // Remove any old or outdated signature items. against the expected. - $signature = array_intersect_key( $signature, $this->sync_types ); $signatures[ $attachment_id ] = $return; - $return = wp_parse_args( $signature, $this->sync_types ); + + // Remove any old or outdated signature items. against the expected. + if ( ! empty( $this->sync_types ) ) { + $signature = array_intersect_key( $signature, $this->sync_types ); + $return = wp_parse_args( $signature, $this->sync_types ); + } } /** @@ -789,9 +792,12 @@ public function sync_base( $attachment_id ) { $return = array(); $asset_state = $this->get_asset_state( $attachment_id ); - foreach ( array_keys( $this->sync_types ) as $type ) { - if ( $asset_state >= $this->sync_base_struct[ $type ]['asset_state'] ) { - $return[ $type ] = $this->generate_type_signature( $type, $attachment_id ); + + if ( ! empty( $this->sync_types ) ) { + foreach ( array_keys( $this->sync_types ) as $type ) { + if ( $asset_state >= $this->sync_base_struct[ $type ]['asset_state'] ) { + $return[ $type ] = $this->generate_type_signature( $type, $attachment_id ); + } } } @@ -844,7 +850,7 @@ public function get_sync_type( $attachment_id, $cached = true ) { $required_signature = $this->generate_signature( $attachment_id, $cached ); $attachment_signature = $this->get_signature( $attachment_id, $cached ); $attachment_signature = array_intersect_key( $attachment_signature, $required_signature ); - if ( is_array( $required_signature ) ) { + if ( is_array( $required_signature ) && ! empty( $this->sync_types ) ) { $sync_items = array_filter( $attachment_signature, function ( $item, $key ) use ( $required_signature ) { @@ -1108,8 +1114,8 @@ public function maybe_cleanup_errored() { wp_redirect( add_query_arg( array( - 'page' => 'cloudinary', - 'action' => 'cleaned_up', + 'page' => 'cloudinary', + 'action' => 'cleaned_up', ), admin_url( 'admin.php' ) )