From 5d8caadea25c53c0a95d37f57c3f3d8e79a3fa55 Mon Sep 17 00:00:00 2001 From: Zack Galbreath Date: Wed, 20 Nov 2024 13:19:32 -0500 Subject: [PATCH] Eliminate unnecessary DELETE statements in removeBuilds() (#2576) Remove DELETE statements for tables that are now handled by cascading deletions. * build2uploadfile was fixed in #1657 * label2buildfailure was fixed in #2452 * dynamicanalysisdefect and label2dynamicanalysis were fixed in #2455 --- app/Utils/DatabaseCleanupUtils.php | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/app/Utils/DatabaseCleanupUtils.php b/app/Utils/DatabaseCleanupUtils.php index 1b5700132..5026c7d7f 100644 --- a/app/Utils/DatabaseCleanupUtils.php +++ b/app/Utils/DatabaseCleanupUtils.php @@ -129,7 +129,6 @@ public static function removeBuild($buildid) : void if (count($buildfailureids) > 0) { $buildfailure_prepare_array = $db->createPreparedArray(count($buildfailureids)); DB::delete("DELETE FROM buildfailure2argument WHERE buildfailureid IN $buildfailure_prepare_array", $buildfailureids); - DB::delete("DELETE FROM label2buildfailure WHERE buildfailureid IN $buildfailure_prepare_array", $buildfailureids); } // Delete buildfailuredetails that are only used by builds that are being @@ -197,24 +196,6 @@ public static function removeBuild($buildid) : void ) ", array_merge($buildids, $buildids)); - // dynamicanalysisdefect - $dynamicanalysis = DB::select(" - SELECT id - FROM dynamicanalysis - WHERE buildid IN $buildid_prepare_array - ", $buildids); - - $dynids = []; - foreach ($dynamicanalysis as $dynamicanalysis_array) { - $dynids[] = intval($dynamicanalysis_array->id); - } - - if (count($dynids) > 0) { - $dynids_prepare_array = $db->createPreparedArray(count($dynids)); - DB::delete("DELETE FROM dynamicanalysisdefect WHERE dynamicanalysisid IN $dynids_prepare_array", $dynids); - DB::delete("DELETE FROM label2dynamicanalysis WHERE dynamicanalysisid IN $dynids_prepare_array", $dynids); - } - // Delete the note if not shared DB::delete(" DELETE FROM note WHERE id IN ( @@ -349,7 +330,6 @@ public static function removeBuild($buildid) : void if (count($fileids) > 0) { $fileids_prepare_array = $db->createPreparedArray(count($fileids)); DB::delete("DELETE FROM uploadfile WHERE id IN $fileids_prepare_array", $fileids); - DB::delete("DELETE FROM build2uploadfile WHERE fileid IN $fileids_prepare_array", $fileids); } // Remove any children of these builds.