mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-27767 install: Shows notifications rather than throwing exceptions when installation encounters unexpected id for guest or admin
This commit is contained in:
parent
42f6b3f1d7
commit
3912cdd1de
1 changed files with 9 additions and 4 deletions
|
@ -27,7 +27,7 @@
|
||||||
defined('MOODLE_INTERNAL') || die();
|
defined('MOODLE_INTERNAL') || die();
|
||||||
|
|
||||||
function xmldb_main_install() {
|
function xmldb_main_install() {
|
||||||
global $CFG, $DB, $SITE;
|
global $CFG, $DB, $SITE, $OUTPUT;
|
||||||
|
|
||||||
/// Make sure system context exists
|
/// Make sure system context exists
|
||||||
$syscontext = context_system::instance(0, MUST_EXIST, false);
|
$syscontext = context_system::instance(0, MUST_EXIST, false);
|
||||||
|
@ -178,7 +178,7 @@ function xmldb_main_install() {
|
||||||
$guest->timemodified= time();
|
$guest->timemodified= time();
|
||||||
$guest->id = $DB->insert_record('user', $guest);
|
$guest->id = $DB->insert_record('user', $guest);
|
||||||
if ($guest->id != 1) {
|
if ($guest->id != 1) {
|
||||||
throw new moodle_exception('generalexceptionmessage', 'error', '', 'Unexpected new guest user id!');
|
echo $OUTPUT->notification('Unexpected id generated for the Guest account. Your database configuration or clustering setup may not be fully supported', 'notifyproblem');
|
||||||
}
|
}
|
||||||
// Store guest id
|
// Store guest id
|
||||||
set_config('siteguest', $guest->id);
|
set_config('siteguest', $guest->id);
|
||||||
|
@ -201,10 +201,15 @@ function xmldb_main_install() {
|
||||||
$admin->timemodified = time();
|
$admin->timemodified = time();
|
||||||
$admin->lastip = CLI_SCRIPT ? '0.0.0.0' : getremoteaddr(); // installation hijacking prevention
|
$admin->lastip = CLI_SCRIPT ? '0.0.0.0' : getremoteaddr(); // installation hijacking prevention
|
||||||
$admin->id = $DB->insert_record('user', $admin);
|
$admin->id = $DB->insert_record('user', $admin);
|
||||||
|
|
||||||
if ($admin->id != 2) {
|
if ($admin->id != 2) {
|
||||||
throw new moodle_exception('generalexceptionmessage', 'error', '', 'Unexpected new admin user id!');
|
echo $OUTPUT->notification('Unexpected id generated for the Admin account. Your database configuration or clustering setup may not be fully supported', 'notifyproblem');
|
||||||
}
|
}
|
||||||
// Store list of admins
|
if ($admin->id != ($guest->id + 1)) {
|
||||||
|
echo $OUTPUT->notification('Nonconsecutive id generated for the Admin account. Your database configuration or clustering setup may not be fully supported.', 'notifyproblem');
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Store list of admins
|
||||||
set_config('siteadmins', $admin->id);
|
set_config('siteadmins', $admin->id);
|
||||||
// Make sure user context exists
|
// Make sure user context exists
|
||||||
context_user::instance($admin->id);
|
context_user::instance($admin->id);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue