tools/generate-item-upgrade-schema: filter old IDs that were already renamed by previous schemas

this caused weird outputs if an item was renamed multiple times.
This commit is contained in:
Dylan K. Taylor 2024-01-22 18:48:32 +00:00
parent e77cd39316
commit d97c8e2fd2
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -94,9 +94,14 @@ foreach($files as $file){
$newDiff = []; $newDiff = [];
foreach($target["simple"] as $oldId => $newId){ foreach($target["simple"] as $oldId => $newId){
if(($merged["simple"][$oldId] ?? null) !== $newId){ $previousNewId = $merged["simple"][$oldId] ?? null;
$newDiff["renamedIds"][$oldId] = $newId; if(
$previousNewId === $newId || //if previous schemas already accounted for this
($previousNewId !== null && isset($target["simple"][$previousNewId])) //or the item's ID has been changed for a second time
){
continue;
} }
$newDiff["renamedIds"][$oldId] = $newId;
} }
if(isset($newDiff["renamedIds"])){ if(isset($newDiff["renamedIds"])){
ksort($newDiff["renamedIds"], SORT_STRING); ksort($newDiff["renamedIds"], SORT_STRING);