]> granicus.if.org Git - php/commitdiff
Fixed bug #68351 (PDO::PARAM_BOOL and ATTR_EMULATE_PREPARES misbehaving)
authorMatteo Beccati <mbeccati@php.net>
Thu, 6 Nov 2014 14:46:49 +0000 (15:46 +0100)
committerMatteo Beccati <mbeccati@php.net>
Thu, 6 Nov 2014 14:47:32 +0000 (15:47 +0100)
NEWS
ext/pdo_pgsql/pgsql_statement.c
ext/pdo_pgsql/tests/bug62593.phpt

diff --git a/NEWS b/NEWS
index ef4195132b9f6783486fafa74a0e5898178f31db..2340bea13d4833cc6bf40fc3a89bedfec9803d30 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -36,6 +36,8 @@ PHP                                                                        NEWS
   . Fixed bug #66584 (Segmentation fault on statement deallocation) (Matteo)
   . Fixed bug #67462 (PDO_PGSQL::beginTransaction() wrongly throws exception
     when not in transaction) (Matteo)
+  . Fixed bug #68351 (PDO::PARAM_BOOL and ATTR_EMULATE_PREPARES misbehaving)
+    (Matteo)
 
 - SPL:
   . Fixed bug #68128 (Regression in RecursiveRegexIterator) (Tjerk)
index 1fa7ce4777a1eaaecb516c78ae2712430bbe22c5..4e183311e2d30e0457b8bffdc4217bff63fdf534 100644 (file)
@@ -370,6 +370,7 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
             ((param->param_type & PDO_PARAM_INPUT_OUTPUT) != PDO_PARAM_INPUT_OUTPUT)) {
             SEPARATE_ZVAL(&param->parameter);
             param->param_type = PDO_PARAM_STR;
+                       convert_to_boolean(param->parameter);
             ZVAL_STRINGL(param->parameter, Z_BVAL_P(param->parameter) ? "t" : "f", 1, 1);
         }
     }
index e3ebf46ed53fab8ab4f7077ef6da6a822d7ae225..4ab4566f0011d38bee95ffe4cd3e9af529d27650 100644 (file)
@@ -34,6 +34,19 @@ $query->execute();
 $errors[] = $query->errorInfo();
 var_dump($value);
 
+// Try with strings - Bug #68351
+$value = '0';
+$query->bindParam(':foo', $value, PDO::PARAM_BOOL);
+$query->execute();
+$errors[] = $query->errorInfo();
+var_dump($query->fetchColumn());
+
+$value = "abc";
+$query->bindParam(':foo', $value, PDO::PARAM_BOOL);
+$query->execute();
+$errors[] = $query->errorInfo();
+var_dump($query->fetchColumn());
+
 $expect = 'No errors found';
 
 foreach ($errors as $error)
@@ -48,4 +61,6 @@ echo $expect;
 --EXPECTF--
 bool(true)
 bool(false)
+bool(true)
+bool(false)
 No errors found