Browse Source

Fix weird case where trying to delete an artist that was already deleted breaks edit

spaghetti 8 years ago
parent
commit
a058a42a50
1 changed files with 19 additions and 17 deletions
  1. 19
    17
      sections/torrents/nonwikiedit.php

+ 19
- 17
sections/torrents/nonwikiedit.php View File

@@ -115,28 +115,30 @@ foreach ($CurrArtists as $CurrArtist) {
115 115
       SELECT ArtistID
116 116
       FROM artists_group
117 117
       WHERE Name = '".db_string($CurrArtist)."'");
118
-    list($ArtistID) = $DB->next_record();
118
+    if ($DB->has_results()) {
119
+      list($ArtistID) = $DB->next_record();
119 120
 
120
-    $DB->query("
121
-      DELETE FROM torrents_artists
122
-      WHERE ArtistID = ".$ArtistID."
123
-        AND GroupID = ".$GroupID);
121
+      $DB->query("
122
+        DELETE FROM torrents_artists
123
+        WHERE ArtistID = ".$ArtistID."
124
+          AND GroupID = ".$GroupID);
124 125
 
125
-    $DB->query("
126
-      SELECT GroupID
127
-      FROM torrents_artists
128
-      WHERE ArtistID = ".$ArtistID);
126
+      $DB->query("
127
+        SELECT GroupID
128
+        FROM torrents_artists
129
+        WHERE ArtistID = ".$ArtistID);
129 130
 
130
-    $Cache->delete_value('artist_groups_'.$ArtistID);
131
+      $Cache->delete_value('artist_groups_'.$ArtistID);
131 132
 
132
-    if (!$DB->has_results()) {
133
-      $DB->query("
134
-        SELECT RequestID
135
-        FROM requests_artists
136
-        WHERE ArtistID = ".$ArtistID."
137
-          AND ArtistID != 0");
138 133
       if (!$DB->has_results()) {
139
-        Artists::delete_artist($ArtistID);
134
+        $DB->query("
135
+          SELECT RequestID
136
+          FROM requests_artists
137
+          WHERE ArtistID = ".$ArtistID."
138
+            AND ArtistID != 0");
139
+        if (!$DB->has_results()) {
140
+          Artists::delete_artist($ArtistID);
141
+        }
140 142
       }
141 143
     }
142 144
   }

Loading…
Cancel
Save