Skip to content

Commit 69b3bf4

Browse files
Double-check sync_types emptiness
1 parent 8b6c2e9 commit 69b3bf4

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

php/class-sync.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,13 @@ public function get_signature( $attachment_id, $cached = true ) {
372372
$signature = array();
373373
}
374374

375-
// Remove any old or outdated signature items. against the expected.
376-
$signature = array_intersect_key( $signature, $this->sync_types );
377375
$signatures[ $attachment_id ] = $return;
378-
$return = wp_parse_args( $signature, $this->sync_types );
376+
377+
// Remove any old or outdated signature items. against the expected.
378+
if ( ! empty( $this->sync_types ) ) {
379+
$signature = array_intersect_key( $signature, $this->sync_types );
380+
$return = wp_parse_args( $signature, $this->sync_types );
381+
}
379382
}
380383

381384
/**
@@ -789,9 +792,12 @@ public function sync_base( $attachment_id ) {
789792

790793
$return = array();
791794
$asset_state = $this->get_asset_state( $attachment_id );
792-
foreach ( array_keys( $this->sync_types ) as $type ) {
793-
if ( $asset_state >= $this->sync_base_struct[ $type ]['asset_state'] ) {
794-
$return[ $type ] = $this->generate_type_signature( $type, $attachment_id );
795+
796+
if ( ! empty( $this->sync_types ) ) {
797+
foreach ( array_keys( $this->sync_types ) as $type ) {
798+
if ( $asset_state >= $this->sync_base_struct[ $type ]['asset_state'] ) {
799+
$return[ $type ] = $this->generate_type_signature( $type, $attachment_id );
800+
}
795801
}
796802
}
797803

@@ -844,7 +850,7 @@ public function get_sync_type( $attachment_id, $cached = true ) {
844850
$required_signature = $this->generate_signature( $attachment_id, $cached );
845851
$attachment_signature = $this->get_signature( $attachment_id, $cached );
846852
$attachment_signature = array_intersect_key( $attachment_signature, $required_signature );
847-
if ( is_array( $required_signature ) ) {
853+
if ( is_array( $required_signature ) && ! empty( $this->sync_types ) ) {
848854
$sync_items = array_filter(
849855
$attachment_signature,
850856
function ( $item, $key ) use ( $required_signature ) {
@@ -1108,8 +1114,8 @@ public function maybe_cleanup_errored() {
11081114
wp_redirect(
11091115
add_query_arg(
11101116
array(
1111-
'page' => 'cloudinary',
1112-
'action' => 'cleaned_up',
1117+
'page' => 'cloudinary',
1118+
'action' => 'cleaned_up',
11131119
),
11141120
admin_url( 'admin.php' )
11151121
)

0 commit comments

Comments
 (0)