Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ ee site create --type=wp <site-name> [--cache] [--vip] [--mu=<subdir>] [--mu=<su
Enable cache with local redis container.

[--php=<php-version>]
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
Expand All @@ -73,6 +73,7 @@ ee site create --type=wp <site-name> [--cache] [--vip] [--mu=<subdir>] [--mu=<su
- 8.3
- 8.4
- 8.5
- 8.6
- latest
---

Expand Down Expand Up @@ -255,9 +256,9 @@ ee site info --type=wp <site-name> [--cache] [--vip] [--mu=<subdir>] [--mu=<subd
Enable cache with local redis container.

[--php=<php-version>]
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
Expand All @@ -270,6 +271,7 @@ ee site info --type=wp <site-name> [--cache] [--vip] [--mu=<subdir>] [--mu=<subd
- 8.3
- 8.4
- 8.5
- 8.6
Comment thread
mrrobot47 marked this conversation as resolved.
Resolved
- latest
---

Expand Down Expand Up @@ -536,9 +538,9 @@ ee site reload --type=wp <site-name> [--cache] [--vip] [--mu=<subdir>] [--mu=<su
Enable cache with local redis container.

[--php=<php-version>]
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
Expand All @@ -551,6 +553,7 @@ ee site reload --type=wp <site-name> [--cache] [--vip] [--mu=<subdir>] [--mu=<su
- 8.3
- 8.4
- 8.5
- 8.6
- latest
---

Expand Down Expand Up @@ -680,9 +683,9 @@ ee site restart --type=wp <site-name> [--cache] [--vip] [--mu=<subdir>] [--mu=<s
Enable cache with local redis container.

[--php=<php-version>]
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
Expand All @@ -695,6 +698,7 @@ ee site restart --type=wp <site-name> [--cache] [--vip] [--mu=<subdir>] [--mu=<s
- 8.3
- 8.4
- 8.5
- 8.6
- latest
---

Expand Down
2 changes: 1 addition & 1 deletion features/COVERAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` (all 12 options) | 8.4 default and update to 8.2: php-version: Default PHP version and update…; 8.3, 8.5, latest: Create a site on PHP <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): 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 <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… |
Expand Down
8 changes: 4 additions & 4 deletions features/php-version.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions features/site.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 | <empty> |
| php_version | 8.4 |
| php_version | 8.5 |
| db_host | global-db |
| db_port | 3306 |
| db_name | bh_site_type_wp_basic_test |
Expand Down Expand Up @@ -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
Expand All @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/Site_WP_Docker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] ];
Expand Down
35 changes: 23 additions & 12 deletions src/WordPress.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -139,9 +149,9 @@ public function __construct() {
* : Set custom source directory for site inside htdocs.
*
* [--php=<php-version>]
* : 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
Expand All @@ -153,7 +163,8 @@ public function __construct() {
* - 8.2
* - 8.3
* - 8.4
* - 8.5
* - 8.5
* - 8.6
* - latest
* ---
*
Expand Down Expand Up @@ -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', '' );
Expand Down Expand Up @@ -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 );
Expand Down