From af2003641950e3a36515706415a1d20b93f21e61 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Thu, 19 Nov 2026 10:40:36 +0530 Subject: [PATCH 1/4] feat(php): add PHP 8.6 to the supported PHP versions Allow `--php=8.6` for PHP sites. The site runs the easyengine/php8.6 image with the tag from core's img-versions.json. The default and `latest` stay on 8.4. --- src/PHP.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/PHP.php b/src/PHP.php index 883fe39..e798c1a 100644 --- a/src/PHP.php +++ b/src/PHP.php @@ -88,7 +88,7 @@ public function __construct() { * : Create separate db container instead of using global db. * * [--php=] - * : PHP version for site. Currently only supports PHP 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, and latest. + * : PHP version for site. Currently only supports PHP 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, and latest. * --- * default: 8.4 * options: @@ -102,7 +102,8 @@ public function __construct() { * - 8.2 * - 8.3 * - 8.4 - * - 8.5 + * - 8.5 + * - 8.6 * - latest * --- * @@ -233,7 +234,7 @@ public function create( $args, $assoc_args ) { $this->site_data['alias_domains'] = implode( ',', array_merge( [ $this->site_data['site_url'] ], $alias_domains ) ); - $supported_php_versions = [ 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 'latest' ]; + $supported_php_versions = [ 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 'latest' ]; if ( ! in_array( $this->site_data['php_version'], $supported_php_versions ) ) { $old_version = $this->site_data['php_version']; $floor = (int) floor( $this->site_data['php_version'] ); From f85a4a9caaa48ddf0da1f05c325cccf3e86ce0ec Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Thu, 19 Nov 2026 11:41:31 +0530 Subject: [PATCH 2/4] feat(php): make PHP 8.5 the default for new PHP sites New PHP sites now default to PHP 8.5 instead of 8.4. `--php=latest` now runs the easyengine/php8.5 image, and create() now falls back to 8.5 for an 8.x version it doesn't support. PHP 8.6 stays opt-in with `--php=8.6`. Changes: the `--php` default and help in src/PHP.php, the 8.x fallback in the same file, and the `latest` image in src/Site_PHP_Docker.php. The Behat features that check the default or `latest` site now expect 8.5. The README's `--php` help now matches the command: default 8.5, with 8.6 listed. --- README.md | 20 ++++++++++++-------- features/COVERAGE.md | 4 ++-- features/create.feature | 8 ++++---- features/lifecycle.feature | 4 ++-- features/php-version.feature | 8 ++++---- features/site.feature | 2 +- src/PHP.php | 4 ++-- src/Site_PHP_Docker.php | 2 +- 8 files changed, 28 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index ae10745..12337f1 100644 --- a/README.md +++ b/README.md @@ -37,9 +37,9 @@ ee site create --type=php [--cache] [--admin-email=] [ Create separate db container instead of using global db. [--php=] - PHP version for site. Currently only supports PHP 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, and latest. + PHP version for site. Currently only supports PHP 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, and latest. --- - default: 8.4 + default: 8.5 options: - 5.6 - 7.0 @@ -52,6 +52,7 @@ ee site create --type=php [--cache] [--admin-email=] [ - 8.3 - 8.4 - 8.5 + - 8.6 - latest --- @@ -186,9 +187,9 @@ ee site info --type=php [--cache] [--admin-email=] [-- Create separate db container instead of using global db. [--php=] - PHP version for site. Currently only supports PHP 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, and latest. + PHP version for site. Currently only supports PHP 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, and latest. --- - default: 8.4 + default: 8.5 options: - 5.6 - 7.0 @@ -201,6 +202,7 @@ ee site info --type=php [--cache] [--admin-email=] [-- - 8.3 - 8.4 - 8.5 + - 8.6 - latest --- @@ -419,9 +421,9 @@ ee site reload --type=php [--cache] [--admin-email=] [ Create separate db container instead of using global db. [--php=] - PHP version for site. Currently only supports PHP 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, and latest. + PHP version for site. Currently only supports PHP 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, and latest. --- - default: 8.4 + default: 8.5 options: - 5.6 - 7.0 @@ -434,6 +436,7 @@ ee site reload --type=php [--cache] [--admin-email=] [ - 8.3 - 8.4 - 8.5 + - 8.6 - latest --- @@ -515,9 +518,9 @@ ee site restart --type=php [--cache] [--admin-email=] Create separate db container instead of using global db. [--php=] - PHP version for site. Currently only supports PHP 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, and latest. + PHP version for site. Currently only supports PHP 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, and latest. --- - default: 8.4 + default: 8.5 options: - 5.6 - 7.0 @@ -530,6 +533,7 @@ ee site restart --type=php [--cache] [--admin-email=] - 8.3 - 8.4 - 8.5 + - 8.6 - latest --- diff --git a/features/COVERAGE.md b/features/COVERAGE.md index 431c785..891fcd8 100644 --- a/features/COVERAGE.md +++ b/features/COVERAGE.md @@ -33,7 +33,7 @@ Scope: `ee site create --type=php` and everything php-specific (`src/PHP.php`, ` | DB name / user collisions on rollback | database.feature: `--dbname`/`--dbuser` of another site refused, colliding default names refused by the volume check, a taken default name gets a `_2` suffix, each on its own sites (regression checks for EasyEngine/site-command#503 and EasyEngine/site-type-php#115) | | mysql CLI in the php container against the global and local db | not covered yet: the MariaDB client in php8.2+ images demands TLS, which the EasyEngine MariaDB doesn't offer (its 2 scenarios come back with the fix) | | `--php=` every supported version + `latest` | php-version.feature outline (12 examples, `@slow`) | -| `--php` default 8.4 | create.feature "The site row holds the php defaults", "The compose file ..." | +| `--php` default 8.5 | create.feature "The site row holds the php defaults", "The compose file ..." | | `--php` invalid values | create.feature outline "An unsupported --php value is rejected" (4 examples) | | `--php` loosely matching values (`8`, `7`, `8.40`, `8.4.1`) | not covered yet: a loose `in_array()` accepts them and the create fails late on a missing image (its outline, 4 examples, comes back with the fix) | | `--php=` without `--type` (EE3 compat mapping) | not covered yet: the version is consumed as the EE3 `--php` type flag and dropped (its scenario comes back with the fix) | @@ -140,7 +140,7 @@ Estimated coverage: about 88% of the inventory items above (php-specific items: Scenarios for open bugs aren't in the suite: each comes back with the PR that fixes its bug. The inventory above marks them "not covered yet". Bugs without a clean black-box assertion aren't tested: php sites render `.env`/`php.ini` from site-type-wp's templates; site-command's `ltrim($url, 'www.')` character-list bug; `var_dump()` in the inherit error; `--ssl` options not enforced on create (documented by the `--ssl=bogus` rollback scenario); no `/etc/hosts` entry for custom/inherit SSL sites. -Other notes from the code: `--php=latest` maps to the php8.4 image, not the newest supported (8.5), maybe intended; `update --add/--delete-alias-domains` doesn't regenerate `main.conf` (stale `server_name`, harmless); a site created with `--dbhost=global-db:` and user-supplied credentials is stored with `db_host=global-db`, so `site delete` drops that pre-existing database and user. The old suite's label assertion was inverted and its mysql checks passed vacuously; both fixed in this context. +Other notes from the code: `update --add/--delete-alias-domains` doesn't regenerate `main.conf` (stale `server_name`, harmless); a site created with `--dbhost=global-db:` and user-supplied credentials is stored with `db_host=global-db`, so `site delete` drops that pre-existing database and user. The old suite's label assertion was inverted and its mysql checks passed vacuously; both fixed in this context. ## Tags diff --git a/features/create.feature b/features/create.feature index e41b53a..0df2741 100644 --- a/features/create.feature +++ b/features/create.feature @@ -17,7 +17,7 @@ Feature: Create a plain php site Then the site "bh-site-type-php-1.test" should be enabled And the site "bh-site-type-php-1.test" should have the field "site_type" set to "php" And the site "bh-site-type-php-1.test" should have the field "app_sub_type" set to "php" - And the site "bh-site-type-php-1.test" should have the field "php_version" set to "8.4" + And the site "bh-site-type-php-1.test" should have the field "php_version" set to "8.5" And the site "bh-site-type-php-1.test" should have the field "site_fs_path" set to "/opt/easyengine/sites/bh-site-type-php-1.test" And the site "bh-site-type-php-1.test" should have the field "site_container_fs_path" set to "/var/www/htdocs" And the site "bh-site-type-php-1.test" should have the field "alias_domains" set to "bh-site-type-php-1.test" @@ -55,7 +55,7 @@ Feature: Create a plain php site Scenario: The compose file has the php services and no db or redis Given a php site "bh-site-type-php-1.test" exists - Then the docker-compose file of site "bh-site-type-php-1.test" should use the pinned "easyengine/php8.4" image + Then the docker-compose file of site "bh-site-type-php-1.test" should use the pinned "easyengine/php8.5" image And the docker-compose file of site "bh-site-type-php-1.test" should use the pinned "easyengine/nginx" image And the docker-compose file of site "bh-site-type-php-1.test" should use the pinned "easyengine/postfix" image And the docker-compose file of site "bh-site-type-php-1.test" should use the pinned "easyengine/mailhog" image @@ -75,11 +75,11 @@ Feature: Create a plain php site And the site "bh-site-type-php-1.test" should have 3 running containers And the site "bh-site-type-php-1.test" should have 8 docker volumes And the docker network "bh-site-type-php-1.test" should exist - And the "php" service of site "bh-site-type-php-1.test" should use the pinned "easyengine/php8.4" image + And the "php" service of site "bh-site-type-php-1.test" should use the pinned "easyengine/php8.5" image And the "nginx" service of site "bh-site-type-php-1.test" should be attached to the docker network "ee-global-frontend-network" And the "php" service of site "bh-site-type-php-1.test" should not be attached to the docker network "ee-global-frontend-network" And the "php" service of site "bh-site-type-php-1.test" should have the restart policy "always" - And the php service of site "bh-site-type-php-1.test" should run PHP "8.4" + And the php service of site "bh-site-type-php-1.test" should run PHP "8.5" Scenario: The site is reachable over HTTP and runs PHP Given a php site "bh-site-type-php-1.test" exists diff --git a/features/lifecycle.feature b/features/lifecycle.feature index d2c3231..4611661 100644 --- a/features/lifecycle.feature +++ b/features/lifecycle.feature @@ -21,7 +21,7 @@ Feature: info, list, enable, disable, refresh, restart, reload, proxy cache and And the JSON in STDOUT should have "site_url" set to "bh-site-type-php-100.test" And the JSON in STDOUT should have "site_type" set to "php" And the JSON in STDOUT should have "app_sub_type" set to "php" - And the JSON in STDOUT should have "php_version" set to "8.4" + And the JSON in STDOUT should have "php_version" set to "8.5" And the JSON in STDOUT should have "site_enabled" set to "1" And the JSON in STDOUT should have "site_container_fs_path" set to "/var/www/htdocs" @@ -127,7 +127,7 @@ Feature: info, list, enable, disable, refresh, restart, reload, proxy cache and When I run "bin/ee site refresh bh-site-type-php-106.test" Then the command should succeed And the file "/opt/easyengine/sites/bh-site-type-php-106.test/docker-compose.yml" should not contain "# bh-compose-marker" - And the docker-compose file of site "bh-site-type-php-106.test" should use the pinned "easyengine/php8.4" image + And the docker-compose file of site "bh-site-type-php-106.test" should use the pinned "easyengine/php8.5" image And I wait until a GET request to "http://bh-site-type-php-106.test/" returns 200 within 60 seconds Scenario: site restart restarts nginx, php and the local db, not postfix diff --git a/features/php-version.feature b/features/php-version.feature index 0457c33..275c374 100644 --- a/features/php-version.feature +++ b/features/php-version.feature @@ -11,7 +11,7 @@ Feature: PHP versions of php sites (create --php, update --php) And the response should contain "Congratulations!" And the file "/opt/easyengine/sites//config/php/php/conf.d/custom.ini" should contain "" - # "latest" maps to the php8.4 image (Site_PHP_Docker), not to the newest supported version. + # "latest" maps to the php8.5 image (Site_PHP_Docker); 8.6 is opt-in. Examples: | site | version | image | runs | sendmail | | bh-site-type-php-40.test | 5.6 | easyengine/php5.6 | 5.6 | sendmail_path = /usr/sbin/sendmail -t -i -f no-reply@example.com | @@ -25,7 +25,7 @@ Feature: PHP versions of php sites (create --php, update --php) | bh-site-type-php-48.test | 8.3 | easyengine/php8.3 | 8.3 | sendmail_path = /usr/bin/msmtp -t | | bh-site-type-php-49.test | 8.4 | easyengine/php8.4 | 8.4 | sendmail_path = /usr/bin/msmtp -t | | bh-site-type-php-50.test | 8.5 | easyengine/php8.5 | 8.5 | sendmail_path = /usr/bin/msmtp -t | - | bh-site-type-php-51.test | latest | easyengine/php8.4 | 8.4 | sendmail_path = /usr/bin/msmtp -t | + | bh-site-type-php-51.test | latest | easyengine/php8.5 | 8.5 | sendmail_path = /usr/bin/msmtp -t | Scenario: Update the PHP version of a php site and keep custom php settings Given a php site "bh-site-type-php-52.test" exists @@ -38,7 +38,7 @@ Feature: PHP versions of php sites (create --php, update --php) And the docker-compose file of site "bh-site-type-php-52.test" should use the pinned "easyengine/php8.3" image And the "php" service of site "bh-site-type-php-52.test" should use the pinned "easyengine/php8.3" image And the php service of site "bh-site-type-php-52.test" should run PHP "8.3" - And the directory "/opt/easyengine/sites/bh-site-type-php-52.test/.backup/config/php-8.4" should exist + And the directory "/opt/easyengine/sites/bh-site-type-php-52.test/.backup/config/php-8.5" should exist And the file "/opt/easyengine/sites/bh-site-type-php-52.test/config/php/php/conf.d/custom.ini" should contain "; bh-custom-ini-marker" And I wait until a GET request to "http://bh-site-type-php-52.test/" returns 200 within 60 seconds @@ -83,7 +83,7 @@ Feature: PHP versions of php sites (create --php, update --php) When I run "bin/ee site update bh-site-type-php-55.test --php=8.3" Then the return code should be 1 And STDERR should contain "Error: Site bh-site-type-php-55.test is not enabled. Use `ee site enable bh-site-type-php-55.test` to enable it." - And the site "bh-site-type-php-55.test" should have the field "php_version" set to "8.4" + And the site "bh-site-type-php-55.test" should have the field "php_version" set to "8.5" Scenario: Updating a site that does not exist fails When I run "bin/ee site update bh-site-type-php-198.test --php=8.3" diff --git a/features/site.feature b/features/site.feature index 2eba0fa..b9ee0db 100644 --- a/features/site.feature +++ b/features/site.feature @@ -54,7 +54,7 @@ Feature: Site command presence and usage errors And STDOUT should contain "[--wildcard]" And STDOUT should contain "[--force]" And STDOUT should contain "[--public-dir]" - And STDOUT should contain "default: 8.4" + And STDOUT should contain "default: 8.5" Scenario: Help for php site info, restart and reload shows the php variants When I run "bin/ee help site restart --type=php" diff --git a/src/PHP.php b/src/PHP.php index e798c1a..59fe079 100644 --- a/src/PHP.php +++ b/src/PHP.php @@ -90,7 +90,7 @@ public function __construct() { * [--php=] * : PHP version for site. Currently only supports PHP 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, and latest. * --- - * default: 8.4 + * default: 8.5 * options: * - 5.6 * - 7.0 @@ -244,7 +244,7 @@ public function create( $args, $assoc_args ) { $this->site_data['php_version'] = 7.4; $old_version .= ' yet'; } elseif ( 8 === $floor ) { - $this->site_data['php_version'] = 8.4; + $this->site_data['php_version'] = 8.5; $old_version .= ' yet'; } else { EE::error( 'Unsupported PHP version: ' . $this->site_data['php_version'] ); diff --git a/src/Site_PHP_Docker.php b/src/Site_PHP_Docker.php index 9c9184e..822ce72 100644 --- a/src/Site_PHP_Docker.php +++ b/src/Site_PHP_Docker.php @@ -65,7 +65,7 @@ public function generate_docker_compose_yml( array $filters = [], $volumes ) { $db['networks'] = $network_default; } // PHP configuration. - $php_image_key = ( 'latest' === $filters['php_version'] ? 'easyengine/php8.4' : 'easyengine/php' . $filters['php_version'] ); + $php_image_key = ( 'latest' === $filters['php_version'] ? 'easyengine/php8.5' : 'easyengine/php' . $filters['php_version'] ); $php['service_name'] = [ 'name' => 'php' ]; $php['image'] = [ 'name' => $php_image_key . ':' . $img_versions[ $php_image_key ] ]; From 57e7caf364a1992dd4b43dfda906ccab9ede0ab9 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Thu, 19 Nov 2026 23:40:55 +0530 Subject: [PATCH 3/4] refactor(php): read the default PHP version from one constant `PHP::DEFAULT_PHP_VERSION` ('8.5') now drives the `latest` image in `Site_PHP_Docker`, the 8.x fallback and create()'s own fallback when `--php` is missing, and `PHP::SUPPORTED_PHP_VERSIONS` replaces the inline version list. This carries over the constant refactor of #113. The `--php` docblock keeps `default: 8.5`: EE's dispatcher injects it before create() runs, so it stays the effective default and `--help` keeps showing it. A docblock can't reference a constant, so a default bump changes both. No behaviour change. --- src/PHP.php | 17 +++++++++++++---- src/Site_PHP_Docker.php | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/PHP.php b/src/PHP.php index 59fe079..a2a7c61 100644 --- a/src/PHP.php +++ b/src/PHP.php @@ -28,6 +28,16 @@ */ class PHP extends EE_Site_Command { + /** + * Default PHP version for new sites, `latest` and the 8.x fallback. The create() docblock `default:` must match it. + */ + const DEFAULT_PHP_VERSION = '8.5'; + + /** + * Versions `--php` accepts. Keep in sync with the create() docblock options. + */ + const SUPPORTED_PHP_VERSIONS = [ '5.6', '7.0', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5', '8.6', 'latest' ]; + /** * @var string $cache_type Type of caching being used. */ @@ -211,7 +221,7 @@ public function create( $args, $assoc_args ) { $this->site_data['site_fs_path'] = WEBROOT . $this->site_data['site_url']; $this->cache_type = \EE\Utils\get_flag_value( $assoc_args, 'cache' ); $this->site_data['site_ssl_wildcard'] = \EE\Utils\get_flag_value( $assoc_args, 'wildcard' ); - $this->site_data['php_version'] = \EE\Utils\get_flag_value( $assoc_args, 'php' ); + $this->site_data['php_version'] = \EE\Utils\get_flag_value( $assoc_args, 'php', self::DEFAULT_PHP_VERSION ); $this->site_data['app_sub_type'] = 'php'; $this->site_data['site_container_fs_path'] = get_public_dir( $assoc_args ); @@ -234,8 +244,7 @@ public function create( $args, $assoc_args ) { $this->site_data['alias_domains'] = implode( ',', array_merge( [ $this->site_data['site_url'] ], $alias_domains ) ); - $supported_php_versions = [ 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 'latest' ]; - if ( ! in_array( $this->site_data['php_version'], $supported_php_versions ) ) { + if ( ! in_array( $this->site_data['php_version'], self::SUPPORTED_PHP_VERSIONS ) ) { $old_version = $this->site_data['php_version']; $floor = (int) floor( $this->site_data['php_version'] ); if ( 5 === $floor ) { @@ -244,7 +253,7 @@ public function create( $args, $assoc_args ) { $this->site_data['php_version'] = 7.4; $old_version .= ' yet'; } elseif ( 8 === $floor ) { - $this->site_data['php_version'] = 8.5; + $this->site_data['php_version'] = self::DEFAULT_PHP_VERSION; $old_version .= ' yet'; } else { EE::error( 'Unsupported PHP version: ' . $this->site_data['php_version'] ); diff --git a/src/Site_PHP_Docker.php b/src/Site_PHP_Docker.php index 822ce72..18d2c05 100644 --- a/src/Site_PHP_Docker.php +++ b/src/Site_PHP_Docker.php @@ -65,7 +65,7 @@ public function generate_docker_compose_yml( array $filters = [], $volumes ) { $db['networks'] = $network_default; } // PHP configuration. - $php_image_key = ( 'latest' === $filters['php_version'] ? 'easyengine/php8.5' : 'easyengine/php' . $filters['php_version'] ); + $php_image_key = ( 'latest' === $filters['php_version'] ? 'easyengine/php' . PHP::DEFAULT_PHP_VERSION : 'easyengine/php' . $filters['php_version'] ); $php['service_name'] = [ 'name' => 'php' ]; $php['image'] = [ 'name' => $php_image_key . ':' . $img_versions[ $php_image_key ] ]; From 11665de54ae01df2315f15e51b1c8aa34d7312c1 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Thu, 19 Nov 2026 23:47:25 +0530 Subject: [PATCH 4/4] fix(php): match --php against the supported versions as strings EE's synopsis check compares `--php` loosely with the options Spyc parses from the docblock (floats such as 8.5 next to strings such as '8.0'), so `8`, `8.10`, `08.5`, `8.60` or ` 8.5` pass it. create() compared loosely too and kept such values as they were, so the compose file asked for images like `easyengine/php8` or `easyengine/php8.10`, which have no tag in img-versions.json, and the create failed late. create() now trims the value, casts it to a string (the injected docblock default arrives as the float 8.5) and checks it strictly against `SUPPORTED_PHP_VERSIONS`. Surrounding whitespace is dropped; any other spelling that isn't listed gets the existing fallback prompt (`--php=8` asks to continue with 8.5). A non-numeric value that gets through, such as a bare `--php` or `8.5abc` on PHP 7, is refused as unsupported instead of reaching floor(), which throws a TypeError on PHP 8. The fallback versions are strings as well, so the stored version is always a string such as '8.5'. Carries over the strict check from #113. --- features/COVERAGE.md | 2 +- src/PHP.php | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/features/COVERAGE.md b/features/COVERAGE.md index 891fcd8..ff4b983 100644 --- a/features/COVERAGE.md +++ b/features/COVERAGE.md @@ -35,7 +35,7 @@ Scope: `ee site create --type=php` and everything php-specific (`src/PHP.php`, ` | `--php=` every supported version + `latest` | php-version.feature outline (12 examples, `@slow`) | | `--php` default 8.5 | create.feature "The site row holds the php defaults", "The compose file ..." | | `--php` invalid values | create.feature outline "An unsupported --php value is rejected" (4 examples) | -| `--php` loosely matching values (`8`, `7`, `8.40`, `8.4.1`) | not covered yet: a loose `in_array()` accepts them and the create fails late on a missing image (its outline, 4 examples, comes back with the fix) | +| `--php` loosely matching values (`8`, `7`, `8.40`, `8.4.1`) | not covered: core's synopsis check compares loosely and lets them through (`8.4.1` only on PHP 7), then create() compares as strings and asks whether to continue with the fallback version (8.5, 7.4 or 5.6; `8.4.1` is refused as unsupported). The php type has no `--yes`, so the prompt reads stdin | | `--php=` without `--type` (EE3 compat mapping) | not covered yet: the version is consumed as the EE3 `--php` type flag and dropped (its scenario comes back with the fix) | | EE3 `--mysql` compat flag | create.feature "The legacy --mysql flag creates a php site with a database" | | php 5.6 ini (sendmail) vs msmtp | php-version.feature outline `sendmail` column | diff --git a/src/PHP.php b/src/PHP.php index a2a7c61..61e13c9 100644 --- a/src/PHP.php +++ b/src/PHP.php @@ -34,7 +34,7 @@ class PHP extends EE_Site_Command { const DEFAULT_PHP_VERSION = '8.5'; /** - * Versions `--php` accepts. Keep in sync with the create() docblock options. + * Versions `--php` accepts, as strings for the strict check in create(). Keep in sync with the create() docblock options. */ const SUPPORTED_PHP_VERSIONS = [ '5.6', '7.0', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5', '8.6', 'latest' ]; @@ -221,7 +221,8 @@ public function create( $args, $assoc_args ) { $this->site_data['site_fs_path'] = WEBROOT . $this->site_data['site_url']; $this->cache_type = \EE\Utils\get_flag_value( $assoc_args, 'cache' ); $this->site_data['site_ssl_wildcard'] = \EE\Utils\get_flag_value( $assoc_args, 'wildcard' ); - $this->site_data['php_version'] = \EE\Utils\get_flag_value( $assoc_args, 'php', self::DEFAULT_PHP_VERSION ); + // The dispatcher passes the docblock default as a float, and its loose options check lets through values like '8' or ' 8.5'. + $this->site_data['php_version'] = trim( (string) \EE\Utils\get_flag_value( $assoc_args, 'php', self::DEFAULT_PHP_VERSION ) ); $this->site_data['app_sub_type'] = 'php'; $this->site_data['site_container_fs_path'] = get_public_dir( $assoc_args ); @@ -244,13 +245,13 @@ public function create( $args, $assoc_args ) { $this->site_data['alias_domains'] = implode( ',', array_merge( [ $this->site_data['site_url'] ], $alias_domains ) ); - if ( ! in_array( $this->site_data['php_version'], self::SUPPORTED_PHP_VERSIONS ) ) { + if ( ! in_array( $this->site_data['php_version'], self::SUPPORTED_PHP_VERSIONS, true ) ) { $old_version = $this->site_data['php_version']; - $floor = (int) floor( $this->site_data['php_version'] ); + $floor = is_numeric( $old_version ) ? (int) floor( $old_version ) : 0; if ( 5 === $floor ) { - $this->site_data['php_version'] = 5.6; + $this->site_data['php_version'] = '5.6'; } elseif ( 7 === $floor ) { - $this->site_data['php_version'] = 7.4; + $this->site_data['php_version'] = '7.4'; $old_version .= ' yet'; } elseif ( 8 === $floor ) { $this->site_data['php_version'] = self::DEFAULT_PHP_VERSION;