diff --git a/system/src/Grav/Common/User/FlexUser/UserIndex.php b/system/src/Grav/Common/User/FlexUser/UserIndex.php index 91b7f67cc..43f47ead1 100644 --- a/system/src/Grav/Common/User/FlexUser/UserIndex.php +++ b/system/src/Grav/Common/User/FlexUser/UserIndex.php @@ -100,12 +100,10 @@ class UserIndex extends FlexIndex return $this->load(''); } - protected static function getIndexData($key, ?array $row) + protected static function updateIndexData(array &$entry, array $data) { - return [ - 'key' => mb_strtolower($row['username'] ?? $key), - 'email' => mb_strtolower($row['email'] ?? ''), - ]; + $entry['key'] = mb_strtolower($data['username'] ?? $data['email'] ?? $entry['key']); + $entry['email'] = mb_strtolower($data['email']) ?? null; } protected static function getIndexFile(FlexStorageInterface $storage) diff --git a/system/src/Grav/Framework/Flex/FlexIndex.php b/system/src/Grav/Framework/Flex/FlexIndex.php index 4b05dcd63..4dadb7b8f 100644 --- a/system/src/Grav/Framework/Flex/FlexIndex.php +++ b/system/src/Grav/Framework/Flex/FlexIndex.php @@ -530,7 +530,8 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde $updated = $added = []; foreach ($rows as $key => $row) { if (null !== $row) { - $entry = $entries[$key] + static::getIndexData($key, $row); + $entry = ['key' => $key] + $entries[$key]; + static::updateIndexData($entry, $row); if (isset($row['__error'])) { $entry['__error'] = true; static::onException(new \RuntimeException(sprintf('Object failed to load: %s (%s)', $key, $row['__error']))); @@ -563,11 +564,8 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde return $index; } - protected static function getIndexData($key, ?array $row) + protected static function updateIndexData(array &$entry, array $data) { - return [ - 'key' => $key, - ]; } protected static function loadEntriesFromIndex(FlexStorageInterface $storage)