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

Loading…
Cancel
Save