Commit fd9bc4e2 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1702198: Record the ctime when creating the initial 'admin' user



As part of the install process

behatnotneeded

Change-Id: I0d74698a61f74508d2ab8ed5dcb4695e39a0c3fd
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 787ac996
......@@ -5062,5 +5062,17 @@ function xmldb_core_upgrade($oldversion=0) {
}
}
if ($oldversion < 2017071100) {
log_debug('Fix up missing creation time for users');
// Guess their creation time from their earliest view
if ($results = get_records_sql_array("SELECT u.id, (
SELECT MIN(v.ctime) FROM {view} v WHERE v.owner = u.id)
AS starttime FROM {usr} u WHERE u.deleted = 0 AND u.ctime IS NULL AND u.id != 0")) {
foreach ($results as $result) {
execute_sql("UPDATE {usr} SET ctime = ? WHERE id = ?", array($result->starttime, $result->id));
}
}
}
return $status;
}
......@@ -801,6 +801,7 @@ function core_install_lastcoredata_defaults() {
$user->lastname = 'User';
$user->email = 'admin@example.org';
$user->quota = get_config_plugin('artefact', 'file', 'defaultquota');
$user->ctime = db_format_timestamp(time());
$user->id = insert_record('usr', $user, 'id', true);
set_profile_field($user->id, 'email', $user->email);
set_profile_field($user->id, 'firstname', $user->firstname);
......
......@@ -16,7 +16,7 @@ $config = new stdClass();
// See https://wiki.mahara.org/wiki/Developer_Area/Version_Numbering_Policy
// For upgrades on stable branches, increment the version by one. On master, use the date.
$config->version = 2017062000;
$config->version = 2017071100;
$config->series = '17.10';
$config->release = '17.10dev';
$config->minupgradefrom = 2012080604;
......
Markdown is supported
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