Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pmpro_no_quotes - Add null coalescing operator #2909

Merged
merged 2 commits into from
Mar 27, 2024

Conversation

ipokkel
Copy link
Member

@ipokkel ipokkel commented Mar 26, 2024

All Submissions:

Changes proposed in this Pull Request:

When null is passed to the str_replace arguments used in pmpro_no_quotes the follow error got logged in debug:

PHP Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Resolves XXX.

Adding a null coalescing operator to the search string third argument returns an empty string which resolves this issue.

How to test the changes in this Pull Request:

  1. Activate the Custom Level Cost Text Add On, navigate to Memberships > Settings > Advanced and check the debug log for the deprecated warning.
  2. Apply the patch, reload the page, and confirm that no new log entries were added.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you successfully run tests with your changes locally?

@ideadude
Copy link
Member

This works but would raise the PHP version requirement to 7.

Inline with our intention to only raise the version requirement when necessary, we can rewrite this to avoid the null in another way.

Something like if ( empty( $s ) ) { $s = ''; } above the return.

@dparker1005 dparker1005 merged commit e29a0ae into strangerstudios:dev Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants