-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Component: Framework/ConsoleIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseThe issue has been reproduced on latest 2.3 release
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
Component: Framework/ConsoleIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseThe issue has been reproduced on latest 2.3 release