[wp-trac] [WordPress Trac] #27982: Stop passing boolean values to mysqli_fetch_object()

WordPress Trac noreply at wordpress.org
Sun Nov 30 19:03:20 UTC 2014


#27982: Stop passing boolean values to mysqli_fetch_object()
-----------------------------------+-----------------------------
 Reporter:  markjaquith            |       Owner:  markjaquith
     Type:  defect (bug)           |      Status:  assigned
 Priority:  normal                 |   Milestone:  Future Release
Component:  Database               |     Version:  3.9
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:
-----------------------------------+-----------------------------

Comment (by petermantos):

 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/27982#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list