From fdc95ef179af3ce01378dc6074171a06bcb6af45 Mon Sep 17 00:00:00 2001 From: Lorenzo Stanco Date: Fri, 21 Jan 2022 11:59:15 +0100 Subject: [PATCH 1/2] Fixed stdClass constructor in mysql_fetch_object() Fixed error "stdClass does not have a constructor hence you cannot use ctor_params" when explicitly passing `"stdClass"` instead of `null` to `mysql_fetch_object()` --- lib/mysql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mysql.php b/lib/mysql.php index afee938..9e2a361 100644 --- a/lib/mysql.php +++ b/lib/mysql.php @@ -384,7 +384,7 @@ function mysql_fetch_object($result, $class = null, array $params = array()) /* // @codeCoverageIgnoreEnd } - if ($class === null) { + if ($class === null || $class === 'stdClass') { $object = mysqli_fetch_object($result); } else { $object = mysqli_fetch_object($result, $class, $params); From 870b5ec53df8f7ace6f5b5a8847ab29199f2fcc4 Mon Sep 17 00:00:00 2001 From: Lorenzo Stanco Date: Fri, 21 Jan 2022 15:58:22 +0100 Subject: [PATCH 2/2] Fixed class constructor call in mysql_fetch_object() Fixed error "Class does not have a constructor hence you cannot use ctor_params" when passing a class name with no defined constructor to `mysql_fetch_object()` --- lib/mysql.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/mysql.php b/lib/mysql.php index 9e2a361..e347c1a 100644 --- a/lib/mysql.php +++ b/lib/mysql.php @@ -384,8 +384,10 @@ function mysql_fetch_object($result, $class = null, array $params = array()) /* // @codeCoverageIgnoreEnd } - if ($class === null || $class === 'stdClass') { + if ($class === null) { $object = mysqli_fetch_object($result); + } else if (!method_exists($class, '__construct')) { + $object = mysqli_fetch_object($result, $class); } else { $object = mysqli_fetch_object($result, $class, $params); }