-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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(text2image): Return providers as indexed array #42377
Conversation
/backport to stable28 |
Signed-off-by: MB-Finski <sami.finnila@gmail.com>
cf24acd
to
8904bf6
Compare
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.
Why? Is there code relying on this? If so, please update the OCP return type accordingly in phpdoc to indicate array<int,IProvider>
or list<IProvider>
depending on what is needed.
[EDIT] Reading the referenced issue, you would need list<IProvider>
to be sure that you can use key 0
without issue.
The runOrScheduleTask assumes an indexed array with [0] being defined. This causes issues if a user has not specified the default provider and getPreferredProviders returns the unfiltered results of the getProviders() as it currently does. This seemed like the easiest place to fix this. |
Signed-off-by: MB-Finski <sami.finnila@gmail.com>
@come-nc I hope I got it right. (I'm essentially a php newbie). EDIT: Nope, made it worse according to psalm. |
Can't we just keep |
You can but then calling code cannot assume that index 0 will be populated as the keys can be anything. |
Ah, I kind of assumed string[] to be a list, but it's a array<array-key, string> 🙈 |
To fix psalm the property needs to be typed as list as well on https://github.com/nextcloud/server/blob/fix/text-to-image-manager/lib/private/TextToImage/Manager.php#L53 |
Yeah, |
lib/private/TextToImage/Manager.php
Outdated
@@ -83,7 +83,7 @@ public function getProviders(): array { | |||
foreach ($context->getTextToImageProviders() as $providerServiceRegistration) { | |||
$class = $providerServiceRegistration->getService(); | |||
try { | |||
$this->providers[$class] = $this->serverContainer->get($class); | |||
$this->providers[] = $this->serverContainer->get($class); |
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.
lib/private/TextToImage/Manager.php:94:10: LessSpecificReturnStatement: The type 'list<mixed>' is more general than the declared return type 'list<OCP\TextToImage\IProvider>' for OC\TextToImage\Manager::getProviders (see https://psalm.dev/129)
Need to adjust the docs on the definition of the member as well
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
df52fda
to
997f6c3
Compare
The backport to stable28 failed. Please do this backport manually. # Switch to the target branch and update it
git checkout stable28
git pull origin stable28
# Create the new backport branch
git checkout -b fix/foo-stable28
# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts. Resolve them.
git cherry-pick abc123
# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable28 Error: Unknown error More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport |
Checklist