Skip to content

Conversation

@hellofromtonya
Copy link
Contributor

Closes #42565.

What?

As reported in #42565, using isset() on a constant causing a fatal parsing error.

Why?

Resolves a fatal parsing error on sites running PHP 5.6.

How?

This PR replaces isset() with array_key_exists().

Testing Instructions

Before using this PR, do the following to reproduce the issue:

  1. Set your environment to use PHP 5.6 (how to do this depends upon the localhost app/tooling you're using).
  2. Log into the admin area.
  3. Go to Plugins > Add New.
  4. Install the Gutenberg plugin.
  5. Activate the plugin. Result: Fatal error.

Apply this PR and do the following to confirm the PR resolves the issue:

  1. Refresh the Plugins admin page in the browser.
  2. Active the Gutenberg plugin. Expected: no error and plugin activates.

…with `array_key_exists()` to resolve the fatal parsing error on PHP 5.6.
@hellofromtonya hellofromtonya added Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json CSS Styling Related to editor and front end styles, CSS-specific issues. labels Jul 20, 2022
@hellofromtonya hellofromtonya self-assigned this Jul 20, 2022
@hellofromtonya hellofromtonya added the [Type] Bug An existing feature does not function as intended label Jul 20, 2022
@hellofromtonya hellofromtonya merged commit 83d17c8 into trunk Jul 20, 2022
@hellofromtonya hellofromtonya deleted the fix/isset-on-constants branch July 20, 2022 17:24
Copy link
Contributor

@anton-vlasenko anton-vlasenko left a comment

Choose a reason for hiding this comment

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

LGTM!

@spacedmonkey
Copy link
Member

Side note, php unit tests should run in different versions of PHP like core does.

@hellofromtonya
Copy link
Contributor Author

Side note, php unit tests should run in different versions of PHP like core does.

I agree @spacedmonkey! On my TODO list. Let's make that happen 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CSS Styling Related to editor and front end styles, CSS-specific issues. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fatal error on PHP 5.6 for using isset() on class constant WP_Theme_JSON_6_1::VALID_ELEMENT_PSEUDO_SELECTORS

4 participants