Magento will still fire observers for disabled modules.
Besides simply triggering unwanted functionality, this can also potentially cause fatal errors if the module was disabled before the install scripts ever ran, as the observer will expect the module to be installed (and any schema/data changes to be applied), which it won't be in this case.
Magento 2.1.3
setup:upgrade.setup:upgrade. Because the module is disabled, schema changes will not be made (correctly so).Observer is not fired, since module is disabled.
Observer is fired, causing a potentially fatal error if it assumes schema changes have occurred.
@scottsb Please add more details to your description of the steps you followed when identifying this issue. Screenshots or logs would be helpful, too.
Is there a particular area you want clarification on? I already provided the steps to reproduce. (For what it's worth, the example I cite of Magento_AdminNotification isn't just hypothetical; it's the actual module we had disabled that caused us to run into this, so you could do the same.)
OK
Op 5 jul. 2017 21:59 schreef "Scott Buchanan" notifications@github.com:
Is there a particular area you want clarification on? I already provided
the steps to reproduce. (For what it's worth, the example I cite of
Magento_AdminNotification isn't just hypothetical; it's the actual module
we had disabled that caused us to run into this, so you could do the same.)—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/magento/magento2/issues/9948#issuecomment-313210037,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AS5o-mn9LwrpmiTgutrrjSqlTJ4yYWblks5sK-sqgaJpZM4N6Bts
.
I did just clarify the problem statement in the issue. The fundamental bug is simply that event observers in disabled modules still run. My steps to reproduce illustrate how this can lead to a fatal error, though obviously there are many ways this could fail since code is running that's supposed to be disabled.
@scottsb, thank you for your report.
We've created internal ticket(s) MAGETWO-71009 to track progress on the issue.
I am working on it #SQUASHTOBERFEST
@scottsb do you have example module that you can share?
It's been over a year, and I haven't bumped into this since I reported it. However, as I recall, this came up while doing a Magento upgrade on a store that had Magento_AdminNotification disabled.
Note that this can't be demonstrated by a module alone because it has to do with the configured status of the module in config.php. See steps to reproduce in the description.
@magento-engcom-team Any update on this? This is causing issues in 2.3 with the new MSP_ReCaptcha module... we have it disabled and we are getting errors like:
[2019-01-03 18:22:29] report.ERROR: Class MSP\ReCaptcha\Observer\Frontend\LoginObserver does not exist [] []
[2019-01-03 18:22:44] report.ERROR: Class MSP\ReCaptcha\Observer\Frontend\CreateUserObserver does not exist [] []
[2019-01-03 18:28:27] report.ERROR: Class MSP\ReCaptcha\Observer\Frontend\LoginObserver does not exist [] []
[2019-01-03 18:35:10] report.ERROR: Class MSP\ReCaptcha\Observer\Frontend\CreateUserObserver does not exist [] []
...because the Virtual Types are not getting compiled (since the module is disabled) but the events are still firing.
I just upgraded to 2.3.2 and it seems there are other areas where Magento ignores the fact that a module is disabled. During "Repositories code generation":
Fatal error: Interface 'MSP\ReCaptcha\Model\Provider\FailureProviderInterface' not found in /var/www/magento/vendor/magento/module-paypal-recaptcha/Model/Provider/Failure/PaypalResponseFailure.php on line 25
Fatal error: Interface 'MSP\ReCaptcha\Model\Provider\FailureProviderInterface' not found in /var/www/magento/vendor/magento/module-paypal-recaptcha/Model/Provider/Failure/PaypalResponseFailure.php on line 25
Partial trace
#0 /var/www/magento/vendor/composer/ClassLoader.php(444): include()
#1 /var/www/magento/vendor/composer/ClassLoader.php(322): Composer\\Autoload\\includeFile(\'/var/www/magent...\')
#2 [internal function]: Composer\\Autoload\\ClassLoader->loadClass(\'Magento\\\\PaypalR...\')
#3 [internal function]: spl_autoload_call(\'Magento\\\\PaypalR...\')
#4 /var/www/magento/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(125): class_exists(\'Magento\\\\PaypalR...\')
#5 /var/www/magento/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(111): Magento\\Setup\\Module\\Di\\Code\\Reader\\ClassesScanner->includeClasses(Array, \'/var/www/magent...\')
#6 /var/www/magento/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(82): Magento\\Setup\\Module\\Di\\Code\\Reader\\ClassesScanner->extract(Object(RecursiveIteratorIterator))
#7 /var/www/magento/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php(61): Magento\\Setup\\Module\\Di\\Code\\Reader\\ClassesScanner->getList(\'/var/www/magent...\')
I have the Magento_PaypalReCaptcha module disabled though...
cat app/etc/config.php | grep Magento_PaypalReCaptcha
'Magento_PaypalReCaptcha' => 0,
Magento even recognizes the module as disabled per the CLI tool.
magento module:status | grep -E "(Magento_PaypalReCaptcha|disabled|enabled)"
List of enabled modules:
List of disabled modules:
Magento_PaypalReCaptcha
I understand that Magento wants to fill the platform will all kinds of goodies, but the app should certainly respect the decision of a developer to use a core feature that Magento provides (disabling modules).
I will create a ticket for that issue and link it here when I do.
Having this issue on 2.3.2 as well.
@scottsb I tested this on branch 2.3-develop and was not able to reproduce this.
This is the scenario I used:
<event name="this_custom_event">
<observer name="vendor_module_event"
instance="Vendor\Module\Observer\Event" />
</event>
<?php
namespace Vendor\Module\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer;
class Event implements ObserverInterface
{
public function execute(Observer $observer)
{
var_dump("i got fired");
}
}
$this->eventManager->dispatch("this_custom_event"); My results:
The var_dump is only shown when the 'Vendor_Module' is enabled.
Can you give me some more information on how to reproduce this issue or verify my test?
thx!
Hi @duckchip. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:
Component: XXXXX label(s) to the ticket, indicating the components it may be related to.[ ] 2. Verify that the issue is reproducible on 2.3-develop branchDetails
- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!
[ ] 3. If the issue is not relevant or is not reproducible any more, feel free to close it.
Hi @shikhamis11. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:
Component: XXXXX label(s) to the ticket, indicating the components it may be related to.[ ] 2. Verify that the issue is reproducible on 2.4-develop branchDetails
- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!
[ ] 3. If the issue is not relevant or is not reproducible any more, feel free to close it.
I also tried to reproduce this issue on magento 2.3.4 instance but it is not reproducible now
@scottsb can you confirm the same ?
Most helpful comment
@magento-engcom-team Any update on this? This is causing issues in 2.3 with the new
MSP_ReCaptchamodule... we have it disabled and we are getting errors like:...because the Virtual Types are not getting compiled (since the module is disabled) but the events are still firing.