From 5163f1e6bd86e17bc1f7c839c418b4627776e4bc Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Wed, 20 Jan 2021 21:51:21 +0000 Subject: [PATCH] MDL-69460 admin: prevent CLI upgrade when stale files present. --- admin/cli/upgrade.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/admin/cli/upgrade.php b/admin/cli/upgrade.php index 12904e5a035..cbfa2be6401 100644 --- a/admin/cli/upgrade.php +++ b/admin/cli/upgrade.php @@ -135,6 +135,15 @@ if (!$envstatus) { exit(1); } +// Make sure there are no files left over from previous versions. +if (upgrade_stale_php_files_present()) { + cli_problem(get_string('upgradestalefiles', 'admin')); + + // Stale file info contains HTML elements which aren't suitable for CLI. + $upgradestalefilesinfo = get_string('upgradestalefilesinfo', 'admin', get_docs_url('Upgrading')); + cli_error(strip_tags($upgradestalefilesinfo)); +} + // Test plugin dependencies. $failed = array(); if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed, $CFG->branch)) {