From 7334f629baae6e8df8e4235b120522577b8e61a7 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 15 Jun 2020 22:25:10 -0500 Subject: [PATCH] Restore SQL debug output apparently something changed with hasListeners() --- LibreNMS/Util/Laravel.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/LibreNMS/Util/Laravel.php b/LibreNMS/Util/Laravel.php index c83b4f0dd5..ad9c275d09 100644 --- a/LibreNMS/Util/Laravel.php +++ b/LibreNMS/Util/Laravel.php @@ -80,9 +80,10 @@ class Laravel public static function enableQueryDebug() { + static $sql_debug_enabled; $db = Eloquent::DB(); - if ($db && !$db->getEventDispatcher()->hasListeners('Illuminate\Database\Events\QueryExecuted')) { + if ($db && !$sql_debug_enabled) { $db->listen(function (QueryExecuted $query) { // collect bindings and make them a little more readable $bindings = collect($query->bindings)->map(function ($item) { @@ -99,6 +100,7 @@ class Laravel c_echo("SQL[%Y{$query->sql} %y$bindings%n {$query->time}ms] \n"); } }); + $sql_debug_enabled = true; } }