Commit b1ae9daa authored by Nigel McNie's avatar Nigel McNie

Rewrite upgrade to not install user profile views.

The process of copying profile views takes ages. Furthermore, the View
class appears to have some memory leaks that mean the upgrade soon runs
out of memory (tested on a ~2000 user site, the 64M limit is reached
reasonably soon).

After this, the upgrade finishes in a few seconds, rather than waiting
over a minute before dying (on test site).
parent 4d860976
......@@ -1354,14 +1354,6 @@ function xmldb_core_upgrade($oldversion=0) {
install_blocktype_viewtypes_for_plugin(blocktype_single_to_namespaced($bt->name, $bt->artefactplugin));
}
}
// migrate all users to their default profile view
// These profile views are deleted in the next upgrade.
if ($userids = get_column('usr', 'id')) {
foreach ($userids as $user) {
install_default_profile_view(array('id' => $user));
}
}
}
if ($oldversion < 2008091603) {
......@@ -1372,33 +1364,7 @@ function xmldb_core_upgrade($oldversion=0) {
}
}
// Delete all the empty profile views & recreate them from the
// site template.
$viewids = get_column('view', 'id', 'type', 'profile');
if ($viewids) {
require_once(get_config('libroot') . 'view.php');
foreach ($viewids as $id) {
$view = new View($id);
$view->delete();
}
}
install_system_profile_view();
if ($userids = get_column('usr', 'id')) {
foreach ($userids as $user) {
if ($user > 0) {
install_default_profile_view(array('id' => $user));
}
}
}
// This record already exists on an install from scratch, but
// not in an upgrade
if (!record_exists('event_subscription', 'event', 'createuser', 'callfunction', 'install_default_profile_view')) {
insert_record('event_subscription', (object)array('event' => 'createuser', 'callfunction' => 'install_default_profile_view'));
}
}
if ($oldversion < 2008091604) {
......@@ -1419,6 +1385,12 @@ function xmldb_core_upgrade($oldversion=0) {
// next upgrade should probably set disablelogin = false and
// minupgradefrom = 2008092000 in version.php.
if ($oldversion < 2008101500) {
// Remove event subscription for new user accounts to have a default
// profile view created, they're now created on demand
execute_sql("DELETE FROM {event_subscription} WHERE event = 'createuser' AND callfunction = 'install_default_profile_view';");
}
return $status;
}
......
......@@ -670,10 +670,6 @@ function core_install_firstcoredata_defaults() {
'event' => 'createuser',
'callfunction' => 'activity_set_defaults',
),
array(
'event' => 'createuser',
'callfunction' => 'install_default_profile_view'
),
);
foreach ($subs as $sub) {
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2008100101;
$config->version = 2008101500;
$config->release = '1.1.0alpha4dev';
$config->minupgradefrom = 2007080700;
$config->minupgraderelease = '0.8.0 (release tag 0.8.0_RELEASE)';
......
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