1--TEST-- 2PDO Common: Bug #39656 (Crash when calling fetch() on a PDO statement object after closeCursor()) 3--EXTENSIONS-- 4pdo 5--SKIPIF-- 6<?php 7$dir = getenv('REDIR_TEST_DIR'); 8if (false == $dir) die('skip no driver'); 9require_once $dir . 'pdo_test.inc'; 10PDOTest::skip(); 11?> 12--FILE-- 13<?php 14 15if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/'); 16require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; 17$db = PDOTest::factory(); 18 19@$db->exec("DROP TABLE test"); 20$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 21 22$db->exec("CREATE TABLE test (id INTEGER NOT NULL PRIMARY KEY, usr VARCHAR( 256 ) NOT NULL)"); 23$db->exec("INSERT INTO test (id, usr) VALUES (1, 'user')"); 24 25$stmt = $db->prepare("SELECT * FROM test WHERE id = ?"); 26$stmt->bindValue(1, 1, PDO::PARAM_INT ); 27$stmt->execute(); 28$row = $stmt->fetch(); 29var_dump( $row ); 30 31$stmt->execute(); 32$stmt->closeCursor(); 33$row = $stmt->fetch(); // this line will crash CLI 34var_dump( $row ); 35 36@$db->exec("DROP TABLE test"); 37echo "Done\n"; 38?> 39--EXPECT-- 40array(4) { 41 ["id"]=> 42 string(1) "1" 43 [0]=> 44 string(1) "1" 45 ["usr"]=> 46 string(4) "user" 47 [1]=> 48 string(4) "user" 49} 50bool(false) 51Done 52