[BUGFIX] Add missing check in PreparedStatement->execute() 52/32452/2
authorJacob Rasmussen <jacob@omnius.dk>
Wed, 27 Aug 2014 15:32:26 +0000 (17:32 +0200)
committerMarkus Klein <klein.t3@reelworx.at>
Wed, 27 Aug 2014 19:10:35 +0000 (21:10 +0200)
When using prepared statements for inserts and updates, the
execute method currently fails due to a missing check on the
return value from $this->statement->result_metadata();

Resolves: #61229
Releases: 6.3, 6.2
Change-Id: Ida17f617915c36a0c2e91663eee64b4c358090e2
Reviewed-on: http://review.typo3.org/32452
Reviewed-by: Mattias Nilsson <tollepjaer@gmail.com>
Tested-by: Mattias Nilsson <tollepjaer@gmail.com>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/core/Classes/Database/PreparedStatement.php

index cc76c0e..f6c3b0a 100644 (file)
@@ -350,6 +350,7 @@ class PreparedStatement {
                for ($i = 0; $i < $numberOfExtraParamArguments; $i++) {
                        $bindParamArguments[] = &$values[$i];
                }
+
                call_user_func_array(array($this->statement, 'bind_param'), $bindParamArguments);
 
                $success = $this->statement->execute();
@@ -363,8 +364,10 @@ class PreparedStatement {
                        // Store the list of fields
                        if ($this->statement instanceof \mysqli_stmt) {
                                $result = $this->statement->result_metadata();
-                               $fields = $result->fetch_fields();
-                               $result->close();
+                               if ($result instanceof \mysqli_result) {
+                                       $fields = $result->fetch_fields();
+                                       $result->close();
+                               }
                        } else {
                                $fields = $this->statement->fetch_fields();
                        }