From 6378cb5d608589bc37490f5741eae2a847f87b0d Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 19 May 2015 20:29:30 +0000 Subject: [PATCH] In `wpdb::load_col_info()`, don't fetch the number of fields in the result row on each iteration of the `for` loop. It can be stored in a var and referenced. See #32444. git-svn-id: https://develop.svn.wordpress.org/trunk@32515 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/wp-db.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/wp-db.php b/src/wp-includes/wp-db.php index e749f517c4..23bb034578 100644 --- a/src/wp-includes/wp-db.php +++ b/src/wp-includes/wp-db.php @@ -2893,11 +2893,13 @@ class wpdb { return; if ( $this->use_mysqli ) { - for ( $i = 0; $i < @mysqli_num_fields( $this->result ); $i++ ) { + $num_fields = @mysqli_num_fields( $this->result ); + for ( $i = 0; $i < $num_fields; $i++ ) { $this->col_info[ $i ] = @mysqli_fetch_field( $this->result ); } } else { - for ( $i = 0; $i < @mysql_num_fields( $this->result ); $i++ ) { + $num_fields = @mysql_num_fields( $this->result ); + for ( $i = 0; $i < $num_fields; $i++ ) { $this->col_info[ $i ] = @mysql_fetch_field( $this->result, $i ); } }