Closed
Description
Preconditions
- Magento 2.2.4
- Empty database
Steps to reproduce
- Create a module, containing a console command
- Use ProductRepositoryInterface in console command constructor
- run bin/magento setup:install
Expected result
- Setup completing succesfully
Actual result
- Database exception, claiming table 'website' does not exist
Analysis
The root cause seems to be in the Magento\Setup\Model\ObjectManagerProvider
class, which calls createCliCommands
in it's get
function. This will break setup when there are any console commands that depend on the database to exist already. I have seen this happen with the ProductRepository for example.
What is the reason for this createCliCommands call? If I just disable that call, the setup will complete succesfully.
It also seems strange that this call is only present in the CLI SAPI, which means functionality is different between CLI or web installation.
Example
<?php
namespace Test\Test\Console\Command;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Symfony\Component\Console\Command\Command;
class TestCommand extends Command
{
/**
* @var ProductRepositoryInterface
*/
private $productRepository;
public function __construct(
ProductRepositoryInterface $productRepository,
string $name = null
)
{
parent::__construct($name);
$this->productRepository = $productRepository;
}
protected function configure()
{
$this->setName('test:test')
->setDescription('Test command');
parent::configure();
}
}
Metadata
Metadata
Assignees
Labels
Gate 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.2 releaseThe issue has been reproduced on latest 2.3 release