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 in the gallery block #41193

Merged
merged 3 commits into from
Jun 17, 2022

Conversation

aristath
Copy link
Member

What?

Fixes a PHP 8.1 deprecation error in the gallery block.

Why?

Using PHP 8.1, I'm getting the following message:
PHP Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in gutenberg/build/block-library/blocks/gallery.php on line 51.

The issue here is that PHP 8.1 is stricter than previous versions, and passing null when a string is expected is no longer acceptable. In PHP 9 this will throw a fatal error so we should fix this soon.

How?

Adds an additional check to ensure that values passed to preg_match are strings.

Testing Instructions

Using PHP 8.1 ensure that the block no longer throws a deprecation warning in the error-log.

@aristath aristath marked this pull request as ready for review May 20, 2022 09:56
@aristath aristath requested a review from geriux as a code owner May 20, 2022 09:56
@aristath aristath added the [Type] Bug An existing feature does not function as intended label May 20, 2022
@aristath aristath force-pushed the fix/gallery-php81-deprecation branch from dbad067 to cab89c0 Compare May 23, 2022 06:53
@aristath aristath merged commit 943aaef into trunk Jun 17, 2022
@aristath aristath deleted the fix/gallery-php81-deprecation branch June 17, 2022 11:16
@github-actions github-actions bot added this to the Gutenberg 13.6 milestone Jun 17, 2022
Copy link
Member

@SergeyBiryukov SergeyBiryukov left a comment

Choose a reason for hiding this comment

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

Looks good 🙂 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants