1--TEST-- 2GH-16703: Memory leak of setFetchMode() 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 14if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/'); 15class TestStmt extends PDOStatement 16{ 17 public $name; 18} 19 20$db = new PDO( 21 getenv('PDOTEST_DSN'), 22 getenv('PDOTEST_USER') ?: null, 23 getenv('PDOTEST_PASS') ?: null, 24 [ 25 PDO::ATTR_CASE => PDO::CASE_LOWER, 26 PDO::ATTR_STATEMENT_CLASS => [TestStmt::class], 27 ], 28); 29 30$db->exec('CREATE TABLE gh16703 (name varchar(255))'); 31$db->exec("INSERT INTO gh16703 (name) VALUES ('test_name')"); 32 33$stmt = $db->query('SELECT name FROM gh16703'); 34$t = $stmt; 35$stmt->setFetchMode(PDO::FETCH_INTO, $stmt); 36$stmt->fetch(); 37echo "done!\n"; 38?> 39--CLEAN-- 40<?php 41if (getenv('PDOTEST_DSN') === 'sqlite::memory:') return; 42 43require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; 44$db = PDOTest::factory(); 45$db->exec('DROP TABLE gh16703'); 46?> 47--EXPECT-- 48done! 49