From 8918cc75c13dc42f6385b58936761c4bc9ddc158 Mon Sep 17 00:00:00 2001 From: Brendan Heywood Date: Thu, 28 Mar 2019 23:10:53 +1100 Subject: [PATCH] MDL-65208 admin: Add upgrade cli --is-pending option --- admin/cli/upgrade.php | 9 ++++++++- lang/en/admin.php | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/admin/cli/upgrade.php b/admin/cli/upgrade.php index 8e439c5a8e8b4..d827e6d87c17b 100644 --- a/admin/cli/upgrade.php +++ b/admin/cli/upgrade.php @@ -52,7 +52,8 @@ 'allow-unstable' => false, 'help' => false, 'lang' => $lang, - 'verbose-settings' => false + 'verbose-settings' => false, + 'is-pending' => false, ), array( 'h' => 'help' @@ -88,6 +89,8 @@ --verbose-settings Show new settings values. By default only the name of new core or plugin settings are displayed. This option outputs the new values as well as the setting name. +--is-pending If an upgrade is needed it exits with an error code of + 2 so it distinct from other types of errors. -h, --help Print out this help Example: @@ -116,6 +119,10 @@ cli_error(get_string('cliupgradenoneed', 'core_admin', $newversion), 0); } +if ($options['is-pending']) { + cli_error(get_string('cliupgradepending', 'core_admin'), 2); +} + // Test environment first. list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE); if (!$envstatus) { diff --git a/lang/en/admin.php b/lang/en/admin.php index 26c89616de33b..40b864a60789d 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -132,6 +132,7 @@ $string['cliupgradedefaultverbose'] = 'New setting: {$a->name}, Default value: {$a->defaultsetting}'; $string['cliupgradefinished'] = 'Command line upgrade from {$a->oldversion} to {$a->newversion} completed successfully.'; $string['cliupgradenoneed'] = 'No upgrade needed for the installed version {$a}. Thanks for coming anyway!'; +$string['cliupgradepending'] = 'An upgrade is pending'; $string['cliyesnoprompt'] = 'type y (means yes) or n (means no)'; $string['commentsperpage'] = 'Comments displayed per page'; $string['commonactivitysettings'] = 'Common activity settings';