#43934 [Opn->Bgs]: uncaught exception for wrong parameter type in mysql_fetch_object
| From: | jani@php.net | Date: | Mon, 27 Oct 2008 12:59:26 +0000 |
| Subject: | #43934 [Opn->Bgs]: uncaught exception for wrong parameter type in mysql_fetch_object | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-130193@lists.php.net to get a copy of this message | ||
ID: 43934
Updated by: jani@php.net
Reported By: josmessa at uk dot ibm dot com
-Status: Open
+Status: Bogus
Bug Type: MySQL related
Operating System: Windows XP
PHP Version: 5.2CVS-2008-01-25 (snap)
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Previous Comments:
------------------------------------------------------------------------
[2008-03-07 19:53:17] felipe@php.net
The comments on code justify such behavior:
/* Two problems why we throw exceptions here: PHP is typeless
* and hence passing one argument that's not an array could be
* by mistake and the other way round is possible, too. The
* single value is an array. Also we'd have to make that one
* argument passed by reference.
*/
------------------------------------------------------------------------
[2008-01-25 11:43:06] josmessa at uk dot ibm dot com
Description:
------------
If an argument that is not an array or null is passed as the $params
(also called $ctor_params in source code) argument in mysql_fetch_object
then the below uncaught exception is returned instead of a normal
warning.
The reproduced code below is similar to that of a test case from 5.3,
although by the time that what I have described above was tested no more
rows were in $res so bool(false) was being returned and so this problem
may also be in 5.3
Reproduce code:
---------------
<?php
//select database and table...
$res = mysql_query('SELECT col1 FROM test');
class mysql_fetch_object_test {
public $a = null;
public $b = null;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function toString() {
var_dump($this);
}
}
var_dump(mysql_fetch_object($res, 'mysql_fetch_object_test', 'not
array'));
?>
Actual result:
--------------
Fatal error: Uncaught exception 'Exception' with message 'Parameter
ctor_params must be an array' in ...\mysql_fetch_object.php:25
Stack trace:
#0 ...\mysql_fetch_object.php(25): mysql_fetch_object(Resource id #5,
'mysql_fetch_obj...', 'not array')
#1 {main}
thrown in ...\mysql_fetch_object.php on line 25
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43934&edit=1