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: don't set 'name' on null metadata #49291

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

icewind1991
Copy link
Member

Otherwise the metadata ends up being an array with just the name set.

@icewind1991 icewind1991 added the 3. to review Waiting for reviews label Nov 14, 2024
@icewind1991 icewind1991 added this to the Nextcloud 31 milestone Nov 14, 2024
@icewind1991 icewind1991 requested review from a team, Altahrim, yemkareems and provokateurin and removed request for a team November 14, 2024 16:24
@provokateurin
Copy link
Member

Why is this bad?

@icewind1991
Copy link
Member Author

Why is this bad?

Any code using this will assume that a non-null result contains the expected set of metadata, not just a name

@provokateurin
Copy link
Member

I see. I also forgot that setting a key on null actually turns it into an array... PHP is fun

@@ -280,7 +280,9 @@ public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalP

public function getMetaData(string $path): ?array {
$entry = $this->storage->getMetaData($this->findPathToUse($path));
$entry['name'] = trim(Filesystem::normalizePath($entry['name']), '/');
if ($entry) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if ($entry) {
if ($entry !== null) {

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants