Opened 2 years ago
Last modified 2 years ago
#16529 new defect (bug)
Missing quotes in DB_NAME on installation
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | General | Version: | 3.0.4 |
| Severity: | normal | Keywords: | has-patch close |
| Cc: |
Description
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)
Change History (9)
comment:2
nacin
— 2 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.
comment:3
beadon
— 2 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.
comment:4
nacin
— 2 years ago
They are.
The line is: define('DB_NAME', 'database_name_here');
I am replacing:
database_name_here
with: $dbname
The single quotes are untouched.
comment:5
scribu
— 2 years ago
- Summary changed from Fresh installation to Missing quotes in DB_NAME on installation
comment:6
beadon
— 2 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)
comment:7
dd32
— 2 years ago
beadon: Where did your wp-config come from? Are you using a internationalised version?
comment:8
beadon
— 2 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 hte 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.
edits to support proper quoting on DB and hostnames