mirror of
https://github.com/php/php-src.git
synced 2024-09-23 19:07:26 +00:00
Merge branch 'PHP-5.4'
* PHP-5.4: NEWS for bug #62593 Bug #62593 Updated to account for INOUT parameters Bug #62593 Updated test to verify bindParam doesn't change original value Bug #62593 Updated to always treat zval by value Bug #62593 Added test for change Bug #62593 Updated pdo_pgsql driver to convert boolean values to pg native format in emulation mode
This commit is contained in:
commit
1af3d9d6c9
@ -362,8 +362,20 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
if (param->is_param) {
|
||||
/* We need to manually convert to a pg native boolean value */
|
||||
if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_BOOL &&
|
||||
((param->param_type & PDO_PARAM_INPUT_OUTPUT) != PDO_PARAM_INPUT_OUTPUT)) {
|
||||
SEPARATE_ZVAL(¶m->parameter);
|
||||
param->param_type = PDO_PARAM_STR;
|
||||
ZVAL_STRINGL(param->parameter, Z_BVAL_P(param->parameter) ? "t" : "f", 1, 1);
|
||||
}
|
||||
}
|
||||
#if HAVE_PQPREPARE
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
51
ext/pdo_pgsql/tests/bug62593.phpt
Normal file
51
ext/pdo_pgsql/tests/bug62593.phpt
Normal file
@ -0,0 +1,51 @@
|
||||
--TEST--
|
||||
PDO PgSQL Bug #62593 (Emulate prepares behave strangely with PARAM_BOOL)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
|
||||
require dirname(__FILE__) . '/config.inc';
|
||||
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
PDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
|
||||
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
|
||||
$errors = array();
|
||||
|
||||
$value = true;
|
||||
$query = $db->prepare('SELECT :foo IS FALSE as val_is_false');
|
||||
$query->bindValue(':foo', $value, PDO::PARAM_BOOL);
|
||||
$query->execute();
|
||||
$errors[] = $query->errorInfo();
|
||||
var_dump($value);
|
||||
|
||||
$query->bindValue(':foo', 0, PDO::PARAM_BOOL);
|
||||
$query->execute();
|
||||
$errors[] = $query->errorInfo();
|
||||
|
||||
// Verify bindParam maintains reference and only passes when execute is called
|
||||
$value = true;
|
||||
$query->bindParam(':foo', $value, PDO::PARAM_BOOL);
|
||||
$value = false;
|
||||
$query->execute();
|
||||
$errors[] = $query->errorInfo();
|
||||
var_dump($value);
|
||||
|
||||
$expect = 'No errors found';
|
||||
|
||||
foreach ($errors as $error)
|
||||
{
|
||||
if (strpos('Invalid text representation', $error[2]) !== false)
|
||||
{
|
||||
$expect = 'Invalid boolean found';
|
||||
}
|
||||
}
|
||||
echo $expect;
|
||||
?>
|
||||
--EXPECTF--
|
||||
bool(true)
|
||||
bool(false)
|
||||
No errors found
|
Loading…
Reference in New Issue
Block a user