Make WordPress Core

Opened 7 weeks ago

Last modified 7 weeks ago

#64130 new defect (bug)

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

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

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.


7 weeks ago

Note: See TracTickets for help on using tickets.