Yoast / wordpress-seo

Yoast SEO for WordPress
https://yoast.com/wordpress/plugins/seo/
Other
1.78k stars 893 forks source link

Assigning wpseo capabilities to the Shop Manager role causes a fatal error #20201

Open ogodoabiola opened 1 year ago

ogodoabiola commented 1 year ago

Please give us a description of what happened

When you assign wp_seo capabilities to the Shop Manager role, it triggers a fatal error

To Reproduce

Step-by-step reproduction instructions

  1. Install WooCommerce and the User Role Editor(URE) plugin
  2. Using URE, assign (wpseo_bulk_edit, wpseo_edit_advanced_metadata, wpseo_manage_options) capabilities to the Shop Manager role
  3. While logged in as shop manager, go to Yoast SEO >> General, and you'll get the error below: Got error 'PHP message: PHP Fatal error: Uncaught TypeError: property_exists(): Argument #1 ($object_or_class) must be of type object|string, bool given in /var/www/html/hljl_prod/wp-content/plugins/woocommerce/includes/wc-user-functions.php:568\nStack trace:\n#0 /var/www/html/hljl_prod/wp-content/plugins/woocommerce/includes/wc-user-functions.php(568): property_exists()\n#1 /var/www/html/hljl_prod/wp-includes/class-wp-hook.php(308): wc_modify_map_meta_cap()\n#2 /var/www/html/hljl_prod/wp-includes/plugin.php(205): WP_Hook->apply_filters()\n#3 /var/www/html/hljl_prod/wp-includes/capabilities.php(838): apply_filters()\n#4 /var/www/html/hljl_prod/wp-includes/class-wp-user.php(778): map_meta_cap()\n#5 /var/www/html/hljl_prod/wp-includes/capabilities.php(981): WP_User->has_cap()\n#6 /var/www/html/hljl_prod/wp-includes/capabilities.php(873): user_can()\n#7 /var/www/html/hljl_prod/wp-content/plugins/wordpress-seo/src/integrations/admin/first-time-configuration-integration.php(551): current_user_can()\n#8 /var/www/html/hljl_...', referer: https://www.levyjalista.fi/wp-admin/

Expected results

  1. Everything should work normally as if you had admin SEO rights

Actual results

  1. A fatal error is triggered on PHP 8++
  2. The page still renders, but the error appears atop. See screenshots below:

Screenshots, screen recording, code snippet

image image

Technical info

Used versions

ogodoabiola commented 1 year ago

Please inform the customer of conversation # 1011654 when this conversation has been closed.

thinkjarvisdesignandmarketing commented 1 year ago

Thank you for adding this to Github (I reported the issue on the forum).

You managed to get further than I did In my experience of this bug the page doesnt render at all you just get the "There has been a critical error with your wordpress site" Error.

Turning on debug reveals the same set of php errors you are seeing though.

I hope you manage to find a solution. Thanks again

maybellyne commented 1 year ago

+1 https://wordpress.org/support/topic/bug-cannot-assign-seo-permissions-to-shop-manager/

detolah commented 2 months ago

Please inform the customer of conversation # 1170751 when this conversation has been closed.