WordPress.org

Make WordPress Core

Opened 14 months ago

Last modified 14 months ago

#45138 new defect (bug)

mixed line endings: wp-config-sample.php uses CRLF (windows) line endings

Reported by: mattpr Owned by:
Milestone: Awaiting Review Priority: normal
Severity: trivial Version:
Component: Upgrade/Install Keywords: close
Focuses: Cc:
PR Number:

Description

Not sure if this is on purpose? Looks like it has always been that way.

# curl -s -N "https://core.trac.wordpress.org/browser/trunk/src/wp-login.php?format=txt" | head -n1 | hexdump -c
0000000   <   ?   p   h   p  \n
0000006
# curl -s -N "https://core.trac.wordpress.org/browser/trunk/wp-config-sample.php?format=txt" | head -n1 | hexdump -c
0000000   <   ?   p   h   p  \r  \n
0000007

Change History (3)

#1 @knutsp
14 months ago

  • Keywords close added
  • Version trunk deleted

Many are those who has used Windows Notepad to edit and save it as wp-config.php. LF only line endings look very bad and will confuse those more than necessary. For many of those, wp-config.php will be the only php file they ever edit.

As long as consistent within the file, and that file only, I don't think it is, or should be regarded as, a bug.

Last edited 14 months ago by knutsp (previous) (diff)

#2 @mattpr
14 months ago

Okay. I was just quite surprised to find a mix between files. Not common to see that in large projects.

It came up for me because my own deployment is scripted as well as my backup and restore.
Some of that involves scripted file editing (sed, etc)...which of course leads to a mix of line endings within the file with windows line endings.

Editors like vim (or notepad++, etc) are smart enough to detect the file line endings and be consistent with their edits...although I grant you Windows Notepad probably isn't.

Don't have an issue with windows line endings...if wordpress is setup for windows line endings, then I just factor that into my provisioning stuff. When it is a mix where some files are CRLF and some files are LF...then it is more messy because I can't set one default but need to check every file every time and potentially do a conversion.

I am sure Windows Notepad users are more helpless than I am, so if that is a big part of your user base, then I guess it makes sense to stick with a system that is more friendly to them (ie make the one file they are likely to edit appear properly in the only built-in plain text editor on their system).

I can just add line ending checks/conversions to all my provisioning code now that I know you use a mix of line endings.

#3 @SergeyBiryukov
14 months ago

  • Component changed from General to Upgrade/Install

Hi @mattpr, welcome WordPress Trac! Thanks for the report.

Not sure if this is on purpose?

It is, see #12775 (also #20890 and #28187).

That said, I think being able to edit the file in Windows Notepad is actually a disservice to most Windows users, as it inserts the UTF-8 byte order mark, causing the Headers already sent PHP warning (as seen in #27373, #27974, #28490, #32575, #33626, #36213, #37036, and some other tickets).

The issue mostly happens in non-Latin locales, where wp-config-sample.php is translated and includes non-ASCII characters. The solution is then to re-save the file in UTF-8 without BOM using Notepad++ or other editor.

Warning: Cannot modify header information - headers already sent by (output started at .../public_html/wp-config.php:1) has been the top FAQ entry on https://ru.wordpress.org/support/ for almost 10 years now. The page specifically advises against using Notepad for editing wp-config.php.

So, while the original intention was to make it easier to edit the file in Notepad, maybe we could reconsider that?

On the other hand, more and more people these days get WordPress from their hosting provider without manually editing files, so perhaps making the change now is not worth it.

Note: See TracTickets for help on using tickets.