Fix(text2image): Return providers as indexed array#42377
Fix(text2image): Return providers as indexed array#42377nickvergessen merged 3 commits intomasterfrom
Conversation
|
/backport to stable28 |
Signed-off-by: MB-Finski <sami.finnila@gmail.com>
cf24acd to
8904bf6
Compare
There was a problem hiding this comment.
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
| $class = $providerServiceRegistration->getService(); | ||
| try { | ||
| $this->providers[$class] = $this->serverContainer->get($class); | ||
| $this->providers[] = $this->serverContainer->get($class); |
There was a problem hiding this comment.
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-stable28Error: Unknown error More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport |
Checklist