From 3a1ee16c4989de131c44cfa994245cb1bda40975 Mon Sep 17 00:00:00 2001 From: Alin Eugen Deac Date: Thu, 10 Oct 2024 15:30:59 +0200 Subject: [PATCH] Fix resource not escaped correctly (#53100) When bindings contain a resource (e.g. file resource), then it is not escaped correctly. Additionally, the gettype() call is to ensure that a closed resource is also escaped correctly. The latter is an edge-case scenario, which can be encountered in situations when a file handler has already been closed, and one attempts to log the executed query, e.g. via using barryvdh/laravel-debugbar. --- src/Illuminate/Database/Query/Grammars/Grammar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Query/Grammars/Grammar.php b/src/Illuminate/Database/Query/Grammars/Grammar.php index 3478de3b2509..1d3148f21150 100755 --- a/src/Illuminate/Database/Query/Grammars/Grammar.php +++ b/src/Illuminate/Database/Query/Grammars/Grammar.php @@ -1526,7 +1526,7 @@ protected function removeLeadingBoolean($value) */ public function substituteBindingsIntoRawSql($sql, $bindings) { - $bindings = array_map(fn ($value) => $this->escape($value), $bindings); + $bindings = array_map(fn ($value) => $this->escape($value, is_resource($value) || gettype($value) === 'resource (closed)'), $bindings); $query = '';