#88118Loose reference while remove items from a tree based on a callback in PageTreeRepository
Description
Hook “$GLOBALS[‘TYPO3_CONF_VARS’][‘SC_OPTIONS’][‘t3lib/class.t3lib_userauthgroup.php’][‘calcPerms’]” in BackendUserAuthentication has no effect.
The bug is in PageTreeRepository::applyCallbackToChildren in line 145:
/**
* Removes items from a tree based on a callback, usually used for permission checks
*
* @param array $tree
* @param callable $callback
*/
protected function applyCallbackToChildren(array &$tree, callable $callback)
{
if (!isset($tree['_children'])) {
return;
}
foreach ($tree['_children'] as $k => $childPage) {
if (!call_user_func_array($callback, [$childPage])) {
unset($tree['_children'][$k]);
continue;
}
$this->applyCallbackToChildren($childPage, $callback);
}
}
The unset does not effect on _children array, because the iteration ignores the reference.
The solution to set reference for $childPage:
foreach ($tree['_children'] as $k => &$childPage) {
...
}Reviews 2
Linked, but not in Forger: Change 60425
History 35
-
Gerrit Code Review pushed patch set 1 for master to change 60425 status
NewUnder Review 04/09/19, 11:22 -
Oliver Hader changed Duplicated by #88257 05/02/19, 15:50
-
Susanne Moog commented and changed status
Under ReviewClosed 01/15/20, 16:56 -
Gerrit Code Review pushed patch set 2 for master to change 60425 status
ClosedUnder Review 05/03/23, 09:15 -
Riccardo De Contardi commented and changed status
Under ReviewClosed removed the assignee 06/06/24, 09:59This has been already fixed; I therefore close it
If you think that this is the wrong decision or experience the issue again please reopen it or open a new issue with a reference to this one.
Thank you
This has been fixed with 9.5.6 and v10 (see https://review.typo3.org/c/Packages/TYPO3.CMS/+/60701).