Commit 5f6a89a7 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic
Browse files

Bug 1773247: bad sql query in files bulk_delete

behatnotneeded

Change-Id: Ide581c47d02772478fe04a85673e8d72cdd919e0
parent f0e8c54a
......@@ -1480,15 +1480,20 @@ class ArtefactTypeFile extends ArtefactTypeFileBase {
// Get all files so that we can delete the files on filesystem
$filerecords = get_records_sql_assoc('
SELECT aff1.*, a.artefacttype
FROM {artefact_file_files} aff1
JOIN {artefact} a ON aff1.artefact = a.id
WHERE artefact IN (' . $idstr . ')
GROUP BY fileid
HAVING COUNT(aff1.artefact) IN
(SELECT COUNT(aff2.artefact)
FROM {artefact_file_files} aff2
WHERE aff1.fileid = aff2.fileid)'
SELECT aff.*, art.artefacttype
FROM {artefact_file_files} aff
JOIN {artefact} art ON aff.artefact = art.id
WHERE fileid IN (
SELECT fileid
FROM {artefact_file_files} aff1
JOIN {artefact} a ON aff1.artefact = a.id
WHERE artefact IN (' . $idstr . ')
GROUP BY fileid
HAVING COUNT(aff1.artefact) IN
(SELECT COUNT(aff2.artefact)
FROM {artefact_file_files} aff2
WHERE aff1.fileid = aff2.fileid)
)'
);
// The current rule is that file deletion should be logged in the artefact_log table
......
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