MDL-30929 detect incorrect major version upgrades

This commit is contained in:
Petr Skoda 2012-01-01 17:24:36 +01:00
parent 60e99097e4
commit 9008ec1654
4 changed files with 66 additions and 0 deletions

View file

@ -257,6 +257,41 @@ function upgrade_plugin_savepoint($result, $version, $type, $plugin, $allowabort
}
}
/**
* Detect if there are leftovers in PHP source files.
*
* During main version upgrades administrators MUST move away
* old PHP source files and start from scratch (or better
* use git).
*
* @return bool true means borked upgrade, false means previous PHP files were properly removed
*/
function upgrade_stale_php_files_present() {
global $CFG;
$someexamplesofremovedfiles = array(
// removed in 2.2dev
'/lib/yui/3.4.1pr1/',
// removed in 2.2
'/search/cron_php5.php',
'/course/report/log/indexlive.php',
'/admin/report/backups/index.php',
'/admin/generator.php',
// removed in 2.1
'/lib/yui/2.8.0r4/',
// removed in 2.0
'/blocks/admin/block_admin.php',
'/blocks/admin_tree/block_admin_tree.php',
);
foreach ($someexamplesofremovedfiles as $file) {
if (file_exists($CFG->dirroot.$file)) {
return true;
}
}
return false;
}
/**
* Upgrade plugins