php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch bindparam-typed-props for PDO Core Bug #80637

Patch version 2021-06-08 13:23 UTC

Return to Bug #80637 | Download this patch
Patch Revisions:

Developer: cmb@php.net

 ext/pdo/pdo_stmt.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index adc921bbd7..49b54fd9a8 100644
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -311,8 +311,17 @@ static int really_register_bound_param(struct pdo_bound_param_data *param, pdo_s
 			ZVAL_STRINGL(parameter, p, len);
 			efree(p);
 		} else {
-			if (!try_convert_to_string(parameter)) {
-				return 0;
+			if (!Z_ISREF(param->parameter)) {
+				if (!try_convert_to_string(parameter)) {
+					return 0;
+				}
+			} else {
+				zend_string *str = zval_try_get_string(parameter);
+				if (!str) {
+					return 0;
+				}
+				ZEND_TRY_ASSIGN_REF_STR(&param->parameter, str);
+				zend_string_release(str);
 			}
 		}
 	} else if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_INT && (Z_TYPE_P(parameter) == IS_FALSE || Z_TYPE_P(parameter) == IS_TRUE)) {
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Oct 27 04:03:38 2021 UTC