Make WordPress Core

Opened 10 months ago

Last modified 10 months ago

#64130 new defect (bug)

Type error in /wp-includes/class-wpdb.php

Reported by: joehorntw Owned by:
Priority: normal Milestone: Awaiting Review
Component: Database Version: 6.8.3
Severity: normal Keywords:
Cc: Focuses:

Description

Hello,

I find an error message in my wordpress site.

TypeError:mysqli_num_fields(): Argument #1 ($result) must be of type mysqli_result, false given

#0 /wp-includes/class-wpdb.php(3863): mysqli_num_fields
#1 /wp-includes/class-wpdb.php(3863): wpdb::load_col_info
#2 /wp-includes/class-wpdb.php(786): wpdb::__get
...

I think there should be a type check before callint mysqli_num_fields(),
such as:

<?php
        protected function load_col_info() {
                if ( $this->col_info || !is_object( $this->result ) ) {
                        return;
                }

                $num_fields = mysqli_num_fields( $this->result );

                for ( $i = 0; $i < $num_fields; $i++ ) {
                        $this->col_info[ $i ] = mysqli_fetch_field( $this->result );
                }
        }

Change History (1)

This ticket was mentioned in Slack in #core by amykamala. View the logs.


10 months ago

Note: See TracTickets for help on using tickets.