Skip to content

Fix deprecations#1077

Merged
mauteri merged 2 commits intoGatherPress:developfrom
apermo:fix-deprecations
Apr 27, 2025
Merged

Fix deprecations#1077
mauteri merged 2 commits intoGatherPress:developfrom
apermo:fix-deprecations

Conversation

@apermo
Copy link
Copy Markdown
Contributor

@apermo apermo commented Apr 27, 2025

Description of the Change

This fixes #1076 by adding a ! empty() check. And #1047 by checking if the given array has the key we want to check.
Also replaced strpos() with str_contains() as it is available as polyfill since WordPress 5.x

Closes #1076
Closes #1047

How to test the Change

Open a topic listing with WP_DEBUG active.

Changelog Entry

Fixed - Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated
Fixed - Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated

Credits

Props @apermo, @shawfactor

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

apermo added 2 commits April 27, 2025 18:17
… type string is deprecated

Also replaced strpos() with str_contains(). str_contains() was introduced in WP 5.9 as polyfill, min WP version is set to 6.7.

Ref: GatherPress#1047
…f type string is deprecated

Added a ! empty() check. This will catch more than just null, but any other empty result will end up in an empty array and thus in skipping the foreach, so bailing out early will be a bit cheaper and cleaner.

Ref: GatherPress#1076
@github-actions
Copy link
Copy Markdown
Contributor

Preview changes with Playground

You can preview the recent changes for PR#1077 with the following PHP versions:

PHP Version 8.3

PHP Version 7.4

Download .zip with build changes

Made with 💙 from GatherPress & a little bit of WordPress Playground. Changes will not persist between sessions.

@mauteri mauteri merged commit 3373151 into GatherPress:develop Apr 27, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants