Make WordPress Core

Ticket #41956: 41956.2.diff

File 41956.2.diff, 1.4 KB (added by munyagu, 7 years ago)
  • src/wp-includes/wp-db.php

     
    17981798                                $this->insert_id = 0;
    17991799                                return false;
    18001800                        }
    1801                 }
    1802 
    1803                 // If there is an error then take note of it.
    1804                 if ( $this->use_mysqli ) {
    1805                         if ( $this->dbh instanceof mysqli ) {
    1806                                 $this->last_error = mysqli_error( $this->dbh );
     1801                } elseif ( 0 !== $mysql_errno ) {
     1802                        // If there is an error then take note of it.
     1803                        if ( $this->use_mysqli ) {
     1804                                if ( $this->dbh instanceof mysqli ) {
     1805                                        $this->last_error = sprintf('[code:"%d", message:"%s"]' ,$mysql_errno, mysqli_error( $this->dbh ) );
     1806                                } else {
     1807                                        $this->last_error = __( 'Unable to retrieve the error message from MySQL' );
     1808                                }
    18071809                        } else {
    1808                                 $this->last_error = __( 'Unable to retrieve the error message from MySQL' );
     1810                                if ( is_resource( $this->dbh ) ) {
     1811                                        $this->last_error = sprintf('[code:"%d", message:"%s"]' ,$mysql_errno, mysql_error( $this->dbh ) );
     1812                                } else {
     1813                                        $this->last_error = __( 'Unable to retrieve the error message from MySQL' );
     1814                                }
    18091815                        }
    1810                 } else {
    1811                         if ( is_resource( $this->dbh ) ) {
    1812                                 $this->last_error = mysql_error( $this->dbh );
    1813                         } else {
    1814                                 $this->last_error = __( 'Unable to retrieve the error message from MySQL' );
    1815                         }
    18161816                }
    18171817
    18181818                if ( $this->last_error ) {