Skip to content
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

Merged
merged 4 commits into from
Apr 5, 2019

Conversation

Nazar65
Copy link
Member

@Nazar65 Nazar65 commented Mar 15, 2019

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)

  1. Magento should create a log entry if an observer does not implement ObserverInterface #21755: Magento should create a log entry if an observer does not implement ObserverInterface

Manual testing scenarios (*)

  1. Create an Observer class wich not implements ObserverInterface
  2. Check Log sytem.log

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team
Copy link
Contributor

Hi @Nazar65. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@magento-engcom-team
Copy link
Contributor

Hi @VladimirZaets, thank you for the review.
ENGCOM-4505 has been created to process this Pull Request

@soleksii
Copy link

✔️ QA Passed

/**
* @var LoggerInterface
*/
protected $logger;
Copy link
Contributor

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) {
Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this property private

@Nazar65
Copy link
Member Author

Nazar65 commented Mar 22, 2019

Hi @sidolov thank you for your review, I was change my solution, now looks good to me.

@magento-engcom-team
Copy link
Contributor

Hi @sidolov, thank you for the review.
ENGCOM-4505 has been created to process this Pull Request

@soleksii
Copy link

soleksii commented Apr 1, 2019

✔️ QA Passed

@m2-assistant
Copy link

m2-assistant bot commented Apr 5, 2019

Hi @Nazar65, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants