Yoast / wordpress-seo

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

strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated #21435

Open kkmuffme opened 3 weeks ago

kkmuffme commented 3 weeks ago

Please give us a description of what happened

strpos(): Passing null to parameter # 1 ($haystack) of type string is deprecated

wordpress-seo/src/helpers/first-time-configuration-notice-helper.php (line 127)

To Reproduce

Step-by-step reproduction instructions

  1. open WooCommerce product csv import (direct url: /wp-admin/admin.php?import=woocommerce_product_csv)
  2. get PHP notice

Expected results

  1. no PHP notice

Actual results

  1. PHP notice

filter_input will return null|false if the GET parameter is not set or in PHP CLI (even if it's set). Possibly use static analysis tools like psalm to prevent errors like those in the future

Used versions

josevarghese commented 1 week ago

Hi @kkmuffme

Thanks for using the Yoast SEO plugin and for creating the issue.

I tried reproducing the issue by installing the Storefront theme, Yoast SEO 22.9. However, I could not notice the error you mentioned when I tried to access the Import product page within the Tools > Import > WooCommerce products (CSV). I also noticed that the import URL on my lab site is /wp-admin/edit.php?post_type=product&page=product_importer instead of the one you mentioned /wp-admin/admin.php?import=woocommerce_product_csv. So, please let us know whether you are using any plugins for importing the WooCommerce Product import other than the one provided by WooCommerce by default.

We look forward to hearing from you.

kkmuffme commented 1 week ago

Hi

possibly. In any case, this is purely a type/static analysis issue and doesn't need a reproducer. Trying to get a reproducer takes more time than to actually create a PR and fix this, so I don't think it's time well spent.

josevarghese commented 1 week ago

Hi @kkmuffme

We want to reproduce the issue before escalating it to the appropriate team, as line 127 within the file https://github.com/Yoast/wordpress-seo/blob/trunk/src/helpers/first-time-configuration-notice-helper.php#L127 is to check whether the page is a Yoast SEO admin page.

If you are interested in contributing to our plugin, please send a PR - see more info here: https://github.com/Yoast/wordpress-seo/blob/trunk/.github/CONTRIBUTING.md