Opened 7 months ago
Last modified 35 hours ago
#57067 new enhancement
Replace certain `array_key_exists()` calls with `isset()` once PHP requirement is raised to 7.0+
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 6.3 | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | needs-patch |
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 (8)
This ticket was mentioned in PR #3907 on WordPress/wordpress-develop by @Mamaduka.
4 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:
4 months ago
#6
Committed in https://core.trac.wordpress.org/changeset/55142.
#7
@
3 weeks ago
- Keywords needs-patch added; has-patch removed
- Milestone changed from Future Release to 6.3
cc @jrf @aristath @desrosj