Skip to content

Commit 957b1de

Browse files
author
Marco Pereirinha
committed
Check if object is set
1 parent fabc737 commit 957b1de

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

php/class-delivery.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -523,12 +523,13 @@ public function get_sized( $attachment_id ) {
523523
*/
524524
public static function update_size_relations_public_id( $attachment_id, $public_id ) {
525525
$relationship = Relationship::get_relationship( $attachment_id );
526-
$relationship->public_id = $public_id;
527-
$relationship->public_hash = md5( $public_id );
528-
$relationship->signature = self::get_settings_signature();
529-
$relationship->save();
530526

531-
do_action( 'cloudinary_flush_cache' );
527+
if ( $relationship instanceof Relationship ) {
528+
$relationship->public_id = $public_id;
529+
$relationship->public_hash = md5( $public_id );
530+
$relationship->signature = self::get_settings_signature();
531+
$relationship->save();
532+
}
532533
}
533534

534535
/**
@@ -539,8 +540,11 @@ public static function update_size_relations_public_id( $attachment_id, $public_
539540
*/
540541
public static function update_size_relations_state( $attachment_id, $state ) {
541542
$relationship = Relationship::get_relationship( $attachment_id );
542-
$relationship->post_state = $state;
543-
$relationship->save();
543+
544+
if ( $relationship instanceof Relationship ) {
545+
$relationship->post_state = $state;
546+
$relationship->save();
547+
}
544548

545549
do_action( 'cloudinary_flush_cache' );
546550
}

0 commit comments

Comments
 (0)