Make WordPress Core

Opened 10 years ago

Closed 7 years ago

Last modified 7 years ago

#16529 closed defect (bug) (invalid)

Missing quotes in DB_NAME on installation

Reported by: beadon Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.3
Component: Upgrade/Install Keywords:
Focuses: Cc:


A fresh installation of the database creates the file "wp-config.php". This sets the MYSQL hostname. When entering the proper information from the 5-minute installation into the MYSQL hostname field, this is incorrectly saved to the "wp-config.php" file *without* quotes around the host if the hostname is something other than localhost.

This makes installation problematic for users for which MySQL is not residing on the same host as their web server. Specifically 1&1 users experience this issue. This appears in the latest SVN pull.

see line 220 - 229 on /wp-admin/setup-config.php

patch attached.

Attachments (1)

setup-config.php.patch (1010 bytes) - added by beadon 10 years ago.
edits to support proper quoting on DB and hostnames

Download all attachments as: .zip

Change History (12)

10 years ago

edits to support proper quoting on DB and hostnames

#1 @kawauso
10 years ago

  • Keywords installation hostname quote removed

#2 @nacin
10 years ago

  • Keywords close added

Note how the replacements are occurring:

$configFile[$line_num] = str_replace("database_name_here", $dbname, $line);
$configFile[$line_num] = str_replace("'username_here'", "'$uname'", $line);
$configFile[$line_num] = str_replace("'password_here'", "'$passwrd'", $line);
$configFile[$line_num] = str_replace("localhost", $dbhost, $line);

The username and password find strings include the quotes, so those are added back. This is not the case for the database and host fields. It's awkward and I'm not sure why it's like that, but there isn't a bug here that I can see.

#3 @beadon
10 years ago

The bug is that the file is then written out *without* the single quotes to the wp-config.php file. The bug is that users that connect to a non-default server with a '.' (period) in the name of the host, the wp-config.php file treats this period as a concatenation operation instead of the hostname and/or database name properly. These fields must be single quoted in the wp-config.php ultimately.

#4 @nacin
10 years ago

They are.

The line is: define('DB_NAME', 'database_name_here');

I am replacing:

with: $dbname

The single quotes are untouched.

#5 @scribu
10 years ago

  • Summary changed from Fresh installation to Missing quotes in DB_NAME on installation

#6 @beadon
10 years ago

Oh, I see now. The version I was looking at must have had wp-config.php without the single quotes around the DB name and localhost -- not sure how that happened. You are correct, this string replace should work.

For clarity should we change the search/replace to match the others ?

(you're right, not a bug)

#7 @dd32
10 years ago

beadon: Where did your wp-config come from? Are you using a internationalised version?

#8 @beadon
10 years ago

A friend required assistance setting up WP for the first time, I snagged the download ( v 3.0.4 at the time) and proceeded with the install via FTP for the initial load, then the install via web browser. This kept displaying the entered database server incorrectly -- I recognized the error as concatenation with the '.' when the server was redisplayed on the installation screen. Naturally, the installation failed until I massaged the wp-config.php manually. I came here to report the bug and fix it.

Last edited 10 years ago by beadon (previous) (diff)

#9 @c3mdigital
7 years ago

  • Keywords has-patch removed
  • Resolution set to invalid
  • Status changed from new to closed
  • Version changed from 3.0.4 to 2.3

The str_replace is no longer being used. Currently we are doing:

$config_file[ $line_num ] = "define('" . $constant . "'," . $padding . "'" . addcslashes( constant( $constant ), "\\'" ) . "');\r\n";

Which also preserves the single quotes.

Last edited 7 years ago by ocean90 (previous) (diff)

#10 @ocean90
7 years ago

  • Milestone Awaiting Review deleted

#11 @SergeyBiryukov
7 years ago

  • Component changed from General to Upgrade/Install
  • Keywords close removed

Related: [19701]

Note: See TracTickets for help on using tickets.