Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.11.0

Bug #2988 "property of non-object" notice when passing table name to tableInfo()
Submitted: 2004-12-19 01:09 UTC
From: timunderwood at gmail dot com Assigned: danielc
Status: Closed Package: DB
PHP Version: 5.0.3 OS: Linux 2.6.9
Roadmaps: (Not assigned)    

 [2004-12-19 01:09 UTC] timunderwood at gmail dot com
Description: ------------ The first line of the DB_mysql::tableInfo appears to be incorrect. It reads: if (isset($result->result)) { But when $result is a string, isset($result->result) returns true: bash-2.05b$ cat test.php <? $string = "Hello"; var_dump(isset($string->result)); ?> bash-2.05b$ php test.php bool(true) which means it never hits the "elseif (is_string($result))" case. So perhaps it should be: if (is_object($result) && isset($result->result)) -or- if (is_object($result) && array_key_exists('result', $result)) or something along those lines. bash-2.05b$ php -v PHP 5.0.3 (cli) (built: Dec 16 2004 22:01:30) Copyright (c) 1997-2004 The PHP Group Zend Engine v2.0.3, Copyright (c) 1998-2004 Zend Technologies


 [2004-12-19 17:25 UTC] danielc
Interesting. PHP changed it's behavior. I'll look into this and get it resolved.
 [2004-12-20 01:00 UTC] php at com dot jkkn dot dk
Notice that this complements the reported bug in php 5.0.3: Which was caused by an attempt to fix this bug: In CVS 'dmitry' added a automatic typecasting of the offset, so in the exmaple "result" is casted to an int (0) and therefore making isset($result[0]) true.
 [2004-12-20 01:20 UTC] danielc
Change summary from "DB_mysql::tableInfo bug fix" to ""property of non-object" notice when passing table name to tableInfo()." Done because this issue applies to most drivers in DB, not just MySQL and better describe the problem. Also, PHP version in header was mistyped as 5.0.2, but this behavioral change arose in 5.0.3 (which is the version noted in the bug report itself)
 [2004-12-20 01:56 UTC] timunderwood at gmail dot com
Yeah I didn't see a "5.0.3" in the dropdown menu when submitting the bug which is why I included the "php -v" output. Thanks for checking this out.
 [2005-01-17 07:54 UTC] danielc
The underlying PHP bug has been resolved in CVS and will be incorporated in the 5.0.4 release.
 [2005-01-29 05:09 UTC] danielc
Also adjusted DB's tableInfo() methods so they'll work with 5.0.3's bug.