Browse Source

Clear artist cache when added to a new group

spaghetti 7 years ago
parent
commit
a8099af79f
1 changed files with 6 additions and 11 deletions
  1. 6
    11
      sections/torrents/add_alias.php

+ 6
- 11
sections/torrents/add_alias.php View File

@@ -18,8 +18,6 @@ if (!$DB->has_results()) {
18 18
 }
19 19
 list($GroupName) = $DB->next_record(MYSQLI_NUM, false);
20 20
 
21
-$Changed = false;
22
-
23 21
 for ($i = 0; $i < count($ArtistNames); $i++) {
24 22
   $ArtistName = Artists::normalise_artist_name($ArtistNames[$i]);
25 23
 
@@ -27,7 +25,7 @@ for ($i = 0; $i < count($ArtistNames); $i++) {
27 25
     $DB->query("
28 26
       SELECT ArtistID
29 27
       FROM artists_group
30
-      WHERE Name = '".db_string($ArtistName)."'");
28
+      WHERE Name = ?", $ArtistName);
31 29
 
32 30
     if ($DB->has_results())
33 31
       list($ArtistID) = $DB->next_record(MYSQLI_NUM, false);
@@ -36,7 +34,7 @@ for ($i = 0; $i < count($ArtistNames); $i++) {
36 34
       $ArtistName = db_string($ArtistName);
37 35
       $DB->query("
38 36
         INSERT INTO artists_group (Name)
39
-        VALUES ('$ArtistName')");
37
+        VALUES ( ? )", $ArtistName);
40 38
       $ArtistID = $DB->inserted_id();
41 39
     }
42 40
 
@@ -47,18 +45,15 @@ for ($i = 0; $i < count($ArtistNames); $i++) {
47 45
         ('$GroupID', '$ArtistID', '$UserID')");
48 46
 
49 47
     if ($DB->affected_rows()) {
50
-      $Changed = true;
51 48
       Misc::write_log("Artist $ArtistID ($ArtistName) was added to the group $GroupID ($GroupName) by user ".$LoggedUser['ID'].' ('.$LoggedUser['Username'].')');
52 49
       Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "added artist $ArtistName", 0);
50
+      $Cache->delete_value("torrents_details_$GroupID");
51
+      $Cache->delete_value("groups_artists_$GroupID"); // Delete group artist cache
52
+      $Cache->delete_value("artist_groups_$ArtistID"); // Delete artist group cache
53
+      Torrents::update_hash($GroupID);
53 54
     }
54 55
   }
55 56
 }
56 57
 
57
-if ($Changed) {
58
-  $Cache->delete_value("torrents_details_$GroupID");
59
-  $Cache->delete_value("groups_artists_$GroupID"); // Delete group artist cache
60
-  Torrents::update_hash($GroupID);
61
-}
62
-
63 58
 header('Location: '.$_SERVER['HTTP_REFERER']);
64 59
 ?>

Loading…
Cancel
Save