Project

General

Profile

Actions

Bug #104423

open

Refetch groups recursively following AfterGroupsResolvedEvent dispatching

Added by Soren Malling 4 months ago. Updated 4 months ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
-
Category:
Authentication
Target version:
-
Start date:
2024-07-18
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

In the "GroupResolver" method "resolveGroupsForUser", we only fetch groups recursively before the event "AfterGroupdResolvedEvent".

It has the consequence of any groups added afterwards, will not have any subgroups fetched.

$resolvedGroups = $this->fetchGroupsRecursive($originalGroupIds);
$event = $this->eventDispatcher->dispatch(new AfterGroupsResolvedEvent($sourceTable, $resolvedGroups, $originalGroupIds, $userRecord));

We could redo the fetching afterwards, to ensure all groups are loaded recursively

$resolvedGroups = $this->fetchGroupsRecursive($originalGroupIds);
$event = $this->eventDispatcher->dispatch(new AfterGroupsResolvedEvent($sourceTable, $resolvedGroups, $originalGroupIds, $userRecord));
$resolvedGroupsAfterEvent = $this->fetchGroupsRecursive(array_map(fn(array $group) => $group['uid'], $event->getGroups()));
Actions #1

Updated by Garvin Hicking 4 months ago

  • Status changed from New to Needs Feedback

I'm wondering if maybe the better place to do this recursively would be to do it inside your event? You can DI inject the GroupResolver to call the method fetchGroupsRecursive on your custom event result?

My reasoning is, that the event might be specifically be used to not include recursive settings. If we would generally add this after the event, no longer could integrators use the event to restrict groups to main groups for example - so we'd actually lose flexibility with this.

What do you think?

Actions #2

Updated by Soren Malling 4 months ago

That is a plausible usecase you describe. In terms of API, the method fetchGroupsRecursive is currently protected, so it can't be called from a DI class.

And, it's important to stress that one should not call resolveGroupsForUser as it would turn into a endless loop :-)

Actions #3

Updated by Garvin Hicking 4 months ago

Ah, of course, I didn't check thoroughly enough.

Then probably the event would need a new "setRecursive" / "isRecursive" property, so that it can be toggled whether the recursive operation should be fired or not after the event.

Would you be interested creating a patch for this?

Actions #4

Updated by Soren Malling 4 months ago

Garvin Hicking wrote in #note-3:

Would you be interested creating a patch for this?

I will come up with something 👌

Actions

Also available in: Atom PDF