Fix attribute update refactor collision

This commit is contained in:
Jake Barnby 2025-08-20 02:56:44 +12:00
parent c88f1ed7ca
commit 82cb491a3c
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C

View file

@ -614,14 +614,14 @@ abstract class Action extends UtopiaAction
*/
foreach ($collection->getAttribute('indexes') as $index) {
/**
* @var string[] $attribute
* @var array<string> $attributes
*/
$attribute = $index->getAttribute('attributes', []);
$found = \array_search($key, $attribute);
$attributes = $index->getAttribute('attributes', []);
$found = \array_search($key, $attributes);
if ($found !== false) {
$attribute[$found] = $newKey;
$index->setAttribute('attributes', $attribute);
$attributes[$found] = $newKey;
$index->setAttribute('attributes', $attributes);
$dbForProject->updateDocument('indexes', $index->getId(), $index);
}
}