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

PHP deprecated notice

Open shabnam611 opened this issue 1 year ago • 2 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

To Reproduce

Step-by-step reproduction instructions

  1. When using PHP 8.1 with Yoast SEO 22.9, the debug log shows PHP Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /wp-content/plugins/wordpress-seo/src/presenters/canonical-presenter.php on line 49

Screenshots, screen recording, code snippet

If possible, please provide a screenshot, a screen recording or a code snippet which demonstrates the bug.

Technical info

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

Used versions

  • Device you are using:
  • Operating system:
  • PHP version: 8.1.28
  • WordPress version: 6.5.4
  • WordPress Theme: Hello Elementor
  • Yoast SEO version: 22.9
  • Gutenberg plugin version:
  • Elementor plugin version:
  • Classic Editor plugin version:
  • Relevant plugins in case of a bug:

shabnam611 avatar Jun 27 '24 11:06 shabnam611

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

shabnam611 avatar Jun 27 '24 11:06 shabnam611

Please include this customer of conversation # 1174638 when this conversation has been closed.

y-noel-baguio avatar Sep 17 '24 15:09 y-noel-baguio

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

janwinmadrona avatar Oct 21 '24 05:10 janwinmadrona

Is this going to be fixed at some point given PHP 8.1 released in 2021 and the current version is 8.3. It looks like a small adjustment is needed to the function call to resolve this.

robinwilson16 avatar Nov 28 '24 13:11 robinwilson16

+1 https://wordpress.org/support/topic/deprecation-warning-in-php-8-2/

suascat avatar Dec 20 '24 19:12 suascat

Literally all that needs to be done to fix this is change line 49 to this:

return \urldecode( \trim( (string) \apply_filters( 'wpseo_canonical', $this->presentation->canonical, $this->presentation ) ) );

Note that the (string) cast that is currently on the trim() call is redundant because trim() can only return a string.

monkeyArms avatar Jan 21 '25 21:01 monkeyArms

Hi @monkeyArms

Thank you for taking the time to check this issue and for sharing the fix! We truly appreciate your contribution and enthusiasm.

We would love for you to submit your fix as a Pull Request. It will be a great way to ensure your contribution gets properly reviewed and integrated into the project by our development team. You can find more details about contributing here.

I appreciate any help you can provide.

josevarghese avatar Jan 22 '25 05:01 josevarghese

@josevarghese this notice generates an enormous amount of noise if tools like Sentry or similar are in place. We have a composer patch to patch this up in place, but would love it if it could make it upstream.

aanduque avatar Jan 30 '25 12:01 aanduque

Hi @aanduque

Thanks for the comment and for taking the time to create a Pull Request! We appreciate your contribution and will look it over as soon as possible. Your efforts to improve the project mean a lot to us.

josevarghese avatar Feb 02 '25 18:02 josevarghese

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

mikigeniston avatar Feb 12 '25 22:02 mikigeniston