From: Pierrick Charron Date: Sun, 3 Jan 2010 16:59:33 +0000 (+0000) Subject: Fixed bug #50636 (MySQLi_Result sets values before calling constructor) X-Git-Tag: php-5.2.13RC1~55 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d005f1d2ee03bd2bf68d73b443f691b6ab1abde9;p=php Fixed bug #50636 (MySQLi_Result sets values before calling constructor) --- diff --git a/NEWS b/NEWS index 64ceb696eb..3e2ebfc70b 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,8 @@ PHP NEWS - 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) diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index b6a288a485..008b97f7a0 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -936,7 +936,6 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags 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 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags } 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); } } /* }}} */ diff --git a/ext/mysqli/tests/bug50636.phpt b/ext/mysqli/tests/bug50636.phpt new file mode 100644 index 0000000000..06ddcf36b6 --- /dev/null +++ b/ext/mysqli/tests/bug50636.phpt @@ -0,0 +1,35 @@ +--TEST-- +Bug #50636 (MySQLi_Result sets values before calling constructor) +--SKIPIF-- + +--FILE-- +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!