Skip to content

Check the minimum PHP version from the WordPress checkout, before the build - #360

Merged
mindctrl merged 1 commit into
WordPress:masterfrom
ekamran:shifteq/required-php-version
Oct 27, 2026
Merged

mindctrl merged 1 commit into
WordPress:masterfrom
ekamran:shifteq/required-php-version

Conversation

@ekamran

@ekamran ekamran commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #359.

Problem

prepare.php only rejects PHP older than 7.2, but WordPress has required PHP 7.4 since 7.0 (r61459). With PHP 7.2 or 7.3, a run gets past the check, clones and builds WordPress, and then fails in Composer with a dependency error. Details in #359.

Fix

  • A new wpt_runner_get_required_php_version() loads src/wp-includes/version.php from the prepared checkout inside a function and returns $required_php_version. WordPress reads the requirements of a new version the same way in update_core(). The check then follows WordPress when the minimum changes.
  • The PHP version check now runs right after the clone, before npm install and the build, so an unsupported PHP version stops the run in seconds. The version lookup moved with it, unchanged.
  • If the version cannot be read, prepare.php stops with an error that names the file.

Verification

The version check block of prepare.php, run on its own with the trunk version.php (7.4):

Test environment PHP master this branch
7.2.34 allowed stopped
7.3.33 allowed stopped
7.4.0, 7.4.33, 8.3.30, 8.5.11 allowed allowed

The message reads: "WordPress requires PHP 7.4 or later, but the test environment runs PHP 7.3.33." With the 6.8 branch's version.php (7.2.24), the check stops 7.2.23 and allows 7.2.24. A version.php with a double-quoted value is read the same way.

Full prepare.php against trunk (8778884d3f):

  • WPT_PHP_EXECUTABLE pointing to a script that reports 7.3.33: master runs for 43 seconds (clone, npm install, build) and then fails in Composer. This branch stops after the clone, 7 seconds in, with the message above.
  • PHP 8.5.11: both prepare the environment, and the generated wp-tests-config.php files are identical.

php -l passes on PHP 7.4, 8.0 and 8.2, and phpcs is clean.

Notes

AI assistance: Yes
Tool(s): Claude Code and Codex
Used for: Investigation, implementation, verification harness, and PR wording. I reviewed the reasoning and test results, and I take responsibility for the contribution.

…build

prepare.php only rejected PHP older than 7.2, while WordPress has required
PHP 7.4 since 7.0. With PHP 7.2 or 7.3 a run cloned and built WordPress and
then failed in Composer with a dependency error.

Read $required_php_version from src/wp-includes/version.php in the prepared
checkout, the way update_core() reads the requirements of a new version,
and run the check right after the clone, before npm install and the build.
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ekamran <ekamran@git.wordpress.org>
Co-authored-by: sonali195 <sonaliprajapati@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@sonali195

Copy link
Copy Markdown

Looks good to me. The PHP requirement is read from the cloned WordPress checkout and checked before the build, so unsupported PHP versions are caught early. I found no issues.

@mindctrl
mindctrl merged commit af18056 into WordPress:master Oct 27, 2026
8 checks passed
@ekamran
ekamran deleted the shifteq/required-php-version branch October 27, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The PHP version check in prepare.php still allows PHP 7.2 and 7.3

4 participants