Skip to content

Avoid wp-config.php conflicts with pre-defined DB_NAME constant #2530

@brandonpayton

Description

@brandonpayton

Today, Playground unconditionally defines a DB_NAME constant in wp-config.php if it examines the config and finds DB_NAME to be missing. This causes a config conflicts with platforms like WP Cloud that define DB_NAME and other constants as part of PHP's auto_prepend_file setting.

To fix this, let's make the define in wp-config.php conditional like:

/*
 * BEGIN: Added by WordPress Playground.
 *
 * Here we can even explain and document
 * what this is and what is it used for,
 * if it's safe to touch it, etc.
 */
if ( ! defined( 'DB_NAME' ) ) {
    define( 'DB_NAME', 'some-default' );
}
/* END: Added by WordPress Playground. */

require_once ABSPATH . 'wp-settings.php';

In addition, let's consider whether changing a user's pre-existing wp-config.php file should require user opt-in.

cc @wojtekn who reported this issue and @JanJakes and @zaerl who helped determine a path forward.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions