From 481e78643661b74e51128734ed2b7ace6df25630 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Fri, 20 Nov 2026 06:34:34 +0530 Subject: [PATCH] fix(php): store the concrete version for --php=latest A site created with --php=latest was stored as `latest`, which follows the default PHP version: after a default bump, the next compose regeneration moves it to the new image while it keeps the PHP config of the old one (SC-60). create() now stores DEFAULT_PHP_VERSION (8.5) instead, so the compose file, custom.ini and the sites row all get the concrete version. --php=latest is still accepted, and rows that still say `latest` keep running the default image. Behat: the `latest` row of "Create a site on PHP " expects php_version 8.5. --- features/COVERAGE.md | 2 +- features/php-version.feature | 13 +++++++------ src/WordPress.php | 4 ++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/features/COVERAGE.md b/features/COVERAGE.md index 7f24455..9afd73a 100644 --- a/features/COVERAGE.md +++ b/features/COVERAGE.md @@ -24,7 +24,7 @@ Legend: file names are under `features/`. Scenarios that assert the correct beha | `--local-db` | database: Create a site with a local database container, restart `--db`, disable/enable, delete | | `--with-local-redis` | cache: Create a site with cache on a local redis container; alone: not covered yet: `--with-local-redis` without `--cache` is silently ignored (its scenario comes back with the fix); restart policy: not covered yet: the local redis service has no restart policy (its scenario comes back with the fix) | | `--public-dir` | install-options: Serve WordPress from a public directory…; without value: not covered yet: a bare `--public-dir` makes the public dir `htdocs/1` (its scenario comes back with the fix) | -| `--php` (13 options; 8.6 not covered until its image is published) | 8.5 default and update to 8.2: php-version: Default PHP version and update…; 8.3, 8.5, latest: Create a site on PHP ; 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1: `@slow` outlines; invalid (7.1, 9.9, foo): Unsupported PHP version…; loose matches (8, 8.10, 08.5, ' 8.5'): not covered: core's synopsis check compares loosely and lets them through, then create() compares as strings: surrounding whitespace is trimmed, the rest gets the fallback prompt (`--php=8` asks to continue with 8.5; `--yes` takes it) | +| `--php` (13 options; 8.6 not covered until its image is published) | 8.5 default and update to 8.2: php-version: Default PHP version and update…; 8.3, 8.5, latest (stored as the default version, 8.5): Create a site on PHP ; 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1: `@slow` outlines; invalid (7.1, 9.9, foo): Unsupported PHP version…; loose matches (8, 8.10, 08.5, ' 8.5'): not covered: core's synopsis check compares loosely and lets them through, then create() compares as strings: surrounding whitespace is trimmed, the rest gets the fallback prompt (`--php=8` asks to continue with 8.5; `--yes` takes it) | | `--dbname`, `--dbuser`, `--dbpass` | database: Custom database name…, Deleting the site drops its custom database and user; remote: external-db; collisions: database ×3 | | `--dbhost` (+ `:port`) | database: Remote database host requires credentials, Unreachable remote database rolls the site back; external-db: all scenarios | | `--dbprefix`, `--dbcharset`, `--dbcollate`, `--skip-check` | database: Custom database name, user, password, prefix, charset and collation… | diff --git a/features/php-version.feature b/features/php-version.feature index fa2c048..761ac95 100644 --- a/features/php-version.feature +++ b/features/php-version.feature @@ -53,8 +53,8 @@ Feature: PHP versions of WordPress sites (--php on create and update) When I run 'bin/ee site create bh-site-type-wp-php.test --type=wp --php=' Then the command should succeed And the site 'bh-site-type-wp-php.test' info should contain: - | field | value | - | php_version | | + | field | value | + | php_version | | And the 'php' container of site 'bh-site-type-wp-php.test' should use image 'easyengine/:' When In the 'php' container of site 'bh-site-type-wp-php.test' I run 'php -v' Then STDOUT should contain: @@ -65,11 +65,12 @@ Feature: PHP versions of WordPress sites (--php on create and update) When I run 'bin/ee site delete bh-site-type-wp-php.test --yes' Then the command should succeed + # `latest` is stored as the default version (8.5), so a later default bump doesn't move the site. Examples: - | php | name | image | runtime | - | 8.3 | 83 | php8.3 | 8.3. | - | 8.5 | 85 | php8.5 | 8.5. | - | latest | latest | php8.5 | 8.5. | + | php | name | stored | image | runtime | + | 8.3 | 83 | 8.3 | php8.3 | 8.3. | + | 8.5 | 85 | 8.5 | php8.5 | 8.5. | + | latest | latest | 8.5 | php8.5 | 8.5. | # These pull the older php images (not present on a fresh host) and need an older WordPress for PHP < 7.4. @slow diff --git a/src/WordPress.php b/src/WordPress.php index 6685328..e60de9e 100644 --- a/src/WordPress.php +++ b/src/WordPress.php @@ -413,6 +413,10 @@ public function create( $args, $assoc_args ) { } \EE::confirm( sprintf( 'EEv4 does not support PHP %s. Continue with PHP %s?', $old_version, $this->site_data['php_version'] ), $assoc_args ); } + // Stored as the concrete version: a stored `latest` would move to a newer image on a later default bump and keep the old PHP config. + if ( 'latest' === $this->site_data['php_version'] ) { + $this->site_data['php_version'] = self::DEFAULT_PHP_VERSION; + } if ( \EE\Utils\get_flag_value( $assoc_args, 'local-db' ) ) { $this->site_data['db_host'] = 'db';