Commit 097fd7e76c for wordpress.org
commit 097fd7e76c8b7d57d670e5cae3e764d11fe93fe4
Author: johnbillion <johnbillion@git.wordpress.org>
Date: Thu Sep 24 20:35:50 2026 +0000
Upgrade/Install: Load the existing configuration and locale before rejecting a request to `setup-config.php`.
Visiting `wp-admin/setup-config.php` on a site that already has a `wp-config.php` file will now show the error message in the site language instead of always in English.
Developed in https://github.com/WordPress/wordpress-develop/pull/13631.
Props swissspidy, abhishekfdd.
Fixes #63009.
Built from https://develop.svn.wordpress.org/trunk@63926
git-svn-id: http://core.svn.wordpress.org/trunk@63092 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-admin/setup-config.php b/wp-admin/setup-config.php
index ec4d1a8bbb..aaa91fc24b 100644
--- a/wp-admin/setup-config.php
+++ b/wp-admin/setup-config.php
@@ -14,6 +14,52 @@
*/
define( 'WP_INSTALLING', true );
+if ( ! defined( 'ABSPATH' ) ) {
+ define( 'ABSPATH', dirname( __DIR__ ) . '/' );
+}
+
+/*
+ * Check whether a wp-config.php file already exists, either in the WordPress root
+ * or one level above it (but not as part of another installation).
+ * This mirrors the lookup in wp-load.php.
+ */
+if ( file_exists( ABSPATH . 'wp-config.php' ) ) {
+ $existing_config_location = 'root';
+} elseif ( @file_exists( dirname( ABSPATH ) . '/wp-config.php' ) && ! @file_exists( dirname( ABSPATH ) . '/wp-settings.php' ) ) {
+ $existing_config_location = 'parent';
+} else {
+ $existing_config_location = '';
+}
+
+if ( $existing_config_location ) {
+ /*
+ * A configuration file already exists, so there is nothing to set up here.
+ * Load WordPress through that file, like any other request would, so that the
+ * site's locale is known and the message below can be translated.
+ */
+ require_once ABSPATH . 'wp-load.php';
+
+ nocache_headers();
+
+ if ( 'root' === $existing_config_location ) {
+ $message = sprintf(
+ /* translators: 1: wp-config.php, 2: install.php */
+ __( 'The file %1$s already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href="%2$s">installing now</a>.' ),
+ '<code>wp-config.php</code>',
+ 'install.php'
+ );
+ } else {
+ $message = sprintf(
+ /* translators: 1: wp-config.php, 2: install.php */
+ __( 'The file %1$s already exists one level above your WordPress installation. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href="%2$s">installing now</a>.' ),
+ '<code>wp-config.php</code>',
+ 'install.php'
+ );
+ }
+
+ wp_die( '<p>' . $message . '</p>', 409 );
+}
+
/**
* We are blissfully unaware of anything.
*/
@@ -26,10 +72,6 @@ define( 'WP_SETUP_CONFIG', true );
*/
error_reporting( 0 );
-if ( ! defined( 'ABSPATH' ) ) {
- define( 'ABSPATH', dirname( __DIR__ ) . '/' );
-}
-
require ABSPATH . 'wp-settings.php';
/** Load WordPress Administration Upgrade API */
@@ -55,32 +97,6 @@ if ( file_exists( ABSPATH . 'wp-config-sample.php' ) ) {
);
}
-// Check if wp-config.php has been created.
-if ( file_exists( ABSPATH . 'wp-config.php' ) ) {
- wp_die(
- '<p>' . sprintf(
- /* translators: 1: wp-config.php, 2: install.php */
- __( 'The file %1$s already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href="%2$s">installing now</a>.' ),
- '<code>wp-config.php</code>',
- 'install.php'
- ) . '</p>',
- 409
- );
-}
-
-// Check if wp-config.php exists above the root directory but is not part of another installation.
-if ( @file_exists( ABSPATH . '../wp-config.php' ) && ! @file_exists( ABSPATH . '../wp-settings.php' ) ) {
- wp_die(
- '<p>' . sprintf(
- /* translators: 1: wp-config.php, 2: install.php */
- __( 'The file %1$s already exists one level above your WordPress installation. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href="%2$s">installing now</a>.' ),
- '<code>wp-config.php</code>',
- 'install.php'
- ) . '</p>',
- 409
- );
-}
-
$step = isset( $_GET['step'] ) ? (int) $_GET['step'] : -1;
/**
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 8b2663e13d..72728a00e5 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-alpha-63925';
+$wp_version = '7.2-alpha-63926';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.