MDL-20625 new delegated transaction support in DML

This commit is contained in:
Petr Skoda
2009-11-07 08:52:56 +00:00
parent 88d39d6992
commit d5a8d9aa71
25 changed files with 797 additions and 449 deletions
+7 -13
View File
@@ -2455,24 +2455,18 @@ function cleanup_contexts() {
ON c.instanceid = t.id
WHERE t.id IS NULL AND c.contextlevel = ".CONTEXT_BLOCK."
";
// transactions used only for performance reasons here
$transaction = $DB->start_delegated_transaction();
if ($rs = $DB->get_recordset_sql($sql)) {
$DB->begin_sql();
$ok = true;
foreach ($rs as $ctx) {
if (!delete_context($ctx->contextlevel, $ctx->instanceid)) {
$ok = false;
break;
}
delete_context($ctx->contextlevel, $ctx->instanceid);
}
$rs->close();
if ($ok) {
$DB->commit_sql();
return true;
} else {
$DB->rollback_sql();
return false;
}
}
$transaction->allow_commit();
return true;
}