Fix #19368 - Improve line ending handling in grid editor#20076
Fix #19368 - Improve line ending handling in grid editor#20076og-khushalpatel wants to merge 28 commits intophpmyadmin:QA_5_2from
Conversation
|
It fixes the issue, except it introduces an old bug #17398. It also happens on empty values, without 05.02.2026_16.30.32_REC.mp4Also, I think it should be |
|
Hi @liviuconcioiu , Just to clarify one point: the change in this PR does not introduce the old bug #17398 which has been demonstrated in the attached video. That said, I agree with your observation that it also occurs on empty values without NULL. I’ve addressed that case now in the latest update. I’ve also updated the label to Line ending: (singular) and moved the help icon after the colon, as suggested. Please let me know if you’d like me to adjust anything further. Thanks again for the helpful feedback! |
|
06.02.2026_16.50.48_REC.mp4 |
|
@liviuconcioiu I’ve gone through the scenario again on my end and also shared the recording as proof, but I’m still unable to reproduce the issue you’re observing. To make sure I’m not missing something, could you please share the exact table structure/schema (including column types and any relevant constraints) that you’re using when encountering this problem? |
|
I use CREATE TABLE `test` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`colA` varchar(255) DEFAULT NULL,
`colB` varchar(255) NOT NULL,
`colC` int(10) unsigned DEFAULT NULL,
`colD` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`colD`)),
`colE` uuid DEFAULT NULL,
`colF` timestamp(6) NOT NULL DEFAULT current_timestamp(6),
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
INSERT INTO `test` (`id`, `colA`, `colB`, `colC`, `colD`, `colE`, `colF`) VALUES
(1, 'Lynne', 'Combs', 1, '{\"test\":100}', '7b42b69b-f744-11f0-9d12-806d971fcc98', '2026-01-22 03:43:14.629614'),
(2, 'Carlos', 'Lara', NULL, NULL, NULL, '2026-01-22 03:43:46.727948'),
(3, NULL, 'Lang', 200, '{\"x\":\"y\"}', NULL, '2026-01-22 03:44:20.661601'),
(4, NULL, '', NULL, NULL, 'c0b2cf7a-f744-11f0-9d12-806d971fcc98', '2026-01-22 03:45:11.126818'); |
|
Hi @liviuconcioiu, thanks for sharing the exact table structure/schema. |
|
Found another problem. If I change the line ending to a cell from LF to CRLF, the cell below will have the same line ending as the first, instead of keeping it. CREATE TABLE `test` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`value` text DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
INSERT INTO `test` (`id`, `value`) VALUES
(1, 'test\ntest'),
(2, 'test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test <td class=\"text-right\">\n test test test test test test test test test test test test test test test test test test test test</td>');08.02.2026_10.56.03_REC.mp4 |
Hi @liviuconcioiu, just a quick update! The issue you mentioned is now fixed. It was due to stale event handlers in the grid editor. Would appreciate a quick review when you’re free. |
|
Everything is okay now! |
|
There are some tests that don't pass: CSS needs a little improvement: And if you can update the baselines: |
5e6d48f to
e2caafa
Compare
|
Due to how big the diff is, I think only 6.0 versions should be fixed. Maybe rebase onto the master branch. |
|
Hi @williamdes @MauricioFauth @liviuconcioiu , I’m following up on this PR in case it got buried. Please let me know if any changes are needed from my side. Thank you! |
|
@og-khushalpatel Please look into the failing test cases. |
@MoonE I believe I have already fixed the tests that were previously failing due to the changes in this PR. |
There was a problem hiding this comment.
Haven't looked what causes the other failure.
But I don't see it failing in the master branch, so it has to be related to these changes.
Also the amount of added lines in phpstan-baseline.neon suggests you are running a different configuration than on the server, shouldn't be this many changes.
Signed-off-by: Khushal Patel <khushal.b.patel01@gmail.com>
Signed-off-by: Khushal Patel <khushal.b.patel01@gmail.com>
Signed-off-by: Khushal Patel <khushal.b.patel01@gmail.com>
Signed-off-by: Khushal Patel <khushal.b.patel01@gmail.com>
MoonE
left a comment
There was a problem hiding this comment.
I added some comments on how to resolve the linter problems.
Signed-off-by: Khushal Patel <khushal.b.patel01@gmail.com>
f4b53bc to
41f80d2
Compare
3e5924c to
faaeb5f
Compare
Signed-off-by: Khushal Patel <khushal.b.patel01@gmail.com>
faaeb5f to
9f3b983
Compare
|
@MoonE I believe that finally all pipeline failures have been fixed except for one which is not manifesting because of this PR-related changes. I am really grateful for you helped me understand pipeline failure debugging which was a bit scary for a beginner like me. Let me know if I should notify the maintainers for review. |
MoonE
left a comment
There was a problem hiding this comment.
If a user edits a text value that at the begin has no line breaks, it's not possible to select the line breaks, even after closing and re-opening the edit box. It only shows up after a refresh of the whole browse result.
Would be great if it becomes visible after a new line is entered.
Signed-off-by: Khushal Patel <khushal.b.patel01@gmail.com>
Signed-off-by: Khushal Patel <khushal.b.patel01@gmail.com>
Implemented the code to make the line ending selector visible after a newline is entered. Just check it out: Screencast.from.2026-03-10.19-00-45.webm |
|
Hi, I looked into the CI failure and I believe it's unrelated to my changes. The error occurs in the stop-local-server cleanup script:
My changes only move i18n strings from |
Signed-off-by: Khushal Patel <khushal.b.patel01@gmail.com>
Signed-off-by: Khushal Patel <khushal.b.patel01@gmail.com>
|
Is there a reason why the line ending detection is done server-side and why an additional original value has to be included in the html? There is existing logic loading the full text when it is displayed truncated, so it would make sense to get the data only when it is needed. Otherwise this can inflate the html size by a lot, which can be a problem when you have columns containing very long strings. Maybe check here if the cell contains a Lines 1081 to 1108 in 44da39f This way there is no data added during normal browsing operation. |
| string $data, | ||
| string $displayedData, |
There was a problem hiding this comment.
I don't think this should be part of the bug fix
There was a problem hiding this comment.
Normalizing line-breaks to \n in $data requires performing string operations when initializing $canonicalValue. For that reason, I wanted to ensure $data is always treated as a string.
Initially, I handled this with an is_string() check because $data wasn't type-hinted. However, since $data is already documented as @param string $data, the linter flagged the conditional as unnecessary.
To resolve that while still ensuring type safety, I type-hinted $data as string instead. That's why I included it as part of the bug fix.
Great Question! Yes, this is intentional. According to the HTML spec,
We need the server-provided original value as a source of truth to prevent
That's a great point! To address this concern, the HTML size won't actually inflate, since for full-text database columns, I'm storing the truncated value in the |
Description
This pull request adds explicit line ending (CRLF / LF) handling to inline grid editing for text-like fields.
Browsers normalize textarea input to LF, which previously made it impossible for users to reliably view, preserve, or intentionally change the original line-ending format stored in the database. This PR addresses that gap by:
The implementation follows existing phpMyAdmin patterns and avoids altering behavior for non-textual field types.
Fixes #19368 - \r\n is replaced with \n when clicking on a value
Before submitting pull request, please review the following checklist:
Signed-off-byline as described in our DCO. This ensures that the work you're submitting is your own creation.