From 09f52cfcc8ced8bed60e5c1702e6f35cf3fe1f29 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Sat, 23 Sep 2023 23:08:02 +0200 Subject: Pass NULL instead of array containing NULL element --- core/namespace/ORM/Repositories/CategoryRepository.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'core/namespace') diff --git a/core/namespace/ORM/Repositories/CategoryRepository.php b/core/namespace/ORM/Repositories/CategoryRepository.php index 8692079..7c7b3f9 100644 --- a/core/namespace/ORM/Repositories/CategoryRepository.php +++ b/core/namespace/ORM/Repositories/CategoryRepository.php @@ -42,7 +42,13 @@ class CategoryRepository extends Repository { $query = sprintf($query, $table, $field, $check, $table); $Statement = $this->Database->prepare($query); - $Statement->execute([$value]); + $Statement->execute( + # If $value is NULL, pass NULL instead of an array with one NULL + # element. PHP >= 8 will throw a PDOException when the number of + # bound variables doesn't matches the number of tokens ("?") in + # the SQL query, which is the case here if $value is NULL. + is_null($value) ? NULL : [$value] + ); # TODO: Virtual column _depth shall not be fetched into the entity class return $this->fetchEntities($Statement); -- cgit v1.2.3