Page MenuHomePhabricator

rebuildLanguage.php bug with newlines
Closed, ResolvedPublic


Update to rebuildLanguage system

I experienced this bug a few times today, when I edited a MessagesXX.php file in Windows environment, then used rebuildLanguage.php and after that, the final messages file contained both Linux (\n) and Windows (\r\n) line endings in it. Because of this, svn could not create a patch file.

I figured that I can create a very tiny PHP file for myself, that would replace all \r\n combinations with \n (that is to convert all line endings to Linux type). This way, the above problem was sovled.

I believed there would be no harm in updating rebuildLangauges system in a way that it would perform that operation prior to writing the messages to the file, so I created a patch for that.

Version: unspecified
Severity: enhancement

attachment a.diff ignored as obsolete



Related Objects


Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:51 PM
bzimport set Reference to bz10266.
bzimport added a subscriber: Unknown Object (MLST).

Created attachment 3772
Update to rebuildLanguage system

fixed a typo

attachment a.diff ignored as obsolete

Created attachment 3774
Fixed the issues in previous patch

Fixed the issues in previous patch. It still needs being reviewed.


The sensible thing is probably to:
a) Normalize \r\n to \n on input
b) Normalize \n to the local newline sequence on output

You could use the PHP_EOL constant (available since PHP 5.0.2), or try detecting it from the source file for consistency.

Well I didn't understand what you are concerned about in the (b) section. Could you please give an example?


I'm not sure if r24423 is what I actually meant here. I think what Brion said is a better idea: To change all \r\n to \n. Then to change them back to the local newline sequence (this second part is not necessary). The benefit is, if the file contains a mixture of \n newlines and \r\n newlines, they will be all made similar.

Hmmm maybe...

In the past I got SVN commit errors after running rebuildLanguage.php due to a mixture of newlines. With r24423 SVN doesn't whine anymore :)

Ok, let's check again :)

Good idea. I may test it later on as well, when I manage to translate some of the new messages for MessagesFa.