Closed (fixed)
Project:
Drupal core
Version:
11.4.x-dev
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
26 Sep 2023 at 05:44 UTC
Updated:
15 Sep 2026 at 21:05 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #3
mstrelan commentedComment #4
mstrelan commentedComment #5
mstrelan commentedComment #6
acbramley commentedSimple fix, correctly fixes the failed test and fixes our issues on a client project.
Comment #7
larowlanLeft a question on the MR
Comment #8
mstrelan commentedComment #9
smustgrave commentedRestoring status.
Comment #10
mondrakeThanks for working on this. It seems my initial implementation fell short on a number of things. Sorry for that.
The good thing is that we are adding test coverage for cases that were totally untested in the prior implementation - a more reliable pattern against possible future regressions.
In a couple of similar issues earlier, #3386482: DiffOpOutputBuilder does not correctly match the 10.0.x implementation and produces unexpected output and #3386707: DiffOpOutputBuilder does not correctly match the 10.0.x implementation and produces unexpected output (part 2), @alexpott also added the test case to the @legacy test for DiffEngine, so to show that the change is consistent with earlier behavior. I think it should be done here, too. NW for that.
Comment #11
mstrelan commentedAdded test coverage to DiffEngineTest
Comment #12
mondrakeOK, so now we have the regression fixed.
Since this is making a 'change' out of two exactly same lines that only differ by the EOL (being UNIX-like or WINDOWS-like), I was wondering: this is technically correct, but for a human it would make no difference. So I checked usage of
Diff, and I find one only in core, where the strings are certainly stripped of the '\n' (but I am unsure about the '\r'), BEFORE they are sent for diffing. So this one might be an edge case. I think that would deserve some comments somewhere re. how the array of strings passed to Diff should be preprocessed for EOL markings.From ConfigManager:
Also, I think additional test cases should be provided for
DiffFormatterTest, that is currently only testing array of strings free from any EOL markings.Comment #13
eason xu commentedComment #14
moshe weitzman commentedIt seems like the additional tests are not coming quickly. Would maintainers consider fixing the bug without tests? Otherwise we are forcing everyone to live with a bug because we are worried that the bug might return one day.
Comment #15
micahw156For what it's worth, we've been running the patch from #3 above in production for nine months with no ill effects.
Comment #17
atropoidesRerolled for D11.3
Comment #18
rclemings commentedThe patch from MR4877 won't apply because /core/tests/Drupal/Tests/Component/Diff/Engine/DiffEngineTest.php doesn't exist in current Drupal 11.3.12. It also looks as if the patch for /core/tests/Drupal/Tests/Component/Diff/DiffOpOutputBuilderTest.php doesn't apply, although there are no errors (i.e. the code is unchanged after the patch with DiffEngineTest.php removed is applied).
Comment #19
mstrelan commentedAgree with moshe in #14 and don't have much motivation to continue on this issue so I had claude assist to get it finished.
Rebased on main, the DiffEngineTest hunk is gone as that file was removed in #3424436: [11.x] Remove deprecated code from the Diff component. Updated the tests with more cases.
The IS is asking how this worked on 10.0 and below. The old DiffEngine had no line ending detection, mode 3 never occurred until #3337942: DiffEngine is deprecated and replaced with sebastianbergmann/diff.
Apparently ConfigManager cannot trigger this, as Yaml::encode escapes CRLF, so only direct callers can trigger it.
Comment #20
longwaveThis looks correct to me, the new tests look more than enough, thanks!
Comment #21
amateescu commentedCommitted and pushed cc28583dbe1 to main and e5dd13300b2 to 11.x and aa675a94345 to 11.4.x. Thanks!