Closed
Description
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 (*)
- Magento version: 2.3.1
- PHP 7.2.12
Steps to reproduce (*)
- Create a preference for \Magento\Catalog\Model\Indexer\Category\Product\Action\Full in a custom module
- Run
bin/magento setup:di:compile
Expected result (*)
- Code is compiled
Actual result (*)
- 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
The issue has been fixed in 2.3 release lineGate 2 Passed. Manual verification of the issue description passedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 1 Passed. Automatic verification of issue format passedGate 4. Acknowledged. Issue is added to backlog and ready for developmentThe issue has been reproduced on latest 2.3 releasePull Request is created by Magento Partner