magento2: Magento_Newsletter cannot be disabled
There are several classes under the Magento\Customer (and one under Magento\Review) namespace that are requiring Magento\Newsletter classes, making it impossible to successfully disable/remove the newsletter module, if one uses another solution.
Magento\Customer\Block\Account\DashboardMagento\Customer\Block\Account\Dashboard\InfoMagento\Customer\Block\Adminhml\Edit\Tab\NewsletterMagento\Customer\Block\Adminhml\Edit\Tab\Newsletter\GridMagento\Customer\Block\Adminhml\Edit\Tab\Newsletter\Grid\Renderer\StatusMagento\Customer\Controller\Adminhtml\IndexMagento\Customer\Controller\Adminhtml\Index\CartMagento\Customer\Controller\Adminhtml\Index\NewsletterMagento\Customer\Controller\Adminhtml\Index\SaveMagento\Customer\Controller\Adminhtml\Index\ViewfileMagento\Customer\Controller\Adminhtml\Customer\InvalidateTokenMagento\Review\Block\Customer\ListCustomer
From those classes, several ones are requiring \Magento\Newsletter\Model\SubscriberFactory but they end up not even using it, basically declaring dependencies to classes that are not needed.
Preconditions
- To a instance of Magento 2.3.3 installed via Composer, add the following section to the
composer.json:
{
"replace": {
"magento/module-newsletter": "*"
}
}
Steps to reproduce
composer update --lock -vvv;php bin/magento setup:di:compile
Expected result
- Compilation is successful.
Actual result
Class Magento\Newsletter\Model\SubscriberFactory does not exist
Class Magento\Customer\Controller\Adminhtml\Index\Save\Interceptor generation error: The requested class did not generate properly, because the 'generated' directory permission is read-only. If --- after running the 'bin/magento setup:di:compile' CLI command when the 'generated' directory permission is set to write --- the requested class did not generate properly, then you must add the generated class object to the signature of the related construct method, only.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 2
- Comments: 15 (7 by maintainers)
@augrinovska
The Actual result has two lines, the first one being:
Because that class doesn’t exist, the model generation for the second one fails as well. It has nothing to do with the permissions, the second error happens because it was trying to read the class from the
generatedfolder and it wasn’t there, because it failed while generating the previous class.In any case, this can be also very easily checked by looking into the source code. For example, app/code/Magento/Customer/Block/Account/Dashboard.php on
2.4-developis trying to use theSubscriberFactoryclass, which is declared inside theMagento_Newslettermodule.So, please open the ticket again, as you will not be able to test this error on
2.4-developunless you manually delete theapp/code/Magento/Newsletterbefore running the compilation.