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

Fix: PHP 8.1 Deprecation - strncmp(): Passing null to parameter #44829

Merged
merged 2 commits into from
Oct 24, 2022

Conversation

Soean
Copy link
Member

@Soean Soean commented Oct 10, 2022

What?

If the $value is null, we don't need to do some string checks, because they throw PHP 8.1 deprecation messages: strncmp(): Passing null to parameter #1 ($string1) of type string is deprecated.

Fixes: #44792

@Soean Soean added the [Type] Code Quality Issues or PRs that relate to code quality label Oct 10, 2022
Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing, @Soean.

A similar check was removed in #43925; let's be sure fixing the deprecation doesn't cause a regression.

cc/ @matiasbenedetto, @andrewserong

Copy link
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't had a chance to test this yet, but in principle it sounds like a safe change — the previous PR resolved the earlier issue by removing the '' empty string fallback. This PR doesn't make a change to the value of $value so sounds pretty safe.

I suppose another option might be to update the check to if ( ! is_string( $value ) ) {, but I don't have a strong preference either way. Thanks for putting this PR up!

@Soean Soean self-assigned this Oct 11, 2022
Copy link
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, just re-tested the issue resolved in #43925 by @matiasbenedetto, and confirmed that this PR doesn't re-introduce the regression 👍

@Soean Soean merged commit 5fdeae1 into trunk Oct 24, 2022
@Soean Soean deleted the php-dep-fix-2 branch October 24, 2022 07:24
@github-actions github-actions bot added this to the Gutenberg 14.5 milestone Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PHP Deprecated: strncmp(): Passing null to parameter #1
3 participants