Commit 775f811a authored by skodak's avatar skodak
Browse files

MDL-16002 rewritten upgrade locking and better upgrade progress tracking;...

MDL-16002 rewritten upgrade locking and better upgrade progress tracking; MDL-16070 Do not use $a[0] syntax in lang packs + various other upgrade improvements and fixes
parent 9deded34
......@@ -33,7 +33,7 @@ if ($frm = data_submitted() and confirm_sesskey()) {
$plugin = "auth/$auth";
$name = $matches[1];
if (!set_config($name, $value, $plugin)) {
print_error("cannotsaveconfig", 'error', '', array($name, $value, $plugin));
print_error("cannotsaveconfig", 'error', '', (object)array('name'=>$name, 'value'=>$value, 'plugin'=>$plugin));
}
}
}
......
......@@ -819,9 +819,6 @@ if ( file_exists(dirname(dirname(__FILE__)) . '/config.php')) {
$DB->get_manager()->install_from_xmldb_file("$CFG->libdir/db/install.xml"); //New method
// all new installs are in unicode - keep for backwards compatibility and 1.8 upgrade checks
set_config('unicodedb', 1);
/// Continue with the instalation
// Install the roles system.
......@@ -868,12 +865,6 @@ if ( file_exists(dirname(dirname(__FILE__)) . '/config.php')) {
if ($CFG->version) {
if ($version > $CFG->version) { // upgrade
/// If the database is not already Unicode then we do not allow upgrading!
/// Instead, we print an error telling them to upgrade to 1.7 first. MDL-6857
if (empty($CFG->unicodedb)) {
console_write(STDERR,'unicodeupgradeerror', 'error');
}
$a->oldversion = "$CFG->release ($CFG->version)";
$a->newversion = "$release ($version)";
$strdatabasechecking = get_string("databasechecking", "", $a);
......
......@@ -14,30 +14,20 @@
die;
}
/// Turn off time limits and try to flush everything all the time, sometimes upgrades can be slow.
@set_time_limit(0);
/// try to flush everything all the time
@ob_implicit_flush(true);
while(@ob_end_clean()); // ob_end_flush prevents sending of headers
require_once('../config.php');
require('../config.php');
require_once($CFG->libdir.'/adminlib.php'); // Contains various admin-only functions
require_once($CFG->libdir.'/db/upgradelib.php'); // Upgrade-related functions
$id = optional_param('id', '', PARAM_TEXT);
$confirmupgrade = optional_param('confirmupgrade', 0, PARAM_BOOL);
$confirmrelease = optional_param('confirmrelease', 0, PARAM_BOOL);
$confirmplugins = optional_param('confirmplugincheck', 0, PARAM_BOOL);
$agreelicense = optional_param('agreelicense', 0, PARAM_BOOL);
$autopilot = optional_param('autopilot', 0, PARAM_BOOL);
$ignoreupgradewarning = optional_param('ignoreupgradewarning', 0, PARAM_BOOL);
$confirmplugincheck = optional_param('confirmplugincheck', 0, PARAM_BOOL);
/// check upgrade status first
if ($ignoreupgradewarning) {
$SESSION->upgraderunning = 0;
}
upgrade_check_running("Upgrade already running in this session, please wait!<br />Click on the exclamation marks to ignore this warning (<a href=\"index.php?ignoreupgradewarning=1\">!!!</a>).", 10);
/// set install/upgrade autocontinue session flag
if ($autopilot) {
......@@ -49,15 +39,15 @@
$documentationlink = '<a href="http://docs.moodle.org/en/Installation">Installation docs</a>';
if (ini_get_bool('session.auto_start')) {
print_error('phpvaroff', 'debug', '', array('session.auto_start', $documentationlink));
print_error('phpvaroff', 'debug', '', (object)array('name'=>'session.auto_start', 'link'=>$documentationlink));
}
if (ini_get_bool('magic_quotes_runtime')) {
print_error('phpvaroff', 'debug', '', array('magic_quotes_runtime', $documentationlink));
print_error('phpvaroff', 'debug', '', (object)array('name'=>'magic_quotes_runtime', 'link'=>$documentationlink));
}
if (!ini_get_bool('file_uploads')) {
print_error('phpvaron', 'debug', '', array('file_uploads', $documentationlink));
print_error('phpvaron', 'debug', '', (object)array('name'=>'file_uploads', 'link'=>$documentationlink));
}
/// Check that config.php has been edited
......@@ -71,7 +61,7 @@
$dirroot = dirname(realpath("../index.php"));
if (!empty($dirroot) and $dirroot != $CFG->dirroot) {
print_error('fixsetting', 'debug', '', array($CFG->dirroot, $dirroot));
print_error('fixsetting', 'debug', '', (object)array('current'=>$CFG->dirroot, 'found'=>$dirroot));
}
/// Set some necessary variables during set-up to avoid PHP warnings later on this page
......@@ -85,9 +75,9 @@
$CFG->version = "";
}
if (is_readable("$CFG->dirroot/version.php")) {
include_once("$CFG->dirroot/version.php"); // defines $version
}
$version = null;
$release = null;
include("$CFG->dirroot/version.php"); // defines $version and $release
if (!$version or !$release) {
print_error('withoutversion', 'debug'); // without version, stop
......@@ -99,9 +89,7 @@
} else { // Check for missing main tables
$maintables = true;
$mtables = array("config", "course", "course_categories", "course_modules",
"course_sections", "log", "log_display", "modules",
"user");
$mtables = array('config', 'course', 'groupings'); // some tables used in 1.9 and 2.0, preferable something from the start and end of install.xml
foreach ($mtables as $mtable) {
if (!in_array($mtable, $tables)) {
$maintables = false;
......@@ -109,8 +97,10 @@
}
}
}
unset($mtables);
unset($tables);
if (! $maintables) {
if (!$maintables) {
/// hide errors from headers in case debug enabled in config.php
$origdebug = $CFG->debug;
$CFG->debug = DEBUG_MINIMAL;
......@@ -156,9 +146,6 @@
upgrade_log_start();
$DB->set_debug(true);
/// Both old .sql files and new install.xml are supported
/// But we prioritise install.xml (XMLDB) if present
if (!$DB->setup_is_unicodedb()) {
if (!$DB->change_db_encoding()) {
// If could not convert successfully, throw error, and prevent installation
......@@ -166,15 +153,9 @@
}
}
$DB->get_manager()->install_from_xmldb_file("$CFG->libdir/db/install.xml"); //New method
// all new installs are in unicode - keep for backwards compatibility and 1.8 upgrade checks
set_config('unicodedb', 1);
$DB->get_manager()->install_from_xmldb_file("$CFG->libdir/db/install.xml");
/// Continue with the instalation
$DB->set_debug(false);
/// Groups install is now in core above.
// Install the roles system.
moodle_install_roles();
......@@ -183,7 +164,6 @@
events_update_definition();
// Install core message providers
require_once($CFG->libdir .'/messagelib.php'); // Messagelib functions
message_update_providers();
/// This is used to handle any settings that must exist in $CFG but which do not exist in
......@@ -201,29 +181,39 @@
// (this should only have any effect during initial install).
admin_apply_default_settings(NULL, true);
notify($strdatabasesuccess, "green");
// store main version
if (!set_config('version', $version)) {
print_error('cannotupdateversion', 'debug');
}
notify($strdatabasesuccess, 'notifysuccess');
/// do not show certificates in log ;-)
$DB->set_debug(false);
// hack - set up mnet
require_once $CFG->dirroot.'/mnet/lib.php';
print_continue('index.php');
print_footer('none');
die;
}
/// Check version of Moodle code on disk compared with database
/// and upgrade if possible.
require_once("$CFG->dirroot/lib/db/upgrade.php"); # defines new upgrades
$stradministration = get_string("administration");
$stradministration = get_string('administration');
if (empty($CFG->version)) {
print_error('missingconfigversion', 'debug');
}
if ($CFG->version) {
if ($version > $CFG->version) { // upgrade
/// If the database is not already Unicode then we do not allow upgrading!
/// Instead, we print an error telling them to upgrade to 1.7 first. MDL-6857
if (empty($CFG->unicodedb)) {
print_error('unicodeupgradeerror', 'error', '', $version);
}
require_once($CFG->libdir.'/db/upgrade.php'); // Defines upgrades
require_once($CFG->libdir.'/db/upgradelib.php'); // Upgrade-related functions
$a->oldversion = "$CFG->release ($CFG->version)";
$a->newversion = "$release ($version)";
......@@ -280,7 +270,7 @@
print_footer('none');
die;
} elseif (empty($confirmplugincheck)) {
} elseif (empty($confirmplugins)) {
$strplugincheck = get_string('plugincheck');
$navigation = build_navigation(array(array('name'=>$strplugincheck, 'link'=>null, 'type'=>'misc')));
print_header($strplugincheck, $strplugincheck, $navigation, "", "", false, "&nbsp;", "&nbsp;");
......@@ -305,6 +295,7 @@
die();
} else {
$strdatabasesuccess = get_string("databasesuccess");
$navigation = build_navigation(array(array('name'=>$strdatabasesuccess, 'link'=>null, 'type'=>'misc')));
print_header($strdatabasechecking, $stradministration, $navigation,
......@@ -340,7 +331,6 @@
events_update_definition();
// Update core message providers
require_once($CFG->libdir .'/messagelib.php'); // Messagelib functions
message_update_providers();
if (set_config("version", $version)) {
......@@ -366,11 +356,6 @@
notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
upgrade_log_finish();
}
} else {
if (!set_config("version", $version)) {
print_error('cannotupdateversion', 'debug');
}
}
/// Updated human-readable release version if necessary
......@@ -380,9 +365,6 @@
}
}
/// Groups install/upgrade is now in core above.
/// Find and check all main modules and load them up or upgrade them if necessary
/// first old *.php update and then the new upgrade.php script
upgrade_activity_modules("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
......
......@@ -404,7 +404,7 @@
if ($location || $plugin) {
// file in an extra location
if ($currentfile != "{$prefix}{$plugin}.php") {
print_error('filemismatch', 'error', '', array($currectfile, $prefix, $plugin));
print_error('filemismatch', 'error', '', (object)array('current'=>$currectfile, 'file'=>$prefix.$plugin.'.php'));
}
if (!$uselocal) {
notify($streditingnoncorelangfile);
......@@ -413,7 +413,7 @@
} else {
// file in standard location
if ($currentfile != $filename) {
print_error('filemismatch', 'error', '', array($currectfile, $filename, ''));
print_error('filemismatch', 'error', '', (object)array('current'=>$currectfile, 'file'=>$filename.'.php'));
}
}
......@@ -467,7 +467,7 @@
if (lang_save_file($saveinto, $currentfile, $newstrings, $uselocal, $packstring)) {
notify(get_string("changessaved")." ($saveinto/$currentfile)", "notifysuccess");
} else {
print_error('cannotsavefile', 'error', 'lang.php?mode=compare&amp;currentfile=$currentfile', array($saveinto, $currentfile));
print_error('cannotsavefile', 'error', 'lang.php?mode=compare&amp;currentfile=$currentfile', $saveinto.'/'.$currentfile);
}
unset($packstring);
}
......
......@@ -15,8 +15,8 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
// Completion system
require_once($CFG->libdir.'/completionlib.php');
$temp->add(new admin_setting_configcheckbox('enablecompletion',get_string('enablecompletion','completion'),get_string('configenablecompletion','completion'),COMPLETION_DISABLED));
$temp->add(new admin_setting_pickroles('progresstrackedroles',get_string('progresstrackedroles','completion'),get_string('configprogresstrackedroles','completion')));
$temp->add(new admin_setting_configcheckbox('enablecompletion', get_string('enablecompletion','completion'), get_string('configenablecompletion','completion'), COMPLETION_DISABLED));
$temp->add(new admin_setting_pickroles('progresstrackedroles', get_string('progresstrackedroles','completion'), get_string('configprogresstrackedroles', 'completion'), array('moodle/legacy:student')));
$ADMIN->add('misc', $temp);
......
......@@ -16,11 +16,14 @@
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
function xmldb_backup_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
function xmldb_backup_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
......
......@@ -16,11 +16,14 @@
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
function xmldb_block_activity_modules_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
function xmldb_block_activity_modules_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
......
......@@ -16,11 +16,14 @@
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
function xmldb_block_admin_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
function xmldb_block_admin_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
......
......@@ -16,11 +16,14 @@
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
function xmldb_block_calendar_month_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
function xmldb_block_calendar_month_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
......
......@@ -16,11 +16,14 @@
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
function xmldb_block_calendar_upcoming_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
function xmldb_block_calendar_upcoming_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
......
......@@ -16,11 +16,14 @@
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
function xmldb_block_course_list_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
function xmldb_block_course_list_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
......
......@@ -16,11 +16,14 @@
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
function xmldb_block_course_summary_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
function xmldb_block_course_summary_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
......
......@@ -16,13 +16,14 @@
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
function xmldb_blocks_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
function xmldb_blocks_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
......
......@@ -16,11 +16,14 @@
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
function xmldb_block_news_items_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
function xmldb_block_news_items_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
......
......@@ -16,11 +16,14 @@
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
function xmldb_block_online_users_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
function xmldb_block_online_users_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
......
......@@ -16,11 +16,14 @@
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
function xmldb_block_participants_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
function xmldb_block_participants_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
......
......@@ -16,11 +16,14 @@
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
function xmldb_block_recent_activity_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
function xmldb_block_recent_activity_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
......
......@@ -16,11 +16,14 @@
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
function xmldb_block_rss_client_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
function xmldb_block_rss_client_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
......
......@@ -107,12 +107,11 @@ $defaultfiletypes = "PDF,TXT,HTML,PPT,XML,DOC,HTM";
if(isset($CFG->block_search_pdf_to_text_cmd)) {
p($CFG->block_search_pdf_to_text_cmd);
} else {
$encoding = ($CFG->unicodedb) ? "-enc UTF-8" : "-enc ISO-8859-1" ;
if ($CFG->ostype == 'WINDOWS'){
p("lib/xpdf/win32/pdftotext.exe -eol dos $encoding -q");
p("lib/xpdf/win32/pdftotext.exe -eol dos -enc UTF-8 -q");
}
else{
p("lib/xpdf/linux/pdftotext $encoding -eol unix -q");
p("lib/xpdf/linux/pdftotext -enc UTF-8 -eol unix -q");
}
} ?>"/><br/><br/>
</td>
......
......@@ -16,11 +16,14 @@
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
function xmldb_block_search_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
function xmldb_block_search_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment