Conversation
This could have been a cause of the error on activating the plugin, though I couldn't reproduct it, even with the same PHP and WP versions and theme. But it looks like the code anticipates $stats possibly being an error. In that case, it probably shouldn't be assigned to $this->usage.
|
Request For Review Hi @dugajean, Thanks, Dugi! |
This should still not allow this to be stored.
This can still be set as $this->usage, it should just exit.
|
Sorry, not planning on making any more commits before review 😄 |
|
|
||
| if ( is_wp_error( $stats ) ) { | ||
| return; | ||
| } | ||
|
|
||
| if ( ! empty( $stats['media_limits'] ) ) { |
There was a problem hiding this comment.
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.phpat line 1079-1080 - See
class-push-sync.phpat line 340-341 - See
class-upload-sync.phpat line 120
What do you think @kienstra ?
|
Closing This PR is only a guess at one way the fatal error reported could have happened. Since I can't reproduce the issue, I don't think it makes sense to continue. If there really was a WP_Error from calling the API: ...then there would need to be better UI handling for this. The user would probably need to know that there was some kind of error in order to try again. Simply setting I don't think we can 'fix' something that's not reproducible. |
|
@kienstra , I can reproduce this, we have an environment that fails with this issue. |
|
@const-cloudinary, The stack trace here unfortunately doesn't point to where the |
|
@kienstra, I would start with invalid CLOUDINARY_URL, when "usage" api returns 40x/50x response or something like that. |
|
@kienstra I printed the error. it says: |
|
Hi @const-cloudinary,
Would you be able to paste the rest of the error, especially the line number? |
|
@kienstra It's the same line of the "Cannot use object of type WP_Error as array" . WP_Error contains this message. You can reproduce it by deleting your Cloudinary account, clicking "Cancel my account" on this page: |
|
Hi @const-cloudinary, There didn't seem to be a PHP error after canceling my Cloudinary account: I also tried |
|
@kienstra Can you please provide me some code that I can run on my environment (add some logging entries/write notice message on the screen, etc), so I can understand what is exactly happening in my environment? |
|
Hi @const-cloudinary, Also, this debugging tool has helped me a lot: https://github.com/nette/tracy |
|
@kienstra This bug is reproducible on a shared hosting website I own, it will be problematic to install xdebug there. |
|
Hi @const-cloudinary, Is that a production site? If not, would it be possible to deploy this PR to it, to see if it fixes it? If it's a production site, would it be possible to create a staging 'clone' of it? Thanks! |

There was a fatal error reported on activation:
cloudinary_wordpress/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php
Line 340 in 9b10a98
I couldn't reproduce that, with the same versions as reported in the bug:
PHP 7.4
WP Core 5.3.2
Foodoholic theme
But this PR addresses one possible cause of the error.
It might be possible that
$this->plugin->components['connect']->usageis aWP_Error, causing this fatal error.It looks like the code anticipates
$statsbeing aWP_Error:cloudinary_wordpress/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-connect.php
Line 285 in 9b10a98
If so, it will be assigned to
$this->plugin->components['connect']->usage:cloudinary_wordpress/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-connect.php
Line 291 in 9b10a98
...possibly causing the error the user reported.
Still, I can't reproduce the error that was reported. So it's only a guess that this might fix it.