1--TEST-- 2PDO Common: Bug #44409 (PDO::FETCH_SERIALIZE calls __construct()) 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/'); 15require getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; 16$db = PDOTest::factory(); 17 18$db->exec("CREATE TABLE test44409 (dat varchar(100))"); 19$db->exec("INSERT INTO test44409 (dat) VALUES ('Data from DB')"); 20 21class bug44409 implements Serializable 22{ 23 public function __construct() 24 { 25 printf("Method called: %s()\n", __METHOD__); 26 } 27 28 public function serialize() 29 { 30 return "any data from serizalize()"; 31 } 32 33 public function unserialize($dat) 34 { 35 printf("Method called: %s(%s)\n", __METHOD__, var_export($dat, true)); 36 } 37} 38 39$stmt = $db->query("SELECT * FROM test44409"); 40 41print_r($stmt->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE, "bug44409")); 42 43?> 44--CLEAN-- 45<?php 46require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; 47$db = PDOTest::factory(); 48PDOTest::dropTableIfExists($db, "test44409"); 49?> 50--EXPECTF-- 51Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d 52 53Deprecated: PDOStatement::fetchAll(): The PDO::FETCH_SERIALIZE mode is deprecated in %s on line %d 54Method called: bug44409::unserialize('Data from DB') 55Array 56( 57 [0] => bug44409 Object 58 ( 59 ) 60 61) 62