#57067 closed enhancement (fixed)
Replace certain `array_key_exists()` calls with `isset()` once PHP requirement is raised to 7.0+
Reported by: | flixos90 | Owned by: | flixos90 |
---|---|---|---|
Milestone: | 6.4 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Themes | Keywords: | has-patch commit |
Focuses: | performance | Cc: |
Description
This ticket is blocked until WordPress requires at least PHP 7.0 as minimum version.
Checks like isset( MY_CONSTANT[ $key ] )
result in a fatal error in PHP < 7.0, which is why parts of the WordPress codebase uses array_key_exists()
for such situations as of today, due to the support for PHP 5.6. Also see https://github.com/PHPCompatibility/PHPCompatibility/issues/1301 which explores flagging this as part of the PHPCompatibility sniffs.
This was raised as part of #56974, which reviewed several of these checks. isset
is slightly preferable over array_key_exists
in terms of performance (with the caveat that the two behave differently when it comes to null
values).
As of today, this ticket is essentially a reminder to update such calls to array_key_exists()
in WordPress core once it will at some point no longer support PHP versions below 7.0.
Change History (19)
This ticket was mentioned in PR #3907 on WordPress/wordpress-develop by @Mamaduka.
21 months ago
#4
- Keywords has-patch added
PR fixes a small regression after 54805, where an incorrect variable was used inside the loop.
Trac ticket: https://core.trac.wordpress.org/ticket/57067
@flixos90 commented on PR #3907:
21 months ago
#6
Committed in https://core.trac.wordpress.org/changeset/55142.
#7
@
17 months ago
- Keywords needs-patch added; has-patch removed
- Milestone changed from Future Release to 6.3
#8
@
16 months ago
The effort to bump the minimum version of PHP is being tracked in #57345, which is blocking this ticket. Even so, it would be good to have a patch ready and reviewed so it can be committed as soon as the official decision to drop PHP 5.6 has been made.
#9
@
16 months ago
Anybody willing to be the owner on this ticket and work on a pull request? Otherwise, I think we'll have to punt it, since the final decision on whether to bump the minimum PHP version has still not been made.
We need a PR for this preferably by end of this week in order to commit it before 6.3 beta next Tuesday.
#10
@
16 months ago
- Milestone changed from 6.3 to Future Release
Let's bump it for now, it's not a critical change. I'm waiting to hear the final decision about the minimum PHP version bump.
#11
@
15 months ago
Since the bump to PHP 7.0 happened for WP 6.3, can this be brought back into 6.3 as well?
#12
@
15 months ago
- Milestone changed from Future Release to 6.4
It's a minor change however it's not urgent and it's an enhancement. If someone works on a PR we'll get it into 6.4.
#13
@
14 months ago
I created a PR for the WP_Theme_JSON in the Gutenberg project: https://github.com/WordPress/gutenberg/pull/53098
After merging, I will create a PR for Core.
#15
@
14 months ago
- Keywords has-patch commit added; needs-patch removed
- Owner set to flixos90
- Status changed from new to reviewing
Thanks @Soean for the PR, about to commit shortly.
cc @jrf @aristath @desrosj