-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Component: Framework/EventFixed in 2.2.xThe issue has been fixed in 2.2 release lineThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentProgress: PR CreatedIndicates that Pull Request has been created to fix issueIndicates that Pull Request has been created to fix issueReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseThe issue has been reproduced on latest 2.3 releasehelp wanted
Description
Summary (*)
In developer mode, if an observer does not implement ObserverInterface, Magento throws an exception. This is the expected behavior.
What I don't understand is that it does not do anything for other deploy modes (default and production). It silently discards the observer without even putting an entry to logs.
Examples (*)
This is the method where problem occurs. There is only one condition for developer mode, but other deploy modes are ignored.
/**
* @param \Magento\Framework\Event\ObserverInterface $object
* @param Observer $observer
* @return $this
* @throws \LogicException
*/
protected function _callObserverMethod($object, $observer)
{
if ($object instanceof \Magento\Framework\Event\ObserverInterface) {
$object->execute($observer);
} elseif ($this->_appState->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) {
throw new \LogicException(
sprintf(
'Observer "%s" must implement interface "%s"',
get_class($object),
\Magento\Framework\Event\ObserverInterface::class
)
);
}
return $this;
}
Proposed solution
We can put an else condition. Then, we can log the same exception message in warning level.
Metadata
Metadata
Assignees
Labels
Component: Framework/EventFixed in 2.2.xThe issue has been fixed in 2.2 release lineThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentProgress: PR CreatedIndicates that Pull Request has been created to fix issueIndicates that Pull Request has been created to fix issueReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseThe issue has been reproduced on latest 2.3 releasehelp wanted