wordpress-seo icon indicating copy to clipboard operation
wordpress-seo copied to clipboard

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

Open ogodoabiola opened this issue 2 years ago • 4 comments

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

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

  • If relevant, which editor is affected (or editors):
  • [x] Block Editor
  • [x] Gutenberg Editor
  • [x] Elementor Editor
  • [x] Classic Editor
  • [ ] Other:
  • Which browser is affected (or browsers):
  • [x] Chrome
  • [x] Firefox
  • [x] Safari
  • [ ] Other:

Used versions

  • Device you are using: HP Elitebook
  • Operating system: Windows 11
  • PHP version: 7.4 or 8.xx +
  • WordPress version: 6.2
  • WordPress Theme: Twenty Twenty two
  • Yoast SEO version: 20.5
  • Gutenberg plugin version:
  • Elementor plugin version:
  • Classic Editor plugin version:
  • Relevant plugins in case of a bug: WooCommerce 7.6.0 and User Role Editor 4.63.3

ogodoabiola avatar Apr 25 '23 07:04 ogodoabiola

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

ogodoabiola avatar Apr 25 '23 07:04 ogodoabiola

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

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

maybellyne avatar May 08 '23 11:05 maybellyne

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

detolah avatar Sep 11 '24 09:09 detolah