Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions php/class-sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 );
}
}

/**
Expand Down Expand Up @@ -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 );
}
}
}

Expand Down Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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' )
)
Expand Down