Skip to content

Conversation

@adriendupuis
Copy link
Contributor

@adriendupuis adriendupuis commented Sep 6, 2023

Question Answer
JIRA issue N/A
Type improvement
Target Ibexa version v4.5+
BC breaks no

The 4th parameter of PermissionResolver::canUse must be an array according to its signature, an array of ValueObject according to its phpDoc.

Tested with a controller extending Ibexa\Core\MVC\Symfony\Controller\Controller:

$this->getRepository()->getPermissionResolver()->canUser('content', 'read', $content, $location);

It ends with error "Ibexa\Core\Repository\Permission\CachedPermissionService::canUser(): Argument #4 ($targets) must be of type array, Ibexa\Core\Repository\Values\Content\Location given"

The following quick fix seems to work but I didn't have a proper limitation to go with it as I could just pass an empty array or random strings in the array:

$this->getRepository()->getPermissionResolver()->canUser('content', 'read', $content, [$location]);

It needs a more proper/advanced test by someone else than me 😓

See ibexa/documentation-developer#2132 for doc counter-part.

Checklist:

  • Provided PR description.
  • Tested the solution manually.
  • Provided automated test coverage.
  • Checked that target branch is set correctly (main for features, the oldest supported for bugs).
  • Ran PHP CS Fixer for new PHP code (use $ composer fix-cs).
  • Asked for a review (ping @ibexa/engineering).

@adamwojs
Copy link
Member

adamwojs commented Sep 6, 2023

Could you please change branch to 4.5? In opposite to documentation repositories we are open PR against the lowest version when the given change is applicable

@alongosz alongosz added Bug Something isn't working Rebase required labels Sep 7, 2023
Copy link
Member

@alongosz alongosz left a comment

Choose a reason for hiding this comment

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

Target Ibexa version | v4.5+

@adriendupuis could you rebase it against 4.5 then please? :)

The 4th parameter must be an array according to signature (an array of ValueObject according to phpDoc)
@adriendupuis adriendupuis changed the base branch from main to 4.5 September 7, 2023 07:31
@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 7, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@adriendupuis
Copy link
Contributor Author

@adamwojs @alongosz git rebase main --onto 4.5 done and PR target edited.

@alongosz alongosz merged commit ebc5816 into 4.5 Sep 7, 2023
@alongosz alongosz deleted the fix-canuser-examples branch September 7, 2023 09:26
@alongosz
Copy link
Member

alongosz commented Sep 7, 2023

Thank you @adriendupuis 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working Rebase required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants