Make WordPress Core

Opened 8 years ago

Last modified 5 years ago

#37508 new defect (bug)

wpdb->result instance should be checked `mysqli_num_fields` in `load_col_info()`

Reported by: giuseppemazzapica's profile giuseppe.mazzapica Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9
Component: Database Keywords: needs-unit-tests has-patch
Focuses: Cc:

Description

In wpdb::load_col_info() the function mysqli_num_fields() is called passing $this->result without any check on this property value.

The problem is that function has a type hint to mysqli_result (see http://php.net/manual/en/mysqli-result.field-count.php), but $this->result may be false.

Just like in other places in the same class, the function should check that $this->result instanceof mysqli_result before calling mysqli_num_fields().

Attachments (1)

37508.patch (749 bytes) - added by procodewp 7 years ago.
Checks that this->result is valid before calling mysqli_num_fields() and mysql_num_fields()

Download all attachments as: .zip

Change History (4)

#1 @pento
8 years ago

  • Keywords needs-patch needs-unit-tests added
  • Milestone changed from Awaiting Review to Future Release

Thanks for the bug report, @giuseppe.mazzapica!

#2 @ocean90
8 years ago

  • Version changed from trunk to 3.9

Introduced in [27250].

Related: #27982

@procodewp
7 years ago

Checks that this->result is valid before calling mysqli_num_fields() and mysql_num_fields()

#3 @procodewp
7 years ago

  • Keywords has-patch added; needs-patch removed
Note: See TracTickets for help on using tickets.