felipe          Mon Mar 23 23:02:06 2009 UTC

  Added files:                 
    /php-src/ext/pdo/tests      bug_44409.phpt 

  Modified files:              
    /php-src/ext/pdo    pdo_stmt.c 
  Log:
  - Fixed bug #44409 (PDO::FETCH_SERIALIZE calls __construct()) 
    Patch by: matteo at beccati dot com
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo/pdo_stmt.c?r1=1.216&r2=1.217&diff_format=u
Index: php-src/ext/pdo/pdo_stmt.c
diff -u php-src/ext/pdo/pdo_stmt.c:1.216 php-src/ext/pdo/pdo_stmt.c:1.217
--- php-src/ext/pdo/pdo_stmt.c:1.216    Thu Mar 12 16:12:44 2009
+++ php-src/ext/pdo/pdo_stmt.c  Mon Mar 23 23:02:06 2009
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_stmt.c,v 1.216 2009/03/12 16:12:44 andrei Exp $ */
+/* $Id: pdo_stmt.c,v 1.217 2009/03/23 23:02:06 felipe Exp $ */
 
 /* The PDO Statement Handle Class */
 
@@ -1239,7 +1239,7 @@
                
                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) {

http://cvs.php.net/viewvc.cgi/php-src/ext/pdo/tests/bug_44409.phpt?view=markup&rev=1.1
Index: php-src/ext/pdo/tests/bug_44409.phpt
+++ php-src/ext/pdo/tests/bug_44409.phpt
--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
        (
        )

)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to