Commit a7a32f25 authored by Nigel Cunningham's avatar Nigel Cunningham
Browse files

(Bug1353802) Don't call delete_records for new artefacts.



In ArtefactType::commit, don't bother calling delete_records
if we know the artefact that is being committed is new. In
testing the addition 2000 users from a CSV file, this patch
shaved 4 seconds off the completion time.

Change-Id: I5b22cb5fc936e67e9a37a0022a4488fc30604d03
Signed-off-by: default avatarNigel Cunningham <nigelc@catalyst-au.net>
parent cd910bb7
......@@ -523,6 +523,8 @@ abstract class ArtefactType implements IArtefactType {
public function commit() {
static $last_source, $last_output;
$is_new = false;
if (empty($this->dirty)) {
return;
}
......@@ -545,6 +547,7 @@ abstract class ArtefactType implements IArtefactType {
}
}
if (empty($this->id)) {
$is_new = true;
$this->id = insert_record('artefact', $fordb, 'id', true);
if ($this->can_be_logged()) {
$this->log('created');
......@@ -563,7 +566,10 @@ abstract class ArtefactType implements IArtefactType {
$this->save_rolepermissions();
}
delete_records('artefact_tag', 'artefact', $this->id);
if (!$is_new) {
$deleted = delete_records('artefact_tag', 'artefact', $this->id);
}
if (is_array($this->tags)) {
$this->tags = check_case_sensitive($this->tags, 'artefact_tag');
foreach (array_unique($this->tags) as $tag) {
......
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