Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,21 @@ public function createCriterion(Document $document, CriterionContent $content):

public function deleteDocument(Document $document): void
{
$this->deleteEntry($this->documentTable(), $document->id(), 'id', true);
$table = $this->documentTable();
$this->database->manipulateF(
"DELETE FROM $table WHERE id = %s AND provider = %s",
[ilDBConstants::T_INTEGER, ilDBConstants::T_TEXT],
[$document->id(), $this->id]
);
$this->cleanupCriteria();

}

public function deleteCriterion(int $criterion_id): void
{
$this->deleteEntry($this->criterionTable(), $criterion_id, 'doc_id');
$table = $this->criterionTable();
$id = $this->database->quote($criterion_id, ilDBConstants::T_INTEGER);
$this->database->manipulate("DELETE FROM $table WHERE id = $id AND " . $this->exists($table . '.doc_id'));
}

public function updateDocumentTitle(DocumentId $document_id, string $title): void
Expand Down Expand Up @@ -334,15 +343,6 @@ private function update(int $id, string $table, array $fields_and_values): void
]));
}

private function deleteEntry(string $table, int $id, string $doc_field, bool $cleanup = false): void
{
$id = $this->database->quote($id, ilDBConstants::T_INTEGER);
$this->database->manipulate("DELETE FROM $table WHERE id = $id AND " . $this->exists($table . '.' . $doc_field));
if ($cleanup) {
$this->cleanupCriteria();
}
}

private function cleanupCriteria(): void
{
$criteria = $this->criterionTable();
Expand Down
Loading