-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
chore(files_versions): Use new metadata API for versions #44175
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
Conversation
| if ($backend instanceof IMetadataVersionBackend) { | ||
| $backend->setMetadataValue($this->version, $key, $value); | ||
| return true; | ||
| } elseif ($key === 'label' && $backend instanceof INameableVersionBackend) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure compatibility with backends that are not migrated yet.
| * @param string $key the key for the json value of the metadata column | ||
| * @since 29.0.0 | ||
| */ | ||
| public function getMetadataValue(Node $node, string $key): ?string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The metadata can already be retrieved from the IMetadataVersion. So this method seem unnecessary. @emoral435 does it make sense to remove it? Can still be added later if needed, but I don't see a reason for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed 👍
| if ($this->backend instanceof IMetadataVersionBackend && $this->sourceFileInfo instanceof Node) { | ||
| return $this->backend->getMetadataValue($this->sourceFileInfo, "author"); | ||
| } | ||
| return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constructor now receives the metadata, so we can simplify the logic here.
d375386 to
28ee8af
Compare
28ee8af to
cf75f46
Compare
As of: nextcloud/server#44049 Server equivalent: nextcloud/server#44175 Signed-off-by: Louis Chemineau <[email protected]>
8aeb048 to
0fad147
Compare
| public function getMetadataValue(string $key): ?string { | ||
| if ($this->version instanceof IMetadataVersion) { | ||
| return $this->version->getMetadataValue($key); | ||
| } elseif ($key === 'label' && $this->version instanceof INameableVersion) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure compatibility with backends that are not migrated yet.
| * @since 29.0.0 | ||
| */ | ||
| public function getMetadataValue(Node $node, string $key): ?string; | ||
| public function setMetadataValue(Node $node, int $revision, string $key, string $value): void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a $revision param to be able to target a specific version. @emoral435, ok with you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this change! Ok with me.
| if ($this->versionManager instanceof INameableVersionBackend) { | ||
| $this->versionManager->setVersionLabel($this->version, $label); | ||
| if ($backend instanceof IMetadataVersionBackend) { | ||
| $backend->setMetadataValue($this->version->getSourceFile(), $this->version->getRevisionId(), $key, $value); |
Check notice
Code scanning / Psalm
ArgumentTypeCoercion
| if ($this->versionManager instanceof INameableVersionBackend) { | ||
| $this->versionManager->setVersionLabel($this->version, $label); | ||
| if ($backend instanceof IMetadataVersionBackend) { | ||
| $backend->setMetadataValue($this->version->getSourceFile(), $this->version->getRevisionId(), $key, $value); |
Check notice
Code scanning / Psalm
PossiblyInvalidArgument
| $backend->setMetadataValue($this->version->getSourceFile(), $this->version->getRevisionId(), $key, $value); | ||
| return true; | ||
| } elseif ($key === 'label' && $backend instanceof INameableVersionBackend) { | ||
| $backend->setVersionLabel($this->version, $value); |
Check notice
Code scanning / Psalm
DeprecatedMethod
| if ($this->version instanceof IMetadataVersion) { | ||
| return $this->version->getMetadataValue($key); | ||
| } elseif ($key === 'label' && $this->version instanceof INameableVersion) { | ||
| return $this->version->getLabel(); |
Check notice
Code scanning / Psalm
DeprecatedMethod
Signed-off-by: Louis Chemineau <[email protected]>
0fad147 to
9361a30
Compare
As of: nextcloud/server#44049 Server equivalent: nextcloud/server#44175 Signed-off-by: Louis Chemineau <[email protected]>
emoral435
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the new changes. The capability to store whatever metadata we want and get whichever version's metadata seems really flexible :) I do not know if this PR is ready as I have not been marked down as a reviewer, though I approve the current changes. Ping me if you need me to approve!
| * @since 29.0.0 | ||
| */ | ||
| public function getMetadataValue(Node $node, string $key): ?string; | ||
| public function setMetadataValue(Node $node, int $revision, string $key, string $value): void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this change! Ok with me.
| * @param string $key the key for the json value of the metadata column | ||
| * @since 29.0.0 | ||
| */ | ||
| public function getMetadataValue(Node $node, string $key): ?string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed 👍
I was waiting for CI to be green. Now it's ok, and your approval would be appreciated. :) |
As of: nextcloud/server#44049 Server equivalent: nextcloud/server#44175 Signed-off-by: Louis Chemineau <[email protected]>
As of: nextcloud/server#44049 Server equivalent: nextcloud/server#44175 Signed-off-by: Louis Chemineau <[email protected]>
As of: nextcloud/server#44049 Server equivalent: nextcloud/server#44175 Signed-off-by: Louis Chemineau <[email protected]>
Use the new version metadata API for handling the label logic.
@emoral435 I also tweaked the API a bit, I left some comments to give some reasoning behind the changes.
As of: #44049