Commit 64141d43 authored by Son Nguyen's avatar Son Nguyen Committed by Robert Lyon
Browse files

Delete leftover data not associated to any institution (Bug 1314440)



Another patch for bug 1314440 makes it so that when you delete an
institution, this data gets deleted. This patch cleans up the data
for institutions that were deleted before that patch was merged.

Change-Id: I167001f444a3fd204b12610ca10274d6218d9f96
Signed-off-by: default avatarSon Nguyen <son.nguyen@catalyst.net.nz>
parent ff381c44
......@@ -3428,5 +3428,40 @@ function xmldb_core_upgrade($oldversion=0) {
}
}
// Delete leftover data which are not associated to any institution
if ($oldversion < 2014073100) {
// Institution collections
$collectionids = get_column_sql('
SELECT id
FROM {collection} c
WHERE c.institution IS NOT NULL
AND NOT EXISTS (SELECT 1 FROM {institution} i WHERE i.name = c.institution)');
if ($collectionids) {
require_once(get_config('libroot') . 'collection.php');
$count = 0;
$limit = 200;
$total = count($collectionids);
foreach ($collectionids as $collectionid) {
$collection = new Collection($collectionid);
$collection->delete();
$count++;
if (($count % $limit) == 0) {
log_debug("Deleting leftover collections: $count/$total");
set_time_limit(30);
}
}
log_debug("Deleting leftover collections: $count/$total");
}
// Institution custom layouts and registration
delete_records_sql('
DELETE FROM {usr_custom_layout}
WHERE {usr_custom_layout}.institution IS NOT NULL
AND NOT EXISTS (SELECT 1 FROM {institution} i WHERE i.name = {usr_custom_layout}.institution)');
delete_records_sql('
DELETE FROM {usr_registration}
WHERE {usr_registration}.institution IS NOT NULL
AND NOT EXISTS (SELECT 1 FROM {institution} i WHERE i.name = {usr_registration}.institution)');
}
return $status;
}
......@@ -16,7 +16,7 @@ $config = new stdClass();
// See https://wiki.mahara.org/index.php/Developer_Area/Version_Numbering_Policy
// For upgrades on stable branches, increment the version by one. On master, use the date.
$config->version = 2014062500;
$config->version = 2014073100;
$config->release = '1.10.0dev';
$config->minupgradefrom = 2009022600;
$config->minupgraderelease = '1.1.0 (release tag 1.1.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