Skip to content

Commit

Permalink
Fixes ensureDependenciesExist runtime error (#43626)
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro authored Aug 11, 2022
1 parent 8ec9ede commit fdf3ae9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
12 changes: 5 additions & 7 deletions src/Illuminate/Database/Console/DatabaseInspectionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,15 @@ protected function getConfigFromDatabase($database)
/**
* Ensure the dependencies for the database commands are available.
*
* @return int|null
* @return bool
*/
protected function ensureDependenciesExist()
{
if (! interface_exists('Doctrine\DBAL\Driver')) {
if (! $this->components->confirm('Displaying model information requires the Doctrine DBAL (doctrine/dbal) package. Would you like to install it?')) {
return 1;
return tap(interface_exists('Doctrine\DBAL\Driver'), function ($dependenciesExist) {
if (! $dependenciesExist && $this->components->confirm('Inspecting database information requires the Doctrine DBAL (doctrine/dbal) package. Would you like to install it?')) {
$this->installDependencies();
}

return $this->installDependencies();
}
});
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Illuminate/Database/Console/ShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class ShowCommand extends DatabaseInspectionCommand
*/
public function handle(ConnectionResolverInterface $connections)
{
$this->ensureDependenciesExist();
if (! $this->ensureDependenciesExist()) {
return 1;
}

$connection = $connections->connection($database = $this->input->getOption('database'));

Expand Down
4 changes: 3 additions & 1 deletion src/Illuminate/Database/Console/TableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class TableCommand extends DatabaseInspectionCommand
*/
public function handle(ConnectionResolverInterface $connections)
{
$this->ensureDependenciesExist();
if (! $this->ensureDependenciesExist()) {
return 1;
}

$connection = $connections->connection($this->input->getOption('database'));

Expand Down
4 changes: 3 additions & 1 deletion src/Illuminate/Foundation/Console/ShowModelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ class ShowModelCommand extends DatabaseInspectionCommand
*/
public function handle()
{
$this->ensureDependenciesExist();
if (! $this->ensureDependenciesExist()) {
return 1;
}

$class = $this->qualifyModel($this->argument('model'));

Expand Down

0 comments on commit fdf3ae9

Please sign in to comment.