Actions
Bug #82736
closedNesting level too deep - recursive dependency? in Extbase/SignalSlot/Dispatcher.php
Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2017-10-11
Due date:
% Done:
100%
Estimated time:
TYPO3 Version:
8
PHP Version:
7.1
Tags:
Complexity:
Is Regression:
Sprint Focus:
Description
When connecting a signal with a slot, being the slot an object instance with complex structure (many nested elements), \TYPO3\CMS\Extbase\SignalSlot\Dispatcher->connect throws the exception:
Fatal error: Nesting level too deep - recursive dependency?
when checking if signal-slot connection already exists:
if (!is_array($this->slots[$signalClassName][$signalName]) || !in_array($slot, $this->slots[$signalClassName][$signalName])) { $this->slots[$signalClassName][$signalName][] = $slot; }
The exceptions occurs at in_array(...), which happens when connecting the second (and next) slot to the same signal.
This happens because slot is not strictly compared when doing the in_array search as mentioned here: https://stackoverflow.com/questions/3834791/fatal-error-nesting-level-too-deep-recursive-dependency
Setting the strict flag on the in_array solves the problem:
if (!is_array($this->slots[$signalClassName][$signalName]) || !in_array($slot, $this->slots[$signalClassName][$signalName], true)) { $this->slots[$signalClassName][$signalName][] = $slot; }
Actions