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..ff4b983 100644 --- a/features/COVERAGE.md +++ b/features/COVERAGE.md @@ -33,9 +33,9 @@ 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` 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 | @@ -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 883fe39..61e13c9 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, 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' ]; + /** * @var string $cache_type Type of caching being used. */ @@ -88,9 +98,9 @@ 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 + * default: 8.5 * options: * - 5.6 * - 7.0 @@ -102,7 +112,8 @@ public function __construct() { * - 8.2 * - 8.3 * - 8.4 - * - 8.5 + * - 8.5 + * - 8.6 * - latest * --- * @@ -210,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' ); + // 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 ); @@ -233,17 +245,16 @@ 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' ]; - if ( ! in_array( $this->site_data['php_version'], $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'] = 8.4; + $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 9c9184e..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.4' : '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 ] ];