#28765 [NEW]: get_object_vars returns blank array for a mysqli object

From: Date: Mon, 14 Jun 2004 00:49:12 +0000
Subject: #28765 [NEW]: get_object_vars returns blank array for a mysqli object
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-60854@lists.php.net to get a copy of this message
From: chall5 at tamapbay dot rr dot com Operating system: linux fedora core 2 PHP version: 5.0.0RC3 PHP Bug Type: Class/Object related Bug description: get_object_vars returns blank array for a mysqli object Description: ------------ using get_object_vars() on a mysqli object returns an empty array. As I am able to access vars such as host_info via $mysqliObj->host_info, i would expect this to be a public var, which I would expect to be returned from get_object_vars($mysqliObj). to test this, i defined a test class with a public var, a private var, and a protected var. after instatiating the class an setting each of the vars to a string value, i called get_object_vars() on the object and as expected, only the public var was returned in the array from the function. I also tested get_class_methods() and get_class_vars() on the mysqli object. get_class_methods() does return an array of method names. get_class_vars() returns an empty array. these tests are NOT included in the attached code. Reproduce code: --------------- <?php class testClass { public $a; private $b; protected $c; public function test() { $this->a = "a"; $this->b = "b"; $this->c = "c"; } } $mysqli = new mysqli("localhost", "root", "vnbeRTC", "mysql"); echo "mysqli class:\n"; echo "host info: ".$mysqli->host_info."\n\n"; // direct access, public var??? echo "get_object_vars(\$mysqli)\n"; print_r(get_object_vars($mysqli)); // prints empty array $mysqli->close(); echo "\ntestClass class:\n"; $test = new testClass; $test->test(); echo "get_object_vars(\$test)\n"; print_r(get_object_vars($test)); // prints public vars only (expected) print_r(get_class_vars($test)); // strange output for protected var name ?> Expected result: ---------------- array returned from get_object_vars() on a mysqli object would return an array containing all public vars in the object. Actual result: -------------- the returned array was empty. -- Edit bug report at http://bugs.php.net/?id=28765&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28765&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28765&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=28765&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=28765&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=28765&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=28765&r=needscript Try newer version: http://bugs.php.net/fix.php?id=28765&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=28765&r=support Expected behavior: http://bugs.php.net/fix.php?id=28765&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=28765&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=28765&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=28765&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28765&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=28765&r=dst IIS Stability: http://bugs.php.net/fix.php?id=28765&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=28765&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=28765&r=float

« previous php.bugs (#60854) next »