pierrick Sun, 03 Jan 2010 16:59:33 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=293039
Log: Fixed bug #50636 (MySQLi_Result sets values before calling constructor) Bug: http://bugs.php.net/50636 (Open) MySQLi_Result sets values before calling constructor Changed paths: U php/php-src/branches/PHP_5_2/NEWS U php/php-src/branches/PHP_5_2/ext/mysqli/mysqli.c A php/php-src/branches/PHP_5_2/ext/mysqli/tests/bug50636.phpt U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/mysqli/mysqli.c A php/php-src/branches/PHP_5_3/ext/mysqli/tests/bug50636.phpt U php/php-src/trunk/ext/mysqli/mysqli.c A php/php-src/trunk/ext/mysqli/tests/bug50636.phpt Modified: php/php-src/branches/PHP_5_2/NEWS =================================================================== --- php/php-src/branches/PHP_5_2/NEWS 2010-01-03 16:57:38 UTC (rev 293038) +++ php/php-src/branches/PHP_5_2/NEWS 2010-01-03 16:59:33 UTC (rev 293039) @@ -11,6 +11,8 @@ - Fixed build of mysqli with MySQL 5.5.0-m2. (Andrey) +- Fixed bug #50636 (MySQLi_Result sets values before calling constructor). + (Pierrick) - Fixed bug #50575 (PDO_PGSQL LOBs are not compatible with PostgreSQL 8.5). (Matteo) - Fixed bug #50558 (Broken object model when extending tidy). (Pierrick) Modified: php/php-src/branches/PHP_5_2/ext/mysqli/mysqli.c =================================================================== --- php/php-src/branches/PHP_5_2/ext/mysqli/mysqli.c 2010-01-03 16:57:38 UTC (rev 293038) +++ php/php-src/branches/PHP_5_2/ext/mysqli/mysqli.c 2010-01-03 16:59:33 UTC (rev 293039) @@ -936,7 +936,6 @@ zval *retval_ptr; object_and_properties_init(return_value, ce, NULL); - zend_merge_properties(return_value, Z_ARRVAL(dataset), 1 TSRMLS_CC); if (ce->constructor) { fci.size = sizeof(fci); @@ -991,6 +990,8 @@ } else if (ctor_params) { zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "Class %s does not have a constructor hence you cannot use ctor_params", ce->name); } + + zend_merge_properties(return_value, Z_ARRVAL(dataset), 1 TSRMLS_CC); } } /* }}} */ Added: php/php-src/branches/PHP_5_2/ext/mysqli/tests/bug50636.phpt =================================================================== --- php/php-src/branches/PHP_5_2/ext/mysqli/tests/bug50636.phpt (rev 0) +++ php/php-src/branches/PHP_5_2/ext/mysqli/tests/bug50636.phpt 2010-01-03 16:59:33 UTC (rev 293039) @@ -0,0 +1,35 @@ +--TEST-- +Bug #50636 (MySQLi_Result sets values before calling constructor) +--SKIPIF-- +<?php +require_once('skipif.inc'); +require_once('skipifconnectfailure.inc'); +?> +--FILE-- +<?php + include ("connect.inc"); + + class Book { + private $title = 0; + + function __construct() { + $this->title = 'foobar'; + } + + function __set($name, $value) { + $this->{$name} = $value; + } + } + + $link = new mysqli($host, $user, $passwd); + var_dump($link->query('SELECT "PHP" AS title, "Rasmus" AS author')->fetch_object('Book')); + echo "done!"; +?> +--EXPECTF-- +object(Book)#%d (2) { + ["title:private"]=> + string(3) "PHP" + ["author"]=> + string(6) "Rasmus" +} +done! Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2010-01-03 16:57:38 UTC (rev 293038) +++ php/php-src/branches/PHP_5_3/NEWS 2010-01-03 16:59:33 UTC (rev 293039) @@ -7,6 +7,8 @@ (Ilia) - Added stream_resolve_include_path(). (Mikko) +- Fixed bug #50636 (MySQLi_Result sets values before calling constructor). + (Pierrick) - Fixed bug #48190 (Content-type parameter "boundary" is not case-insensitive in HTTP uploads). (Ilia) - Fixed bug #47409 (extract() problem with array containing word "this"). Modified: php/php-src/branches/PHP_5_3/ext/mysqli/mysqli.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/mysqli/mysqli.c 2010-01-03 16:57:38 UTC (rev 293038) +++ php/php-src/branches/PHP_5_3/ext/mysqli/mysqli.c 2010-01-03 16:59:33 UTC (rev 293039) @@ -1205,7 +1205,6 @@ zval *retval_ptr; object_and_properties_init(return_value, ce, NULL); - zend_merge_properties(return_value, Z_ARRVAL(dataset), 1 TSRMLS_CC); if (ce->constructor) { fci.size = sizeof(fci); @@ -1261,6 +1260,8 @@ } else if (ctor_params) { zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "Class %s does not have a constructor hence you cannot use ctor_params", ce->name); } + + zend_merge_properties(return_value, Z_ARRVAL(dataset), 1 TSRMLS_CC); } } /* }}} */ Added: php/php-src/branches/PHP_5_3/ext/mysqli/tests/bug50636.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/mysqli/tests/bug50636.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/ext/mysqli/tests/bug50636.phpt 2010-01-03 16:59:33 UTC (rev 293039) @@ -0,0 +1,35 @@ +--TEST-- +Bug #50636 (MySQLi_Result sets values before calling constructor) +--SKIPIF-- +<?php +require_once('skipif.inc'); +require_once('skipifconnectfailure.inc'); +?> +--FILE-- +<?php + include ("connect.inc"); + + class Book { + private $title = 0; + + function __construct() { + $this->title = 'foobar'; + } + + function __set($name, $value) { + $this->{$name} = $value; + } + } + + $link = new mysqli($host, $user, $passwd); + var_dump($link->query('SELECT "PHP" AS title, "Rasmus" AS author')->fetch_object('Book')); + echo "done!"; +?> +--EXPECTF-- +object(Book)#%d (2) { + ["title":"Book":private]=> + string(3) "PHP" + ["author"]=> + string(6) "Rasmus" +} +done! Modified: php/php-src/trunk/ext/mysqli/mysqli.c =================================================================== --- php/php-src/trunk/ext/mysqli/mysqli.c 2010-01-03 16:57:38 UTC (rev 293038) +++ php/php-src/trunk/ext/mysqli/mysqli.c 2010-01-03 16:59:33 UTC (rev 293039) @@ -1237,7 +1237,6 @@ zval *retval_ptr; object_and_properties_init(return_value, ce, NULL); - zend_merge_properties(return_value, Z_ARRVAL(dataset), 1 TSRMLS_CC); if (ce->constructor) { fci.size = sizeof(fci); @@ -1293,6 +1292,8 @@ } else if (ctor_params) { zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "Class %v does not have a constructor hence you cannot use ctor_params", ce->name); } + + zend_merge_properties(return_value, Z_ARRVAL(dataset), 1 TSRMLS_CC); } } /* }}} */ Added: php/php-src/trunk/ext/mysqli/tests/bug50636.phpt =================================================================== --- php/php-src/trunk/ext/mysqli/tests/bug50636.phpt (rev 0) +++ php/php-src/trunk/ext/mysqli/tests/bug50636.phpt 2010-01-03 16:59:33 UTC (rev 293039) @@ -0,0 +1,35 @@ +--TEST-- +Bug #50636 (MySQLi_Result sets values before calling constructor) +--SKIPIF-- +<?php +require_once('skipif.inc'); +require_once('skipifconnectfailure.inc'); +?> +--FILE-- +<?php + include ("connect.inc"); + + class Book { + private $title = 0; + + function __construct() { + $this->title = 'foobar'; + } + + function __set($name, $value) { + $this->{$name} = $value; + } + } + + $link = new mysqli($host, $user, $passwd); + var_dump($link->query('SELECT "PHP" AS title, "Rasmus" AS author')->fetch_object('Book')); + echo "done!"; +?> +--EXPECTF-- +object(Book)#%d (2) { + [%u|b%"title":%u|b%"Book":private]=> + %unicode|string%(3) "PHP" + [%u|b%"author"]=> + %unicode|string%(6) "Rasmus" +} +done!
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php