Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,12 @@ public function setup() {
if ( empty( $stats ) ) {
// Get users plan.
$stats = $this->plugin->components['connect']->api->usage();
if ( ! is_wp_error( $stats ) && ! empty( $stats['media_limits'] ) ) {

if ( is_wp_error( $stats ) ) {
return;
}

if ( ! empty( $stats['media_limits'] ) ) {
Comment on lines +285 to +290
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be a better idea to set some defaults before returning if there's a WP_Error since there are 5 uses of its keys around the plugin, which might cause undefined index errors.

  • See class-media.php at line 1079-1080
  • See class-push-sync.php at line 340-341
  • See class-upload-sync.php at line 120

What do you think @kienstra ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uf, good point

$stats['max_image_size'] = $stats['media_limits']['image_max_size_bytes'];
$stats['max_video_size'] = $stats['media_limits']['video_max_size_bytes'];
set_transient( '_cloudinary_usage', $stats, HOUR_IN_SECONDS );
Expand Down