Skip to content

Commit 1208e26

Browse files
committed
Handle error from prepare_upload.
1 parent ec80adc commit 1208e26

File tree

1 file changed

+7
-2
lines changed
  • cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php

1 file changed

+7
-2
lines changed

cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,15 @@ public function is_synced( $post_id ) {
115115
*
116116
* @param int $post_id The post id to generate a signature for.
117117
*
118-
* @return string
118+
* @return string|bool
119119
*/
120120
public function generate_signature( $post_id ) {
121-
$upload = $this->managers['push']->prepare_upload( $post_id );
121+
$upload = $this->managers['push']->prepare_upload( $post_id );
122+
// Check if has an error (ususally due to file quotas).
123+
if ( is_wp_error( $upload ) ) {
124+
$this->plugin->components['media']->get_post_meta( $post_id, self::META_KEYS['sync_error'], $upload->get_error_message() );
125+
return false;
126+
}
122127
$credentials = $this->plugin->components['connect']->get_credentials();
123128
$upload['cloud_name'] = $credentials['cloud_name'];
124129
$return = array_map(

0 commit comments

Comments
 (0)