Last modified: 2010-05-15 15:28:21 UTC
If the MediaWiki distribution is unpacked with WinZip with the option "TAR file smart CR/LF conversion" turned on (under Options|Configuration|Miscellaneous), config/index.php is created with CR/LF EOLs. Once configured, the created LocalSettings.php has CR/CR/LF EOLs, which get further corrupted with subsequent edits by Notepad or Wordpad. One solution is to distribute the GZ file without the intermediary TAR file. Another solution is to pre-process the LocalSettings.php text before writing it to disk.
(In reply to comment #0) > One solution is to distribute the GZ file without the intermediary TAR file. A gzip (.gz) file is a compressed copy of exactly one file; there's no way of gzipping multiple files to one target without first combining them into an archive format, such as tar.
Thanks Rowan. So how about compressing the distribution with something that supports multiple files, & in config/index.php add $local = strtr($local, "\r\n", "\n") or similar before writing LocalSettings.php ?
Created attachment 632 [details] HEAD patch for config/index.php
Created attachment 633 [details] REL1_4 patch for config/index.php
What exactly is the source of this problem? Where do the extra characters come from? It presumably ought to work correctly if the files are CR/LF to begin with; where does it go wrong?
(In reply to comment #5) > What exactly is the source of this problem? Where do the extra characters come from? It presumably ought to > work correctly if the files are CR/LF to begin with; where does it go wrong? This is what I think happens: config/index.php has CR/LF EOLs (thanks to a WinZip default for example). So writeLocalSettings() returns $local with CR/LF EOLs. $localsettings then adds lines at the start and end using $endl, which is also based on the config/index.php EOLs. The output file is fopen()'ed with a "t" mode, causing EOL translation from LF to CR/LF, so CR/LF becomes CR/CR/LF. Saving the LocalSettings.php from various editors then does more horrible EOL stuff. Using a mode of "b" would prevent the EOL translation, so LocalSettings.php would get the same EOLs as config/index.php. As administrators are likely to edit LocalSettings.php, it seems like a good idea that this file has a native EOL style instead of whatever default style the unpacking software happened to use. So the attached patches force LF-style EOLs after the output of writeLocalSettings, allowing the "t" mode to do its thing.
I applied a slightly modified patch; moved the two str_replaces into a single one in writeLocalSettings itself. Applied on REL1_4 and HEAD.