I have observed that when fast editing (AJAX ?) a text result (mediumtext for example) of a select SQL request, the \r\n (CRLF) characters are replaced by simple \n (LF). It's a problem for me.
The PHP_EOL constant should be used instead of a \n
Windows Server 2012
PHP 7.1.1 x64 NTS
MySQL 5.7.17 x64
Why is this a problem for you?
Because, in some of my PHP scripts, I do treatments on carriage returns and line feed (replace, split, preg...) and it doesn't work anymore for datas which have been edited with PMA.
Since PHP 5.x, PHP offers the right way to manipulate new lines universally on all architectures (the constant PHP_EOL). It's strange that a famous application like PHPMyAdmin doesn't uses it !
PHPMyAdmin doesn't have to force the use of \n in my point of view. It should use either the server configuration (affected by PHP in the constant) or at least the client configuration (\r\n for Windows user agents, \n for Linux etc.).
Hope my request will be taken into account.
Wouldn't it be better to have your code support both EOL styles?
Using the style of the client wouldn't work, suppose you were using pMA from a Linux client.. ;)
Using the style of the server might not be appropriate either, I frequently use \n on Windows.
I use only \r\n (with the PHP_EOL constant) in all my code so no, I will not modify and complex all my code just to satisfy PMA editing compatibility. It's would not a reflexive solution.
In my case, \r\n treatments are only done on the private dashboard part and we control the clients type.
On the public part, we just do nl2br() which supports both \r\n and \n
But, on my advise, it's would be better to use the server configuration in priority.
Never used only \n on Windows. It is not the default usage. If rare users want to use \n on Windows, ok free to them, but by default, PMA shoud use the default PHP_EOL value for majority of users. It is a matter of common sense and the good practice I think.
Perhaps, you could also offer a new option variable in the PMA config file to let the user choose the new line representation.
phpMyAdmin just uses data you've sent with your browser and stores them in the database. So you can as well claim that it is bug in your browser that it silently changed the textarea content.
Anyway from phpMyAdmin point of view, I really don't see reason for rewriting the user posted content before passing it to the database.
I've looked a bit deeper and the HTML specification is a bit inconsistent in this:
As result phpMyAdmin is inconsistent whether you use inline editor or full page editor...
Always use \r\n as newline when editing fields
Convert \n to \r\n during inline editing to be consistent with form submitted
The internal browser representation has to be just \n while form submitted
value \r\n, see specification:
Signed-off-by: Michal Čihař <firstname.lastname@example.org>
I was persuaded that the "conversion" was done by phpMyAdmin, not by the browser.
Thank you for your fix and for the reactivity !!