Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Notice related to $image_count #573

Closed
4 tasks
remyperona opened this issue Jun 18, 2021 · 1 comment · Fixed by #598
Closed
4 tasks

PHP Notice related to $image_count #573

remyperona opened this issue Jun 18, 2021 · 1 comment · Fixed by #598
Assignees
Milestone

Comments

@remyperona
Copy link
Contributor

Describe the bug
I'm getting this PHP notice on my local installation with Imagify active:

PHP Notice:  Undefined property: stdClass::$image_count in /imagify-plugin/inc/classes/class-imagify-cron-rating.php on line 106
[18-Jun-2021 16:10:30 UTC] PHP Stack trace:
[18-Jun-2021 16:10:30 UTC] PHP   1. {main}() /wp-cron.php:0
[18-Jun-2021 16:10:30 UTC] PHP   2. do_action_ref_array() /wp-cron.php:138
[18-Jun-2021 16:10:30 UTC] PHP   3. WP_Hook->do_action() /wp-includes/plugin.php:551
[18-Jun-2021 16:10:30 UTC] PHP   4. WP_Hook->apply_filters() /wp-includes/class-wp-hook.php:316
[18-Jun-2021 16:10:30 UTC] PHP   5. Imagify_Cron_Rating->do_event() /wp-includes/class-wp-hook.php:292

Not a big issue, but we should avoid it. I'm guessing it's happening because I have the plugin activated but didn't optimize any image, so there is no value for this property. We can guard that with an isset() or something.

Expected behavior
No PHP notice

Backlog Grooming (for WP Media dev team use only)

  • Reproduce the problem
  • Identify the root cause
  • Scope a solution
  • Estimate the effort
@mostafa-hisham
Copy link
Contributor

Reproduced localy: ✖️

Scope for Solution:

Like Rémy said we can add isset to avoid this

if ( ! is_wp_error( $user ) && (int) $user->image_count > 100 ) {

if ( ! is_wp_error( $user ) && isset($user->image_count) && (int) $user->image_count > 100 )

Estimate Effort

[XS]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants