From 7b18cd0a92a1b02b28d8dfdbe069892cca896ad9 Mon Sep 17 00:00:00 2001 From: Dominik Hebeler <dominik@suma-ev.de> Date: Wed, 27 Feb 2019 10:39:48 +0100 Subject: [PATCH] Added DB disconnections --- app/Console/Commands/MonthlyRequestsGather.php | 2 +- app/Console/Kernel.php | 2 ++ app/Http/Controllers/StartpageController.php | 1 + app/Http/Middleware/HumanVerification.php | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Console/Commands/MonthlyRequestsGather.php b/app/Console/Commands/MonthlyRequestsGather.php index f2cbb06c0..ef9b138a8 100644 --- a/app/Console/Commands/MonthlyRequestsGather.php +++ b/app/Console/Commands/MonthlyRequestsGather.php @@ -64,7 +64,7 @@ class MonthlyRequestsGather extends Command $this->disableOverusedEngines($sumaFile, $sumas); $this->disableOverusedEngines($sumaEnFile, $sumasEn); - + DB::disconnect('mysql'); } } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 0e5b83e35..c3bb802d4 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -29,12 +29,14 @@ class Kernel extends ConsoleKernel $schedule->call(function () { DB::table('monthlyrequests')->truncate(); + DB::disconnect('mysql'); })->monthlyOn(1, '00:00'); // Delete all of the old humanverification entries $schedule->call(function () { DB::delete('DELETE FROM humanverification WHERE updated_at < (now() - interval 72 hour) AND whitelist = 0 ORDER BY updated_at DESC'); DB::delete('DELETE FROM humanverification WHERE updated_at < (now() - interval 2 week) AND whitelist = 1 ORDER BY updated_at DESC'); + DB::disconnect('mysql'); })->everyThirtyMinutes(); } diff --git a/app/Http/Controllers/StartpageController.php b/app/Http/Controllers/StartpageController.php index 3e7734648..e3288540f 100644 --- a/app/Http/Controllers/StartpageController.php +++ b/app/Http/Controllers/StartpageController.php @@ -48,6 +48,7 @@ class StartpageController extends Controller $sponsors = []; try { $sponsors = DB::table('sponsorenlinks')->where('langcode', 'de')->orderByRaw('LENGTH(linktext)', 'ASC')->get(); + DB::disconnect('mysql'); } catch (\Illuminate\Database\QueryException $e) { Log::info($e); } diff --git a/app/Http/Middleware/HumanVerification.php b/app/Http/Middleware/HumanVerification.php index 2e53d0d39..186604a47 100644 --- a/app/Http/Middleware/HumanVerification.php +++ b/app/Http/Middleware/HumanVerification.php @@ -166,6 +166,7 @@ class HumanVerification ); } } + DB::disconnect('mysql'); } $request->request->add(['verification_id' => $user["uid"], 'verification_count' => $user["unusedResultPages"]]); return $next($request); -- GitLab