creatuity/magento2-interceptors

Disabled plugins are still being called

Opened this issue · 1 comments

When I create a di config in which I want to disable some plugin in given scope the resulted Interceptor still calls the original plugin. For example create a webapi/di.xml in a module with the following content:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Catalog\Model\ResourceModel\Eav\Attribute">
        <plugin name="save_swatches_option_params" disabled="true"/>
    </type>
</config>

My expectation is that this plugin will not be called when the rest request. However the generated interceptor is

/**
 * {@inheritdoc}
 */
public function beforeSave()
{
    $arguments = func_get_args();
    $this->____plugin_save_swatches_option_params()->beforeBeforeSave($this, ...array_values($arguments));

    return parent::beforeSave(...array_values($arguments));
}

/**
 * {@inheritdoc}
 */
public function afterSave()
{
    $arguments = func_get_args();
    $result = parent::afterSave(...array_values($arguments));

    return (($tmp = $this->____plugin_save_swatches_option_params()->afterAfterSave($this, $result, ...array_values($arguments))) !== null) ? $tmp : $result;
}
rhoerr commented

I also ran into this, where a plugin is defined in global scope but disabled in frontend scope. Still gets compiled and executed by this module unless also disabled in global scope. Smile-SA/elasticsuite#2900