[wp-trac] [WordPress Trac] #27982: Stop passing boolean values to mysqli_fetch_object()
WordPress Trac
noreply at wordpress.org
Sun Jul 27 10:47:52 UTC 2014
#27982: Stop passing boolean values to mysqli_fetch_object()
-----------------------------------+--------------------------
Reporter: markjaquith | Owner: markjaquith
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 3.9.2
Component: Database | Version: 3.9
Severity: normal | Resolution:
Keywords: has-patch 2nd-opinion | Focuses:
-----------------------------------+--------------------------
Comment (by michalzuber):
Couldn't find boolean result source, worth mentioning I'm not a C guru :)
Looked at:
* [https://github.com/php/php-
src/blob/2f1148ae8a09cf7644255c31162819d04285bab2/ext/mysqli/mysqli_nonapi.c#L509
ext/mysqli/mysqli_nonapi.c#L509]
* [https://github.com/php/php-
src/blob/5d6805d4982999bd302b13dbe6052e10de7f9db2/ext/mysqli/mysqli.c#L1236
ext/mysqli/mysqli.c#L1236]
* [https://github.com/php/php-
src/blob/a5f5855db9e0e413e5a2ab221e7e11cc5ee03037/ext/mysqli/php_mysqli_structs.h#L254
ext/mysqli/php_mysqli_structs.h#L254]
According to me from PHP source it shouldn't return boolean only if it's
array
{{{if (into_object && Z_TYPE_P(return_value) == IS_ARRAY)}}}
[https://github.com/php/php-
src/blob/5d6805d4982999bd302b13dbe6052e10de7f9db2/ext/mysqli/mysqli.c#L1285
ext/mysqli/mysqli.c#L1285]
Checked why might {{{mysql_fetch_object}}} be error suppressed
[https://github.com/WordPress/WordPress/blame/master/wp-includes/wp-
db.php#L1617 wp-includes/wp-db.php#L1617] and
found that the initial class author
https://github.com/WordPress/WordPress/blob/43e4a8a930be8b3d0359e517e4a6ef12f0d0ba73
/wp-includes/wp-db.php#L203 had it.
Yeah, I'm aware that the following isn't the "nicest", but better then it
is:
{{{
if ( $this->use_mysqli ) {
if ( WP_DEBUG ) {
while ( $row = mysqli_fetch_object( $this->result ) ) {
$this->last_result[$num_rows] = $row;
$num_rows++;
}
} else {
while ( $row = @mysqli_fetch_object( $this->result ) ) {
$this->last_result[$num_rows] = $row;
$num_rows++;
}
}
} else {
if ( WP_DEBUG ) {
while ( $row = mysql_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:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list