Yoast / wordpress-seo

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

WooCommerce compatibility, notice when Shop page option is empty #9335

Closed olegGist closed 6 years ago

olegGist commented 6 years ago

Please give us a description of what happened.

I've meet a small issue related to plugin compatibility with WooCommerce. If system does not have shop page configured in WooCommerce > Settings > Products > General section ( when this option is empty ) following notice take a place:

Notice: Undefined property: WP_Post_Type::$ID in /www/wp-content/plugins/wordpress-seo/frontend/class-frontend.php on line 256

Please describe what you expected to happen and why.

Plugin should not try to get ID of shop page if it has not been added in WooCommerce settings section.

How can we reproduce this behavior?

  1. Go to WooCommerce > Settings > Products > General section.
  2. Reset Shop page option. It should be empty.
  3. Go to Shop page ( or product post type archive page ).
  4. Check that you don't see:
    Notice: Undefined property: WP_Post_Type::$ID in /www/wp-content/plugins/wordpress-seo/frontend/class-frontend.php on line 256

if WP_DEBUG option is on, otherwise check that php logs notices and any new notice has been added to php error log after this page visit.

Technical info

Links

Original report on Wordpress.org

kanlukasz commented 6 years ago

+1 i have the same issuse

benvaassen commented 6 years ago

Thanks for reporting this! I'm able to reproduce this.

Why is your shop page empty? I can't find any documentation when you'd want to leave it empty and am curious to know why it is. That way, I can make a better judgment of the impact of the issue.

CarolineGeven commented 6 years ago

Closing due to inactivity. If this issue is still relevant, please reply with the requested information.

MarcHe124 commented 6 years ago

Same issue. PHP7.0 and PHP7.2. Error on woocommerce shop pages

kanlukasz commented 6 years ago

Sorry for non response.

@benvaassen Shop is empty because i removed choose shop page in Woocomerce -> Setting -> Products

obraz

I did this beacuse i dont wanna allow preview all products on frontend in www.*****.pl/shop

benvaassen commented 6 years ago

@kanlukasz when I leave the shop page blank, I still get the preview of all products on the /shop page.

kanlukasz commented 6 years ago

@benvaassen Hmm interesting. So maybe i did something wrong. I have to check it again. Sorry for the confusion.

EOT