Skip to content

Fix deprecation notices in PHP >= 8.1#22007

Merged
enricobattocchi merged 2 commits intoYoast:trunkfrom
aanduque:21455-fix-deprecation-notice
Feb 3, 2025
Merged

Fix deprecation notices in PHP >= 8.1#22007
enricobattocchi merged 2 commits intoYoast:trunkfrom
aanduque:21455-fix-deprecation-notice

Conversation

@aanduque
Copy link
Copy Markdown
Contributor

@aanduque aanduque commented Jan 30, 2025

Context

Summary

This PR can be summarized in the following changelog entry:

  • Fixes a bug where the canonical presenter would throw a deprecation notice when the environments run PHP >= 8.1. Props to aanduque.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • add the following snippet in your theme's functions.php:
add_filter( 'wpseo_canonical', function() { return null; } );
add_filter( 'wpseo_opengraph_title', function() { return null; } );
  • make sure you are running PHP >= 8.1
  • make sure WP_DEBUG is true
  • visit a post in the frontend
  • without this patch:
    • you get two trim(): Passing null to parameter #1 ($string) of type string is deprecated warnings
  • with this patch:
    • you don´t get the warning above

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

QA can test this PR by following these steps:

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes #21455

@aanduque aanduque marked this pull request as ready for review January 30, 2025 12:10
@aanduque aanduque changed the title Fix deprecation notice in PHP >= 8.1 Fix deprecation notices in PHP >= 8.1 Jan 30, 2025
@aanduque aanduque marked this pull request as draft January 30, 2025 12:40
@aanduque aanduque marked this pull request as ready for review January 30, 2025 12:44
@enricobattocchi enricobattocchi self-requested a review February 3, 2025 13:30
@enricobattocchi enricobattocchi self-assigned this Feb 3, 2025
@enricobattocchi enricobattocchi added changelog: bugfix Needs to be included in the 'Bugfixes' category in the changelog and removed community-patch labels Feb 3, 2025
@enricobattocchi
Copy link
Copy Markdown
Member

Thanks for your contribution @aanduque! This will be released in one of the upcoming versions.

@enricobattocchi enricobattocchi merged commit 3e955d7 into Yoast:trunk Feb 3, 2025
@enricobattocchi enricobattocchi added this to the 24.5 milestone Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: bugfix Needs to be included in the 'Bugfixes' category in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHP deprecated notice

4 participants