[BUGFIX] Check for existing types before binding 86/38386/2
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Tue, 24 Mar 2015 10:45:55 +0000 (11:45 +0100)
committerMarkus Klein <klein.t3@reelworx.at>
Tue, 31 Mar 2015 19:14:41 +0000 (21:14 +0200)
Check the $combinedTypes variables if binds actually exist before
calling the bind_param method.

Resolves: #65941
Releases: master, 6.2
Change-Id: I199026819a48b6b96845c4e346fe493971682218
Reviewed-on: http://review.typo3.org/38386
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/core/Classes/Database/PreparedStatement.php

index d332e65..575b047 100644 (file)
@@ -344,14 +344,16 @@ class PreparedStatement {
                }
 
                // ->bind_param requires second up to last arguments as references
-               $bindParamArguments = array();
-               $bindParamArguments[] = $combinedTypes;
-               $numberOfExtraParamArguments = count($values);
-               for ($i = 0; $i < $numberOfExtraParamArguments; $i++) {
-                       $bindParamArguments[] = &$values[$i];
-               }
+               if (!empty($combinedTypes)) {
+                       $bindParamArguments = array();
+                       $bindParamArguments[] = $combinedTypes;
+                       $numberOfExtraParamArguments = count($values);
+                       for ($i = 0; $i < $numberOfExtraParamArguments; $i++) {
+                               $bindParamArguments[] = &$values[$i];
+                       }
 
-               call_user_func_array(array($this->statement, 'bind_param'), $bindParamArguments);
+                       call_user_func_array(array($this->statement, 'bind_param'), $bindParamArguments);
+               }
 
                $success = $this->statement->execute();