#82736Nesting level too deep - recursive dependency? in Extbase/SignalSlot/Dispatcher.php
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;
}