[wp-trac] [WordPress Trac] #48059: Check PHP and MySQL requirements as early as possible
WordPress Trac
noreply at wordpress.org
Tue Sep 17 17:02:30 UTC 2019
#48059: Check PHP and MySQL requirements as early as possible
----------------------------+-----------------------
Reporter: SergeyBiryukov | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 5.3
Component: Bootstrap/Load | Version:
Severity: normal | Keywords: has-patch
Focuses: |
----------------------------+-----------------------
Background: #47678
As noted in comment:58:ticket:47678, `wp-includes/plugin.php` cannot
currently use PHP 5.6+ function signatures. For example, replacing
`func_get_arg()` in `do_action()` with the spread operator: `do_action(
$tag, ...$arg )` causes a fatal error on older PHP versions:
{{{
Parse error: syntax error, unexpected '.', expecting '&' or T_VARIABLE in
wp-includes/plugin.php on line 442
}}}
instead of displaying a proper error message:
{{{
Your server is running PHP version 5.2.17 but WordPress
5.3-alpha-45282-src requires at least 5.6.20.
}}}
Upon some investigation, it looks like the PHP version check is done a bit
too late in the process flow.
Just moving the check earlier doesn't help, as
`wp_load_translations_early()` includes `wp-includes/plugin.php` for
`do_action()` and `apply_filters()` calls in `l10n.php`.
Moving the check earlier along with removing
`wp_load_translations_early()` for this error message appears to work as
expected. I believe the performance improvements from using modern PHP
code outweigh the benefits of having this particular string translated.
At the moment, these 12 files (apart from `wp-settings.php`) need to be
parsable by older PHP versions to display a proper error message:
{{{
wp-includes/load.php
wp-includes/class-wp-paused-extensions-storage.php
wp-includes/class-wp-fatal-error-handler.php
wp-includes/class-wp-recovery-mode-cookie-service.php
wp-includes/class-wp-recovery-mode-key-service.php
wp-includes/class-wp-recovery-mode-link-service.php
wp-includes/class-wp-recovery-mode-email-service.php
wp-includes/class-wp-recovery-mode.php
wp-includes/error-protection.php
wp-includes/default-constants.php
wp-includes/plugin.php
wp-includes/version.php
}}}
With the patch, the number of files that need to remain parsable by older
PHP versions is reduced to just two:
{{{
wp-includes/version.php
wp-includes/load.php
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48059>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list