-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Magento should create a log entry if an observer does not implement ObserverInterface #21767
Conversation
Hi @Nazar65. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
Hi @VladimirZaets, thank you for the review. |
✔️ QA Passed |
/** | ||
* @var LoggerInterface | ||
*/ | ||
protected $logger; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, make property private
*/ | ||
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that we should delete this condition for the developer mode, also such changes are backward incompatible because method signature is changed (LogicException is not throwing anymore).
/** | ||
* @var |Psr\Log|LoggerInterface | ||
*/ | ||
protected $loggerMock; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this property private
Hi @sidolov thank you for your review, I was change my solution, now looks good to me. |
Hi @sidolov, thank you for the review. |
✔️ QA Passed |
Hi @Nazar65, thank you for your contribution! |
…t implement ObserverInterface #21767
Description (*)
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.
Fixed Issues (if relevant)
Manual testing scenarios (*)
Contribution checklist (*)