TheGameSpider / TechnicSolder

A better version of https://github.com/TechnicPack/TechnicSolder
https://solder.cf
Other
22 stars 19 forks source link

Mod ID's not removing from Modpack #11

Open bastrian opened 4 years ago

bastrian commented 4 years ago

Describe the bug When deleting a Mod from the Mod librarythe ID still stays in the modpack. It will show a blank entry in the Mod list of the Modpack

To Reproduce Steps to reproduce the behavior:

  1. Go to the Mod library
  2. Select a Mod that is in a Modpack and delete it
  3. Go to the Modpack and edit it
  4. See a blank entry

Expected behavior The Mod should be removed from the Modpack too. (Search all Modpacks, check for the ID and remove it)

Screenshots unknown

ZandercraftGames commented 3 years ago

I know it's almost a year later, but this bug would be quite hard to patch evidently as the system would need to scan every version from every modpack for the mods that are left behind. It can be done, but the easiest thing to do is to just not remove versions from the mod library and to just remove the mod in the next version you release. I've talked with TheGameSpider on this one and it does seem like something that could be done, but likely is a large amount of work that can be a little resource-intense if used in hundreds of versions across multiple packs. Just wondering, why would you want to remove something from the mod library in the first place instead of just making a new version without it?

cowpod commented 3 years ago

Maybe try something like:

$id = ;# mod ID that was removed
$modpacks = mysqli_get_array(mysqli_query($connect, "SELECT * FROM builds"));
foreach ($modpacks as $modpack) {
    $modpackId=$modpack['id']; 
    $modpackMods = explode(',', $modpack['mods']) ;
    if (in_array($id, $modpackMods) {
        $indexOfId=array_search($id, $modpackMods);# this and below may not work.
        unset($indexOfId, $modpackMods);  
        $modpackMods=array_values($modpackMods); 
        mysqli_query($connect, "UPDATE builds SET mods = ".$modpackMods." WHERE id = ".$modpackId)
    }
}