From: Nikita Popov Date: Tue, 15 Dec 2020 16:11:51 +0000 (+0100) Subject: Fix ATTR_ORACLE_NULLS with PARAM_ZVAL X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cfe2b36a6db6ed2b1af7a574ed36abadfa18285f;p=php Fix ATTR_ORACLE_NULLS with PARAM_ZVAL PARAM_ZVAL with a STR result should be treated the same way as PARAM_STR in this regard. --- diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 5163e65a98..b1b6fb9907 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -520,6 +520,12 @@ static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, int *typ case PDO_PARAM_ZVAL: if (value && value_len == sizeof(zval)) { ZVAL_COPY_VALUE(dest, (zval *)value); + + if (Z_TYPE_P(dest) == IS_STRING && Z_STRLEN_P(dest) == 0 + && stmt->dbh->oracle_nulls == PDO_NULL_EMPTY_STRING) { + zval_ptr_dtor_str(dest); + ZVAL_NULL(dest); + } } else { ZVAL_NULL(dest); } diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt index 1b6941c583..d7f54bfdee 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt @@ -112,11 +112,11 @@ array(1) { ["z"]=> NULL ["a"]=> - string(0) "" + NULL ["b"]=> string(1) " " ["c"]=> - string(0) "" + NULL ["d"]=> string(2) " d" ["e"]=> @@ -131,11 +131,11 @@ array(1) { ["z"]=> NULL ["a"]=> - string(0) "" + NULL ["b"]=> string(1) " " ["c"]=> - string(0) "" + NULL ["d"]=> string(2) " d" ["e"]=>