From fdf3ae9760729652673359d3e2cced727ba25b92 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 11 Aug 2022 18:06:49 +0100 Subject: [PATCH] Fixes `ensureDependenciesExist` runtime error (#43626) --- .../Database/Console/DatabaseInspectionCommand.php | 12 +++++------- src/Illuminate/Database/Console/ShowCommand.php | 4 +++- src/Illuminate/Database/Console/TableCommand.php | 4 +++- .../Foundation/Console/ShowModelCommand.php | 4 +++- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/Illuminate/Database/Console/DatabaseInspectionCommand.php b/src/Illuminate/Database/Console/DatabaseInspectionCommand.php index 4acf3998c7fa..ebff1e52629a 100644 --- a/src/Illuminate/Database/Console/DatabaseInspectionCommand.php +++ b/src/Illuminate/Database/Console/DatabaseInspectionCommand.php @@ -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(); - } + }); } /** diff --git a/src/Illuminate/Database/Console/ShowCommand.php b/src/Illuminate/Database/Console/ShowCommand.php index 6a4c300db44c..67f2909e975b 100644 --- a/src/Illuminate/Database/Console/ShowCommand.php +++ b/src/Illuminate/Database/Console/ShowCommand.php @@ -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')); diff --git a/src/Illuminate/Database/Console/TableCommand.php b/src/Illuminate/Database/Console/TableCommand.php index 4076f0f4d1c8..7101879a3920 100644 --- a/src/Illuminate/Database/Console/TableCommand.php +++ b/src/Illuminate/Database/Console/TableCommand.php @@ -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')); diff --git a/src/Illuminate/Foundation/Console/ShowModelCommand.php b/src/Illuminate/Foundation/Console/ShowModelCommand.php index c5bca312f903..5250e717cfa1 100644 --- a/src/Illuminate/Foundation/Console/ShowModelCommand.php +++ b/src/Illuminate/Foundation/Console/ShowModelCommand.php @@ -81,7 +81,9 @@ class ShowModelCommand extends DatabaseInspectionCommand */ public function handle() { - $this->ensureDependenciesExist(); + if (! $this->ensureDependenciesExist()) { + return 1; + } $class = $this->qualifyModel($this->argument('model'));