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

Error in workouts-integration.php affected admin on php 8 or later #17961

Open
9 tasks done
ArrayIterator opened this issue Jan 15, 2022 · 4 comments
Open
9 tasks done
Labels
severity: minor Yoast: Management Issues about options and management of the plugin

Comments

@ArrayIterator
Copy link

  • I've read and understood the contribution guidelines.
  • I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened.

Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in [ROOT]/wp-content/plugins/wordpress-seo/src/integrations/admin/workouts-integration.php:486 Stack trace: #0 [ROOT]/wp-content/plugins/wordpress-seo/src/integrations/admin/workouts-integration.php(486): 

return count( $workouts_option['configuration']['finishedSteps'] ) === 5;

$workouts_option = $this->options_helper->get( 'workouts_data', [] );
return count( $workouts_option['configuration']['finishedSteps'] ) === 5;

This maybe cause no validation has been made on count method.
when $workouts_option is empty array or does not contain key (not is array) on configuration or finishedSteps it will thrown an error, cause php 8 or later is strictest than earlier.

Please describe what you expected to happen and why.

After update on latest version, admin area (dashboard) suddenly showing that wordpress has error.
I also used plugins directory as symlink of subdomain.

How can we reproduce this behavior?

  1. (Probably) Update Yoast Plugin that make workouts_data[configuration][finishedSteps ] has been changed.
  2. Try to emptying / change options_helper of workouts_data that does not contains key finishedSteps

Technical info

  • If relevant, which editor is affected (or editors):
  • Classic Editor
  • Gutenberg
  • Classic Editor plugin
  • Sitewide Admin
  • Which browser is affected (or browsers):
  • Chrome
  • Firefox
  • Safari

Used versions

  • Php Version: 8.0.5
  • WordPress version: 5.8.3 (id-ID)
  • Yoast SEO version: 17.9
  • Gutenberg plugin version:
  • Classic Editor plugin version:
  • Relevant plugins in case of a bug:
  • Tested with theme: twentytenty, twentytwentyone, all

IMAGE

after plugin update (suddenly checked that options workouts_data[configuration] has empty)

image

@Djennez
Copy link
Member

Djennez commented Jan 17, 2022

I can see it happening, but I think this is a rare case. Looking at the code, that count should always return something, even if the data does not exist in the database. That option is set to a default empty array, so it should always return 0 if no data is in the database.

Since the options framework is using caching, it might be that the value did not exist before the update and therefore a cached options array was used without that value. But that would mean that you updated from a version prior to 17.7 to 17.9, since this code was introduced in 17.7, and your caching is more robust. Could that be the case?

@Djennez Djennez added severity: minor Yoast: Management Issues about options and management of the plugin labels Jan 17, 2022
@ArrayIterator
Copy link
Author

yep .. even on minor case and the admin dashbord thrown error, the user on admin can not resolve the issues untill deactivate plugins manually via server or fixing the code.

@jameelmoses
Copy link

Just experienced this same issue and had to downgrade to PHP 7.4

@OneMohrTime
Copy link

OneMohrTime commented Mar 17, 2022

I just had this happen, had to rollback to 7.4 as well.

Edit: Unsure if this is helpful, but, I was able to roll SEO back to 17.6, then upgrade PHP to 8.0 without any issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity: minor Yoast: Management Issues about options and management of the plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants