summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS4
-rwxr-xr-xext/pdo/pdo_stmt.c2
-rw-r--r--ext/pdo/tests/bug_44409.phpt51
-rw-r--r--ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt1
-rw-r--r--ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_simple.phpt3
5 files changed, 55 insertions, 6 deletions
diff --git a/NEWS b/NEWS
index e25140588a..0861f7ba44 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 200?, PHP 5.3.0 RC 2
+- Fixed bug #44409 (PDO::FETCH_SERIALIZE calls __construct()).
+ (matteo at beccati dot com)
24 Mar 2009, PHP 5.3.0 RC 1
- Upgraded bundled sqlite to version 3.6.11. (Scott)
@@ -22,7 +24,7 @@ PHP NEWS
- Fixed bug #47572 (Undefined constant causes segmentation fault). (Felipe)
- Fixed bug #47549 (get_defined_constants() return array with broken
array categories). (Ilia)
-- Fixed Bug #47443 (metaphone('scratch') returns wrong result). (Felipe)
+- Fixed bug #47443 (metaphone('scratch') returns wrong result). (Felipe)
- Fixed bug #47438 (mysql_fetch_field ignores zero offset). (Johannes)
- Fixed bug #47398 (PDO_Firebird doesn't implements quoter correctly). (Felipe)
- Fixed bug #47390 (odbc_fetch_into - BC in php 5.3.0). (Felipe)
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index 74587af9b2..698ef564d8 100755
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -1241,7 +1241,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value,
switch (how) {
case PDO_FETCH_CLASS:
- if (ce->constructor && !(flags & PDO_FETCH_PROPS_LATE)) {
+ if (ce->constructor && !(flags & (PDO_FETCH_PROPS_LATE | PDO_FETCH_SERIALIZE))) {
stmt->fetch.cls.fci.object_ptr = return_value;
stmt->fetch.cls.fcc.object_ptr = return_value;
if (zend_call_function(&stmt->fetch.cls.fci, &stmt->fetch.cls.fcc TSRMLS_CC) == FAILURE) {
diff --git a/ext/pdo/tests/bug_44409.phpt b/ext/pdo/tests/bug_44409.phpt
new file mode 100644
index 0000000000..fe24fdfb86
--- /dev/null
+++ b/ext/pdo/tests/bug_44409.phpt
@@ -0,0 +1,51 @@
+--TEST--
+PDO Common: Bug #44409 (PDO::FETCH_SERIALIZE calls __construct())
+--SKIPIF--
+<?php # vim:ft=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 getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
+$db = PDOTest::factory();
+
+$db->exec("CREATE TABLE test (dat varchar(100))");
+$db->exec("INSERT INTO test (dat) VALUES ('Data from DB')");
+
+class bug44409 implements Serializable
+{
+ public function __construct()
+ {
+ printf("Method called: %s()\n", __METHOD__);
+ }
+
+ public function serialize()
+ {
+ return "any data from serizalize()";
+ }
+
+ public function unserialize($dat)
+ {
+ printf("Method called: %s(%s)\n", __METHOD__, var_export($dat, true));
+ }
+}
+
+$stmt = $db->query("SELECT * FROM test");
+
+print_r($stmt->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE, "bug44409"));
+
+?>
+--EXPECT--
+Method called: bug44409::unserialize('Data from DB')
+Array
+(
+ [0] => bug44409 Object
+ (
+ )
+
+)
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt
index 5886a82c88..db8f2f5eaa 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt
@@ -131,7 +131,6 @@ object(myclass)#4 (1) {
Using PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE to fetch the object from DB and unserialize it...
myclass::unserialize('C:7:"myclass":19:{Data from serialize}')
-myclass::__construct(PDO shall not call __construct())
object(myclass)#%d (1) {
["myprotected":protected]=>
string(19) "a protected propery"
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_simple.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_simple.phpt
index ba29e6a53e..e9b231cfdd 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_simple.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_simple.phpt
@@ -80,17 +80,14 @@ object(myclass)#%d (0) {
And now magic PDO using fetchAll(PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE)...
myclass::unserialize('Data fetched from DB to be given to unserialize()')
-myclass::__construct('Called by PDO') - note that it must not be called when unserializing
object(myclass)#%d (0) {
}
myclass::unserialize('Data fetched from DB to be given to unserialize()')
-myclass::__construct(NULL) - note that it must not be called when unserializing
object(myclass)#%d (0) {
}
And now PDO using setFetchMode(PDO::FETCH:CLASS|PDO::FETCH_SERIALIZE) + fetch()...
myclass::unserialize('Data fetched from DB to be given to unserialize()')
-myclass::__construct('Called by PDO') - note that it must not be called when unserializing
object(myclass)#%d (0) {
}
done!