Skip to content

Creating a preference for category product indexer breaks setup:di:compile #22769

Closed
@mbijnsdorp

Description

@mbijnsdorp

Summary

When you create a preference for the category product indexer, code compilation breaks. This is because of the definition of the category product indexer execute method: https://github.com/magento/magento2/blob/2.3.1/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Full.php#L155:

public function execute(): self
{
    $this->createTables();
    $this->clearReplicaTables();
    $this->reindex();
    $this->switchTables();
    return $this;
}

Due to the preference, the generated interceptor (Magento already has a plugin defined for the execute method), returns the preferenced class instead of the the Magento indexer, which then doesn't match : self.

Preconditions (*)

  1. Magento version: 2.3.1
  2. PHP 7.2.12

Steps to reproduce (*)

  1. Create a preference for \Magento\Catalog\Model\Indexer\Category\Product\Action\Full in a custom module
  2. Run bin/magento setup:di:compile

Expected result (*)

  1. Code is compiled

Actual result (*)

  1. Fatal error: Declaration of Vendor\Module\Model\Indexer\Category\Product\Action\Full\Interceptor::execute(): Vendor\Module\Model\Indexer\Category\Product\Action\Full must be compatible with Magento\Catalog\Model\Indexer\Category\Product\Action\Full::execute(): Magento\Catalog\Model\Indexer\Category\Product\Action\Full in /var/www/html/generated/code/Vendor/Module/Model/Indexer/Category/Product/Action/Full/Interceptor.php on line 7
/**
 * {@inheritdoc}
 */
public function execute() : \Vendor\Module\Model\Indexer\Category\Product\Action\Full
{
    $pluginInfo = $this->pluginList->getNext($this->subjectType, 'execute');
    if (!$pluginInfo) {
        return parent::execute();
    } else {
        return $this->___callPlugins('execute', func_get_args(), $pluginInfo);
    }
}

Metadata

Metadata

Assignees

Labels

Component: CatalogFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentPartner: YouweReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasepartners-contributionPull Request is created by Magento Partner

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions