WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 5 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: Priority: normal
Severity: normal Version: 3.9
Component: Database Keywords: needs-unit-tests has-patch
Focuses: Cc:
PR Number:

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 3 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
3 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
3 years ago

  • Version changed from trunk to 3.9

Introduced in [27250].

Related: #27982

@procodewp
3 years ago

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

#3 @procodewp
3 years ago

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