Make WordPress Core

Changeset 42701


Ignore:
Timestamp:
02/11/2018 06:46:48 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Database: In require_wp_db(), check if database constants are defined before using them.

Otherwise, wp-admin/setup-config.php triggers an undefined constant warning in PHP 7.2.

Props mariusvw, jryancard for initial patch.
Fixes #35560.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/load.php

    r42343 r42701  
    419419    }
    420420
    421     $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
     421    $dbuser     = defined( 'DB_USER' ) ? DB_USER : '';
     422    $dbpassword = defined( 'DB_PASSWORD' ) ? DB_PASSWORD : '';
     423    $dbname     = defined( 'DB_NAME' ) ? DB_NAME : '';
     424    $dbhost     = defined( 'DB_HOST' ) ? DB_HOST : '';
     425
     426    $wpdb = new wpdb( $dbuser, $dbpassword, $dbname, $dbhost );
    422427}
    423428
Note: See TracChangeset for help on using the changeset viewer.