Skip to content

Commit 6b329b5

Browse files
author
Marco Pereirinha
committed
Make sure that key is set before using it
1 parent 09de44d commit 6b329b5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,11 @@ public function get_usage_stat( $type, $stat = null ) {
543543

544544
if ( 'limit' === $stat && isset( $this->usage[ $type ]['usage'] ) ) {
545545
$value = $this->usage[ $type ]['usage'];
546-
} elseif ( 'used_percent' === $stat && isset( $this->usage[ $type ]['credits_usage'] ) ) {
546+
} elseif (
547+
'used_percent' === $stat
548+
&& isset( $this->usage[ $type ]['credits_usage'] )
549+
&& ! empty( $this->usage['credits']['limit'] )
550+
) {
547551
// Calculate percentage based on credit limit and usage.
548552
$value = round( $this->usage[ $type ]['credits_usage'] / $this->usage['credits']['limit'] * 100, 2 );
549553
}

0 commit comments

Comments
 (0)