I’ve been handed an old Laravel application, which was running v5.1 and have used Shift to upgrade it through the Laravel v9.
The whole app is behind a login ~ and on submit of the login form (correct or fail), it returns:
Too few arguments to function AppProvidersAppServiceProvider::AppProviders{closure}(), 1 passed in /var/www/html/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php on line 421 and exactly 3 expected
and the trace ends in app / Providers / AppServiceProvider.php: 37
, line 37 being function ($sql, $bindings, $time)
....
error_reporting(0);
// public function boot(Guard $auth) {
view()->composer('*', function ($view) use ($auth) {
if ($auth->user()) {
// get the current user
$currentUser = $auth->user();
Log::info('Executed by '.$currentUser->email);
// pass the data to the view
$view->with('currentUser', $currentUser);
}
});
DB::listen(
function ($sql, $bindings, $time) {
$a = print_r($sql, 1);
$b = print_r($bindings, 1);
$logmessage = $a;
if (! empty($b)) {
$logmessage .= ' : '.$b;
}
Log::info($logmessage);
}
);
...
During the Shift process, re. the login/auth process it noted the following:
Laravel 5.3 split the Auth/AuthController.php into the Auth/LoginController.php and the Auth/RegisterController.php. Since yours appears to be customized, Shift did not remove it. You should compare your Auth/AuthController.php with the newly added controllers and merge your changes accordingly.
and
If you are using Authentication, you should upgrade any routes using AuthController and PasswordController to use the new authentication controllers. Laravel recommends using the Auth::routes() which registers the proper routes for the new authentication controllers. This method also registers a POST route for /logout instead of a GET route.
but the highlighted error line seems related to the database connection…
A quick sanity check of database connection:
try {
DB::connection()->getPDO();
echo DB::connection()->getDatabaseName();
} catch (Exception $e) {
echo 'None';
}
returns the correct database connection, as expected.
I’m not a Laravel-specific dev so trying to muddle my way through and no doubt need to provide more debugging info here, so just let me know what else would be helpful.
Thanks in advance
2
Answers
After chatting to the helpful team at Shift, we deduced it was caused by the DB logging.
We removed that block and it resolved everything.
DB::listen
‘s signature has changed to a single argument that contains your three arguments as properties, so you’ll need to adjust that call to fit if you still want to log SQL queries.(I’d suggest replacing with https://github.com/barryvdh/laravel-debugbar or https://laravel.com/docs/10.x/telescope for this purpose, though.)
https://laravel.com/docs/10.x/database