diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2016-08-13 01:19:09 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2016-08-13 01:21:57 +0200 |
commit | 175d94b6e5df80e2eadec0460c1ad21bda12c02e (patch) | |
tree | 68470652e1939521f91b0f7654b5a4d459323e89 /ext/pdo | |
parent | 92a076a92bf7d2fb20e0bc5d376ce65fab268b52 (diff) | |
parent | 7938ebf6c1b302d3d1b1bfb798f1cf6f07e1e178 (diff) | |
download | php-git-175d94b6e5df80e2eadec0460c1ad21bda12c02e.tar.gz |
Merge branch 'PHP-5.6' into PHP-7.0
Diffstat (limited to 'ext/pdo')
-rw-r--r-- | ext/pdo/pdo_stmt.c | 9 | ||||
-rw-r--r-- | ext/pdo/tests/bug_60665.phpt | 41 |
2 files changed, 49 insertions, 1 deletions
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 8d1d909acc..d135467192 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2564,7 +2564,14 @@ static int row_prop_exists(zval *object, zval *member, int check_empty, void **c for (colno = 0; colno < stmt->column_count; colno++) { if (ZSTR_LEN(stmt->columns[colno].name) == Z_STRLEN_P(member) && strncmp(ZSTR_VAL(stmt->columns[colno].name), Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0) { - return 1; + int res; + zval val; + + fetch_value(stmt, &val, colno, NULL TSRMLS_CC); + res = check_empty ? i_zend_is_true(&val) : Z_TYPE(val) != IS_NULL; + zval_dtor(&val); + + return res; } } } diff --git a/ext/pdo/tests/bug_60665.phpt b/ext/pdo/tests/bug_60665.phpt new file mode 100644 index 0000000000..28c1482154 --- /dev/null +++ b/ext/pdo/tests/bug_60665.phpt @@ -0,0 +1,41 @@ +--TEST-- +PDO Common: Bug #60665 (call to empty() on NULL result using PDO::FETCH_LAZY returns false) +--SKIPIF-- +<?php +if (!extension_loaded('pdo')) die('skip'); +$dir = getenv('REDIR_TEST_DIR'); +if (false == $dir) die('skip no driver'); +require_once $dir . 'pdo_test.inc'; +PDOTest::skip(); +?> +--FILE-- +<?php +if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/'); +require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; +$db = PDOTest::factory(); + +$statement = $db->prepare("SELECT NULL AS null_value, 0 AS zero, 1 AS one"); +$statement->execute(); +$row = $statement->fetch(PDO::FETCH_LAZY); +var_dump( + empty($row->null_value), + empty($row->zero), + !empty($row->one), + empty($row->missing), + !isset($row->null_value), + isset($row->zero), + isset($row->one), + !isset($row->missing) +); +?> +===DONE=== +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +===DONE=== |