From 09b368fc47c082812cd4b10ad312d43bd71059e0 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Tue, 24 Nov 2026 15:45:04 +0530 Subject: [PATCH 1/8] fix(site): don't refuse a php update over a container removed since the listing check_config_volume_unused() kept every container whose `docker inspect` failed, so a container removed between `docker ps` and the inspect made `ee site update --php` (and its rollback) refuse with "still mounted by a running container". Such a container is now dropped only when `docker ps -a --filter id=` succeeds and no longer lists it; otherwise the update is still refused. A failed volume listing gets its own message instead of an empty container list. --- src/helper/class-ee-site.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/helper/class-ee-site.php b/src/helper/class-ee-site.php index 3a9a9cd8..ce8e80f0 100644 --- a/src/helper/class-ee-site.php +++ b/src/helper/class-ee-site.php @@ -1136,7 +1136,7 @@ private function stop_php_for_config_change( $php_conf_dir ) { * * @param string $volume Real path of config/php. * - * @throws \Exception When a running container still mounts it. + * @throws \Exception When a running container still mounts it, or the containers that mount it can't be listed. */ private static function check_config_volume_unused( $volume ) { @@ -1144,12 +1144,24 @@ private static function check_config_volume_unused( $volume ) { return; } $users = EE::launch( 'docker ps -q --filter ' . escapeshellarg( 'volume=' . basename( dirname( $volume ) ) ) ); - $ids = preg_split( '/\s+/', trim( $users->stdout ), -1, PREG_SPLIT_NO_EMPTY ); + if ( $users->return_code ) { + $error = trim( $users->stderr ); + throw new \Exception( 'Could not list the containers that mount the php config volume: ' . ( '' === $error ? 'docker ps exited with code ' . $users->return_code : $error ) . '; re-run the update once docker responds.' ); + } + $ids = preg_split( '/\s+/', trim( $users->stdout ), -1, PREG_SPLIT_NO_EMPTY ); // docker ps can still list a container stopped a moment ago; inspect waits for the engine to record the stop. $ids = array_filter( $ids, function ( $id ) { - return 'exited' !== \EE_DOCKER::container_status( $id ); + $status = \EE_DOCKER::container_status( $id ); + if ( false === $status ) { + // inspect also fails for a container removed since the listing; drop it only if a working listing no longer has it. + $all = EE::launch( 'docker ps -aq --no-trunc --filter ' . escapeshellarg( 'id=' . $id ) ); + + return $all->return_code || '' !== trim( $all->stdout ); + } + + return 'exited' !== $status; } ); - if ( $users->return_code || $ids ) { + if ( $ids ) { throw new \Exception( 'The php config volume is still mounted by a running container (' . implode( ', ', $ids ) . '); stop it and re-run the update.' ); } } From f0a7b989df7bfc51ee6a127aff17ae2c60ee8232 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Tue, 24 Nov 2026 15:47:04 +0530 Subject: [PATCH 2/8] fix(ssl): keep --force in every ssl-verify retry hint of a forced renewal Without --force, ssl-verify keeps a certificate that is valid for 35 more days and never finalizes the new order. #530 added --force to the first hint only; the retry hint of ssl-verify itself, the "served over HTTP until" log, the re-run hint after a failed renewal and the one after a rebuilt DNS challenge still left it out. --- src/helper/Site_Letsencrypt.php | 8 ++++---- src/helper/class-ee-site.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/helper/Site_Letsencrypt.php b/src/helper/Site_Letsencrypt.php index 54cf2ffe..b776efe5 100644 --- a/src/helper/Site_Letsencrypt.php +++ b/src/helper/Site_Letsencrypt.php @@ -487,7 +487,7 @@ public function loadDomainCertificates( array $domains ) { return $certificates; } - public function check( Array $domains, $wildcard = false, $preferred_challenge = '' ) { + public function check( Array $domains, $wildcard = false, $preferred_challenge = '', $force = false ) { $is_solver_dns = ( $wildcard || 'dns' === $preferred_challenge ) ? true : false; \EE::debug( ( 'Starting check with solver ' ) . ( $is_solver_dns ? 'dns' : 'http' ) ); if ( $is_solver_dns ) { @@ -535,7 +535,7 @@ public function check( Array $domains, $wildcard = false, $preferred_challenge = if ( $is_solver_dns && empty( get_config_value( 'cloudflare-api-key' ) ) ) { $primary_domain = str_replace( '*.', '', $domains[0] ); \EE::warning( "The previous ACME order for $primary_domain had expired or failed. A fresh DNS-01 challenge was issued and its new TXT record is printed above." ); - \EE::log( "Publish the new TXT record, then re-run: ee site ssl-verify $primary_domain" ); + \EE::log( "Publish the new TXT record, then re-run: ee site ssl-verify $primary_domain" . ( $force ? ' --force' : '' ) ); return false; } @@ -961,7 +961,7 @@ private function executeRenewal( $domain, array $alternativeNames, $email, $forc if ( $this->is_rate_limit_exception( $e ) ) { \EE::warning( 'Let\'s Encrypt rate limit hit for: ' . $domain . '. Please wait before retrying. Ref: https://letsencrypt.org/docs/rate-limits/' ); } - \EE::log( 'You can fix the issue and re-run: ee site ssl-verify ' . $domain ); + \EE::log( 'You can fix the issue and re-run: ee site ssl-verify ' . $domain . ( $force ? ' --force' : '' ) ); return false; } catch ( \Throwable $e ) { @@ -971,7 +971,7 @@ private function executeRenewal( $domain, array $alternativeNames, $email, $forc if ( $this->is_rate_limit_exception( $e ) ) { \EE::warning( 'Let\'s Encrypt rate limit hit for: ' . $domain . '. Please wait before retrying. Ref: https://letsencrypt.org/docs/rate-limits/' ); } - \EE::log( 'You can fix the issue and re-run: ee site ssl-verify ' . $domain ); + \EE::log( 'You can fix the issue and re-run: ee site ssl-verify ' . $domain . ( $force ? ' --force' : '' ) ); return false; } diff --git a/src/helper/class-ee-site.php b/src/helper/class-ee-site.php index ce8e80f0..e969a888 100644 --- a/src/helper/class-ee-site.php +++ b/src/helper/class-ee-site.php @@ -1876,7 +1876,7 @@ protected function www_ssl_wrapper( $containers_to_start = [], $site_enable = fa // A manual DNS-01 challenge keeps site_ssl without a certificate until `ee site ssl-verify` completes it. if ( \EE\Site\Utils\is_le_ssl_pending( $this->site_data['site_url'], $this->site_data['site_ssl'] ) ) { $this->serve_without_https( $containers_to_start ); - EE::log( sprintf( '%1$s is served over HTTP until `ee site ssl-verify %1$s` succeeds.', $this->site_data['site_url'] ) ); + EE::log( sprintf( '%1$s is served over HTTP until `%2$s` succeeds.', $this->site_data['site_url'], $this->ssl_verify_command( $this->site_data['site_url'], $force ) ) ); return; } @@ -2321,7 +2321,7 @@ public function ssl_verify( $args = [], $assoc_args = [], $www_or_non_www = fals $preferred_challenge = get_preferred_ssl_challenge( $domains ); - if ( ! $client->check( $domains, $this->site_data['site_ssl_wildcard'], $preferred_challenge ) ) { + if ( ! $client->check( $domains, $this->site_data['site_ssl_wildcard'], $preferred_challenge, $force ) ) { $is_solver_dns = ( $this->site_data['site_ssl_wildcard'] || 'dns' === $preferred_challenge ) ? true : false; $api_key_present = ! empty( get_config_value( 'cloudflare-api-key' ) ); @@ -2332,7 +2332,7 @@ public function ssl_verify( $args = [], $assoc_args = [], $www_or_non_www = fals } // During a create, update or renewal, the caller says how to retry. if ( ! $called_by_ee ) { - EE::warning( sprintf( 'Check logs and retry `ee site ssl-verify %s` once the issue is resolved.', $this->site_data['site_url'] ) ); + EE::warning( sprintf( 'Check logs and retry `%s` once the issue is resolved.', $this->ssl_verify_command( $this->site_data['site_url'], $force ) ) ); } return false; From 1f3f3fc29c86c1e7b22c51169f0b033d7831ef49 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Tue, 24 Nov 2026 15:49:25 +0530 Subject: [PATCH 3/8] fix(migration): don't index image tags that have no options row The 2018 update_php_config migration read $current_versions[ $img ] for every image in img-versions.json, so images without a recorded tag (compat-scanner, mailhog, php, newrelic-daemon) printed "Undefined array key" on PHP 8 and a notice on 7.4. They still count as changed, as before. --- ...5125012_site-command_update_php_config.php | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/migrations/container/20181105125012_site-command_update_php_config.php b/migrations/container/20181105125012_site-command_update_php_config.php index 311f7d9a..8c8456ce 100644 --- a/migrations/container/20181105125012_site-command_update_php_config.php +++ b/migrations/container/20181105125012_site-command_update_php_config.php @@ -131,11 +131,7 @@ public function up() { $old_img_backup = EE_BACKUP_DIR . '/img-version-old.json'; $this->fs->dumpFile( $old_img_backup, json_encode( $current_versions ) ); - foreach ( $img_versions as $img => $version ) { - if ( $current_versions[ $img ] !== $version ) { - $updated_images[] = $img; - } - } + $updated_images = self::get_updated_images( $img_versions, $current_versions ); $first_execution = false; } @@ -235,6 +231,24 @@ public function up() { } + /** + * @param array $img_versions Image => tag the release pins. + * @param array $current_versions Image => tag in the options table. + * + * @return string[] Images whose tag changes. + */ + private static function get_updated_images( array $img_versions, array $current_versions ) { + $updated_images = []; + foreach ( $img_versions as $img => $version ) { + // An image with no options row counts as changed, as before; without isset() PHP reports the missing key. + if ( ! isset( $current_versions[ $img ] ) || $current_versions[ $img ] !== $version ) { + $updated_images[] = $img; + } + } + + return $updated_images; + } + /** * Bring back the existing old config and path. * From bd024c18215d7996777f6724ce8a68c31d2d5aa0 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Tue, 24 Nov 2026 15:52:25 +0530 Subject: [PATCH 4/8] fix(site): don't re-apply an admin-tools compose file that mounts the EE database When the v4.13.2 admin-tools migration fails for a site, it puts back the old docker-compose-admin.yml, which mounts the EasyEngine database into the site's php and nginx containers, and admin_tools stays 1. Since every site `up` now adds that file, the mount came back on each recreation. Such a file is now left out, with a warning to run `ee admin-tools enable --force`, which renders a current one. --- src/helper/site-utils.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/helper/site-utils.php b/src/helper/site-utils.php index 02af7aec..08e7d3ee 100644 --- a/src/helper/site-utils.php +++ b/src/helper/site-utils.php @@ -826,6 +826,14 @@ function get_site_compose_files( $site_fs_path ) { // `admin-tools disable` leaves docker-compose-admin.yml in place, so the DB flag decides. foreach ( Site::where( 'site_fs_path', $site_fs_path ) as $site ) { if ( ! empty( $site->admin_tools ) ) { + // A failed v4.13.2 admin-tools migration puts back the old file, which mounts the EasyEngine DB into the site. + $admin_compose = @file_get_contents( $site_fs_path . '/docker-compose-admin.yml' ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- a missing file is skipped later. + if ( defined( 'DB' ) && false !== $admin_compose && false !== strpos( $admin_compose, DB ) ) { + EE::warning( sprintf( 'Not applying %1$s/docker-compose-admin.yml: it still mounts the EasyEngine database. Run `ee admin-tools enable %2$s --force` to bring admin-tools back.', $site_fs_path, $site->site_url ) ); + + return []; + } + return [ 'docker-compose-admin.yml' ]; } } From 3a108f13f7d759d70339740f4fa6aca3a34ba0c3 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Tue, 24 Nov 2026 16:33:37 +0530 Subject: [PATCH 5/8] fix(backup): name the saved config and compose files when a restore rollback stops When a rollback failed at the nginx, php config or custom compose step, the message said "No previous site files are staged in ", although the saved configuration in /config-before (or the compose snapshot, which lives outside the stage) was what the next restore still needed. The message now names them, says the database was not changed when its copy was taken but the import hadn't started, and otherwise says the rollback state is kept in the stage. --- src/helper/Site_Backup_Restore.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/helper/Site_Backup_Restore.php b/src/helper/Site_Backup_Restore.php index d831b1e0..235974bc 100644 --- a/src/helper/Site_Backup_Restore.php +++ b/src/helper/Site_Backup_Restore.php @@ -2213,24 +2213,34 @@ private function rollback_unfinished_restore() { /** * @param array $txn Restore transaction. * - * @return string Where an unfinished rollback left the previous site files, and the previous DB once its import had started. + * @return string Where an unfinished rollback left the previous site files, configuration and DB. */ private function describe_rollback_leftovers( array $txn ) { // Describe what is on disk now: the swap may not have started, and the dump may be gone. $parts = []; if ( ! empty( $this->list_dir( $txn['stage'] . '/old' ) ) ) { - $parts[] = sprintf( 'The previous site files still staged are in %s/old', $txn['stage'] ); + $parts[] = sprintf( 'the previous site files still staged are in %s/old', $txn['stage'] ); + } + if ( ( ! empty( $txn['conf'] ) || ! empty( $txn['php_conf'] ) ) && is_dir( $txn['stage'] . '/config-before' ) ) { + $parts[] = sprintf( 'the previous site configuration is saved in %s/config-before', $txn['stage'] ); + } + // Not in the stage, see get_compose_snapshot_dir(). + if ( ! empty( $txn['compose'] ) && is_dir( $this->get_compose_snapshot_dir() ) ) { + $parts[] = sprintf( 'the previous custom docker-compose files are saved in %s', $this->get_compose_snapshot_dir() ); } if ( 'importing' === $txn['db'] ) { $parts[] = is_file( $txn['stage'] . '/db-before.sql' ) ? sprintf( 'the previous database is in %s/db-before.sql', $txn['stage'] ) : 'the copy of the previous database is missing'; + } elseif ( 'saved' === $txn['db'] && is_file( $txn['stage'] . '/db-before.sql' ) ) { + $parts[] = sprintf( 'the database was not changed (a copy taken before the restore is in %s/db-before.sql)', $txn['stage'] ); } if ( empty( $parts ) ) { - return sprintf( 'No previous site files are staged in %s', $txn['stage'] ); + return sprintf( 'The rollback state is kept in %s', $txn['stage'] ); } + $last = array_pop( $parts ); - return ucfirst( implode( ' and ', $parts ) ); + return ucfirst( empty( $parts ) ? $last : implode( ', ', $parts ) . ' and ' . $last ); } /** From 1cb769aa710b8a4aaea028b05ec0e1e21057c3ab Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Tue, 24 Nov 2026 16:35:48 +0530 Subject: [PATCH 6/8] fix(backup): remove the session settings copy when a restore is rolled back A restore that drops session.sid_length and session.sid_bits_per_character saves the backup's php.ini under EE_BACKUP_DIR/session-sid-settings-