Description
Bug Report
- Yes, I reviewed the contribution guidelines.
- Yes, more specifically, I reviewed the guidelines on how to write clear bug reports.
Describe the current, buggy behavior
I am working on automatic WP deploy using deployer and GH Actions. The first task in my deploy process is to setup the wp-config.php
, then build the theme, upload it, symlink the current release, and at the end I'm making a check for plugin and core updates using WP-CLI.
In the last part of the deployer task that checks the core and plugins, I added
$isInstalled = run('~/bin/wp core is-installed | echo $?');
This will set the variable $isInstalled
to 0 if the core is installed, and 1 if not. In the case it's 1 I do
if ($isInstalled === '1') {
$host = get('hostname');
run("~/bin/wp core install --url={$host} --title={$appName} --admin_user={$adminUser} --admin_email={$adminEmail}");
}
Then after that, I have
$currentCoreVersion = run('~/bin/wp core version');
writeln('<comment>Checking WordPress core version</comment>');
if ($coreVersion !== $currentCoreVersion) {
run("~/bin/wp core update --version='{$coreVersion}' --force");
writeln('<info>WordPress core updated</info>');
}
This will check the current core version, and compare it to the version I have set during my deployment process ($coreVersion
variable). In my case, the $coreVersion
was set to 5.7, and the $currentCoreVersion
was 5.6, so the conditional was true and I tried to update my WP core. But I got the error that WP is not installed, because the tables weren't set yet in the DB.
So in the end the command wp core is-installed
doesn't do a good job really. Not sure why tho, because the is_blog_installed()
function should return false (or maybe it doesn't because of all the error suppressions 🤷🏼♂️ ).
Describe how other contributors can replicate this bug
- Locally download core (
wp core download --version=5.6
) - Set up
wp-config.php
that will point to empty DB (wp config create
) - Try to run
wp core update
and see the error
More so, even after just downloading the core the command
wp core is-installed | echo $?
Will return
0
Error: 'wp-config.php' not found.
Either create one manually or use `wp config create`.
So it says that it's installed but the config is missing, after creating the config it returns 0, but there are still no DB tables.
Describe what you would expect as the correct outcome
It would be good to throw 1 as long as there are no DB tables present. The command should be more robust. That way it will be easier to use them in CI/CD pipelines.
Let us know what environment you are running this on
Local:
OS: Darwin 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64
Shell: /bin/zsh
PHP binary: /usr/local/Cellar/php@7.4/7.4.16/bin/php
PHP version: 7.4.16
php.ini used: /usr/local/etc/php/7.4/php.ini
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /Users/denis.zoljom/Desktop/example
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.4.0
Ubuntu:
OS: Linux 5.4.0-1037-aws #39-Ubuntu SMP Thu Jan 14 02:56:06 UTC 2021 x86_64
Shell: /bin/bash
PHP binary: /usr/bin/php7.4
PHP version: 7.4.13
php.ini used: /etc/php/7.4/cli/php.ini
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /home/denisjezakon
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.4.0