Fix deprecation warning by checking for null before stripslashes() in Meta_Description_Presenter #22314
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
This PR fixes a deprecation warning introduced in PHP 8.1+ where
stripslashes()
throws a warning when passed null. The issue occurs inMeta_Description_Presenter
when$meta_description
is null before being passed tostripslashes()
. This can prevent pages using ACF Flexible Content fields from saving properly, showing a "The response is not a valid JSON response" error.Summary
Changelog:
changelog: bugfix
Fixes a bug where saving posts with ACF flexible content fields could fail with a JSON error due to a deprecation warning in PHP 8.1+ (stripslashes(null)
inMeta_Description_Presenter
).Relevant technical choices
Added a null check before calling stripslashes():
Test instructions
Impact check
This PR affects how meta descriptions are handled in Yoast SEO, specifically in
Meta_Description_Presenter
. Any code that relies on filtering or modifying meta descriptions could be impacted. Regression testing is advised around: