diff options
author | Pierrick Charron <pierrick@php.net> | 2010-01-03 16:59:33 +0000 |
---|---|---|
committer | Pierrick Charron <pierrick@php.net> | 2010-01-03 16:59:33 +0000 |
commit | c44f57eaff6b441c559855d96d5dddf53fba7cf8 (patch) | |
tree | 98bc7bfda2a0b3f58e6107b6e50489839a268b79 | |
parent | 22f4ef45fed6f34c718aa419f3c97e197e6379f0 (diff) | |
download | php-git-c44f57eaff6b441c559855d96d5dddf53fba7cf8.tar.gz |
Fixed bug #50636 (MySQLi_Result sets values before calling constructor)
-rw-r--r-- | ext/mysqli/mysqli.c | 3 | ||||
-rw-r--r-- | ext/mysqli/tests/bug50636.phpt | 35 |
2 files changed, 37 insertions, 1 deletions
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index 72c37a7f35..d3e855dde7 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -1237,7 +1237,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); @@ -1293,6 +1292,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 %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); } } /* }}} */ diff --git a/ext/mysqli/tests/bug50636.phpt b/ext/mysqli/tests/bug50636.phpt new file mode 100644 index 0000000000..c2d7fd20a2 --- /dev/null +++ b/ext/mysqli/tests/bug50636.phpt @@ -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! |