diff --git a/README.md b/README.md index fd5c96c..2698915 100644 --- a/README.md +++ b/README.md @@ -58,9 +58,9 @@ ee site create --type=wp [--cache] [--vip] [--mu=] [--mu=] - 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 @@ -73,6 +73,7 @@ ee site create --type=wp [--cache] [--vip] [--mu=] [--mu= [--cache] [--vip] [--mu=] [--mu=] - 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 @@ -270,6 +271,7 @@ ee site info --type=wp [--cache] [--vip] [--mu=] [--mu= [--cache] [--vip] [--mu=] [--mu=] - 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 @@ -551,6 +553,7 @@ ee site reload --type=wp [--cache] [--vip] [--mu=] [--mu= [--cache] [--vip] [--mu=] [--mu=] - 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 @@ -695,6 +698,7 @@ ee site restart --type=wp [--cache] [--vip] [--mu=] [--mu=; 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): not covered yet: versions are compared loosely, so `--php=8` passes validation (its outline 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) | | `--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 0e04b05..fa2c048 100644 --- a/features/php-version.feature +++ b/features/php-version.feature @@ -4,8 +4,8 @@ Feature: PHP versions of WordPress sites (--php on create and update) Given a WordPress site 'bh-site-type-wp-php.test' exists Then the site 'bh-site-type-wp-php.test' info should contain: | field | value | - | php_version | 8.4 | - And the 'php' container of site 'bh-site-type-wp-php.test' should use image 'easyengine/php8.4:' + | php_version | 8.5 | + And the 'php' container of site 'bh-site-type-wp-php.test' should use image 'easyengine/php8.5:' When I run 'bin/ee site update bh-site-type-wp-php.test --php=8.2' Then the command should succeed And STDOUT should contain: @@ -19,7 +19,7 @@ Feature: PHP versions of WordPress sites (--php on create and update) | field | value | | php_version | 8.2 | And the 'php' container of site 'bh-site-type-wp-php.test' should use image 'easyengine/php8.2:' - And the directory '{SITES_DIR}/bh-site-type-wp-php.test/.backup/config/php-8.4' should exist + And the directory '{SITES_DIR}/bh-site-type-wp-php.test/.backup/config/php-8.5' should exist And the file '{SITES_DIR}/bh-site-type-wp-php.test/config/php/php/conf.d/custom.ini' should contain: """ sendmail_path = /usr/bin/msmtp -t @@ -69,7 +69,7 @@ Feature: PHP versions of WordPress sites (--php on create and update) | php | name | image | runtime | | 8.3 | 83 | php8.3 | 8.3. | | 8.5 | 85 | php8.5 | 8.5. | - | latest | latest | php8.4 | 8.4. | + | latest | latest | 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/features/site.feature b/features/site.feature index a1e285d..8ba5a1c 100644 --- a/features/site.feature +++ b/features/site.feature @@ -89,7 +89,7 @@ Feature: WordPress site lifecycle (create, info, list, enable/disable, restart/r | cache_mysql_query | 0 | | cache_app_object | 0 | | cache_host | | - | php_version | 8.4 | + | php_version | 8.5 | | db_host | global-db | | db_port | 3306 | | db_name | bh_site_type_wp_basic_test | @@ -141,7 +141,7 @@ Feature: WordPress site lifecycle (create, info, list, enable/disable, restart/r """ And the file '{SITES_DIR}/bh-site-type-wp-basic.test/docker-compose.yml' should contain: """ - image: easyengine/php8.4: + image: easyengine/php8.5: - VIRTUAL_HOST - VIRTUAL_PATH=/ - HSTS=off @@ -161,7 +161,7 @@ Feature: WordPress site lifecycle (create, info, list, enable/disable, restart/r And the 'mailhog' container of site 'bh-site-type-wp-basic.test' should not exist And the 'db' container of site 'bh-site-type-wp-basic.test' should not exist And the 'redis' container of site 'bh-site-type-wp-basic.test' should not exist - And the 'php' container of site 'bh-site-type-wp-basic.test' should use image 'easyengine/php8.4:' + And the 'php' container of site 'bh-site-type-wp-basic.test' should use image 'easyengine/php8.5:' And the 'php' container of site 'bh-site-type-wp-basic.test' should have restart policy 'always' And the 'php' container of site 'bh-site-type-wp-basic.test' should be connected to network 'ee-global-backend-network' And the 'nginx' container of site 'bh-site-type-wp-basic.test' should be connected to network 'ee-global-frontend-network' diff --git a/src/Site_WP_Docker.php b/src/Site_WP_Docker.php index b35b2a0..05072ad 100644 --- a/src/Site_WP_Docker.php +++ b/src/Site_WP_Docker.php @@ -67,7 +67,7 @@ public function generate_docker_compose_yml( array $filters = [], $volumes ) { } // 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' . WordPress::DEFAULT_PHP_VERSION : 'easyengine/php' . $filters['php_version'] ); $php['service_name'] = [ 'name' => 'php' ]; $php['image'] = [ 'name' => $php_image_key . ':' . $img_versions[ $php_image_key ] ]; diff --git a/src/WordPress.php b/src/WordPress.php index 6b12c27..6685328 100644 --- a/src/WordPress.php +++ b/src/WordPress.php @@ -26,6 +26,16 @@ */ class WordPress 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. */ @@ -139,9 +149,9 @@ public function __construct() { * : Set custom source directory for site inside htdocs. * * [--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 @@ -153,7 +163,8 @@ public function __construct() { * - 8.2 * - 8.3 * - 8.4 - * - 8.5 + * - 8.5 + * - 8.6 * - latest * --- * @@ -326,7 +337,8 @@ public function create( $args, $assoc_args ) { $this->cache_type = \EE\Utils\get_flag_value( $assoc_args, 'cache' ); $wildcard_flag = \EE\Utils\get_flag_value( $assoc_args, 'wildcard' ); $this->site_data['site_ssl_wildcard'] = 'subdom' === $this->site_data['app_sub_type'] || $wildcard_flag ? true : false; - $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_admin_url'] = \EE\Utils\get_flag_value( $assoc_args, 'title', $this->site_data['site_url'] ); $this->site_data['app_admin_username'] = \EE\Utils\get_flag_value( $assoc_args, 'admin-user', \EE\Utils\random_name_generator() ); $this->site_data['app_admin_password'] = \EE\Utils\get_flag_value( $assoc_args, 'admin-pass', '' ); @@ -385,19 +397,18 @@ public function create( $args, $assoc_args ) { $site_domains = ( 'subdom' === $this->site_data['app_sub_type'] ) ? [ $this->site_data['site_url'], '*.' . $this->site_data['site_url'] ] : [ $this->site_data['site_url'] ]; $this->site_data['alias_domains'] = implode( ',', array_merge( $site_domains, $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; - $old_version .= ' yet'; - } else { + $this->site_data['php_version'] = self::DEFAULT_PHP_VERSION; + $old_version .= ' yet'; + } else { EE::error( 'Unsupported PHP version: ' . $this->site_data['php_version'] ); } \EE::confirm( sprintf( 'EEv4 does not support PHP %s. Continue with PHP %s?', $old_version, $this->site_data['php_version'] ), $assoc_args );