[wp-trac] [WordPress Trac] #30555: wp-db.php warns of mysql_fetch_object() on a boolean or or on a non-object
WordPress Trac
noreply at wordpress.org
Sun Nov 30 18:48:39 UTC 2014
#30555: wp-db.php warns of mysql_fetch_object() on a boolean or or on a non-object
--------------------------+-----------------------------
Reporter: petermantos | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Database | Version: trunk
Severity: normal | Keywords:
Focuses: multisite |
--------------------------+-----------------------------
wp-db.php has a bug around line 1616 (most recent version as of
11/30/2014)
They error reported is:
Debug Warning: ...\wp-includes\wp-db.php line 1622
mysql_fetch_object(): supplied argument is not a valid MySQL result
resource
A similar comes up under different circumstances that basically states
that the result is a boolean, not an object.
The solution is to make a test as to whether or not the result is an
object using is_object as follows:
$num_rows = 0;
if ( is_object($this->result ) ) {
if ( $this->use_mysqli ) {
while ( $row = @mysqli_fetch_object(
$this->result ) ) {
$this->last_result[$num_rows] =
$row;
$num_rows++;
}
} else {
while ( $row = @mysql_fetch_object(
$this->result ) ) {
$this->last_result[$num_rows] =
$row;
$num_rows++;
}
}
}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30555>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list