Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix FileAccess::getByFileId(InStorage) #45140

Merged
merged 1 commit into from
May 2, 2024
Merged

Conversation

icewind1991
Copy link
Member

No description provided.

Signed-off-by: Robin Appelman <robin@icewind.nl>
@icewind1991 icewind1991 added the 3. to review Waiting for reviews label May 1, 2024
@icewind1991 icewind1991 added this to the Nextcloud 30 milestone May 1, 2024
@icewind1991 icewind1991 requested review from a team, ArtificialOwl, Fenn-CS and yemkareems and removed request for a team May 1, 2024 16:01
@icewind1991
Copy link
Member Author

/backport to stable29

@@ -56,7 +56,7 @@ private function getQuery(): CacheQueryBuilder {
}

public function getByFileIdInStorage(int $fileId, int $storageId): ?CacheEntry {
$items = $this->getByFileIdsInStorage([$fileId], $storageId);
$items = array_values($this->getByFileIdsInStorage([$fileId], $storageId));
return $items[0] ?? null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return $items[0] ?? null;
return reset($items) ?: null;

And then you do not need the array_values call.
But no idea if it’s more performant.

It just sucks that array_value_first did not make it in 😿 https://wiki.php.net/rfc/array_key_first_last#vote

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performance seems to be quite the same, ~10% difference (faster array_values) on my system.

@kesselb kesselb merged commit dbd2bc7 into master May 2, 2024
157 checks passed
@kesselb kesselb deleted the fix-fileaccess-single branch May 2, 2024 17:10
@blizzz blizzz mentioned this pull request Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants