I have a custom module with a plugin for Magento\Framework\Encryption\Encryptor that seems to be causing issues after upgrading to Magento 2.3.2 (from 2.3.1.) When I disable the module, everything works fine. When I enable it, I get "No commands in the namespace" for any namespace I try to use. When I run bin/magento list I get a more detailed error message:

In ServiceManager.php line 1130:

  An abstract factory could not create an instance of magentosetupconsolecommandbackupcommand(alias: Magento\Setup\Console\Command\BackupCommand).

In ServiceManager.php line 941:

  An exception was raised while creating "Magento\Setup\Console\Command\BackupCommand"; no instance returned

In Di.php line 865:

  Missing instance/object for parameter maintenanceMode for Magento\Setup\Console\Command\BackupCommand::__construct

In ServiceManager.php line 1130:

  An abstract factory could not create an instance of magentoframeworkappmaintenancemode(alias: Magento\Framework\App\MaintenanceMode).

In ServiceManager.php line 941:

  An exception was raised while creating "Magento\Framework\App\MaintenanceMode"; no instance returned

In Developer.php line 55:

  Circular dependency: Magento\Framework\Logger\Monolog depends on Magento\Framework\Cache\InvalidateLogger and vice versa.

I'm fairly certain that it's the plugin on Encryptor causing this, because when I remove that plugin from di.xml the error goes away.

I've also tried commenting out all of the methods from the plugin, so that it's just an empty class, but the error persists. It appears to be the bare fact that there is a plugin registered for that class that is causing the error.

Any ideas why this might be? I'm not sure why enabling a plugin would appear to cause an error somewhere else entirely, especially when that plugin doesn't even have any methods in it. It worked perfectly well in 2.3.1, as well.

  • you can define namespace at the top of the class use Magento\Framework\Encryption\Encryptor and if that does not work then share your both codes. In which mode currently you are working(default,devloper,production)
    – Softec
    Jul 16, 2019 at 23:43

1 Answer 1


Ok, it turned out that apparently Magento\Framework\Encryption\Encryptor is just not a class that can accept plugins any more. The Magento docs page on plugins does hint at this, sort of:

Plugins can not be used on following:

  • Final methods
  • Final classes
  • Non-public methods
  • Class methods (such as static methods)
  • __construct
  • Virtual types
  • Objects that are instantiated before Magento\Framework\Interception is bootstrapped

Apparently 2.3.2 switches the order in which modules are loaded, and Encryptor ends up getting instantiated before Interception.

The solution was to subclass and override the original, instead of using a plugin. Example code:

In MyModule/Model/Encryptor.php:

namespace MyModule\Model;
class Encryptor 
    extends \Magento\Framework\Encryption\Encryptor 
    implements \Magento\Framework\Encryption\EncryptorInterface
    public function methodToOverride() 

And in MyModule/etc/di.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Framework\Encryption\Encryptor" type="MyModule\Model\Encryptor" />
  • is there any way we can find out which module is giving problem. As I am also facing same problem after upgrade to 2.3.2, but not getting which module is giving problem :( Sep 3, 2019 at 8:50
  • I doubt it; this error seems to occur before much of Magento's self-inspection capabilities are online. Depending on how many modules you have installed, it may be possible to go through checking their di.xml files for plugin nodes to see if anything is trying to hook into core classes. Sep 4, 2019 at 15:43
  • @JosephMontanaro Can you share how you do that?
    – srokatonie
    Dec 19, 2019 at 15:08
  • @srokatonie edited, see above. Dec 19, 2019 at 18:07
  • @JosephMontanaro I got to the same point but was missing the "extends" part. Thanks, you helped a lot!
    – srokatonie
    Dec 21, 2019 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.