WordPress.org

Make WordPress Core

Opened 22 months ago

Last modified 20 months ago

#37508 new defect (bug)

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

Reported by: giuseppe.mazzapica Owned by:
Milestone: Future Release 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 20 months 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
22 months 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
22 months ago

  • Version changed from trunk to 3.9

Introduced in [27250].

Related: #27982

@procodewp
20 months ago

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

#3 @procodewp
20 months ago

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