WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 9 months ago

Last modified 8 months 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:

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)

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

Download all attachments as: .zip

Change History (12)

beadon3 years ago

edits to support proper quoting on DB and hostnames

comment:1 kawauso3 years ago

  • Keywords installation hostname quote removed

comment:2 nacin3 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 beadon3 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 nacin3 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 scribu3 years ago

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

comment:6 beadon3 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 dd323 years ago

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

comment:8 beadon3 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 3 years ago by beadon (previous) (diff)

comment:9 c3mdigital9 months 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.

Version 0, edited 9 months ago by c3mdigital (next)

comment:10 ocean908 months ago

  • Milestone Awaiting Review deleted

comment:11 SergeyBiryukov8 months ago

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

Related: [19701]

Note: See TracTickets for help on using tickets.