From c24fce79f7a276ae8ab17054f6ae8e03de76ea53 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Wed, 26 Oct 2016 14:53:18 -0700 Subject: [PATCH 1/2] Ensure `WP_INSTALLING` is set for `wp core update-db` Core's `wp-admin/upgrade.php` sets this constant, so we should too. --- features/core-update-db.feature | 16 ++++++++++++++++ php/WP_CLI/Runner.php | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/features/core-update-db.feature b/features/core-update-db.feature index 88b48b7ce7..7ad9fc2f24 100644 --- a/features/core-update-db.feature +++ b/features/core-update-db.feature @@ -88,3 +88,19 @@ Feature: Update core's database """ Success: WordPress database upgraded on 3/3 sites. """ + + Scenario: Ensure update-db sets WP_INSTALLING constant + Given a WP install + And a before.php file: + """ + cmd_starts_with( array( 'core', 'is-installed' ) ) ) { + if ( $this->cmd_starts_with( array( 'core', 'is-installed' ) + || $this->cmd_starts_with( array( 'core', 'update-db' ) ) ) ) { define( 'WP_INSTALLING', true ); } From c8efe12d9ad67beb1eb089a0a4a14c6c0c2d4304 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Wed, 26 Oct 2016 16:33:21 -0700 Subject: [PATCH 2/2] Fix conditional. Fortunately, this caused a lot of tests to break. --- php/WP_CLI/Runner.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/php/WP_CLI/Runner.php b/php/WP_CLI/Runner.php index 352c9b2838..34d60cdff1 100644 --- a/php/WP_CLI/Runner.php +++ b/php/WP_CLI/Runner.php @@ -875,8 +875,8 @@ public function start() { exit; } - if ( $this->cmd_starts_with( array( 'core', 'is-installed' ) - || $this->cmd_starts_with( array( 'core', 'update-db' ) ) ) ) { + if ( $this->cmd_starts_with( array( 'core', 'is-installed' ) ) + || $this->cmd_starts_with( array( 'core', 'update-db' ) ) ) { define( 'WP_INSTALLING', true ); }