Page MenuHomePhabricator

Stabilize sort order for Remarkup block rules
ClosedPublic

Authored by epriestley on Apr 23 2017, 12:50 PM.
Tags
None
Referenced Files
F15530012: D17771.id42749.diff
Wed, Apr 23, 12:38 AM
F15491986: D17771.id.diff
Sat, Apr 12, 9:35 AM
F15485588: D17771.diff
Thu, Apr 10, 12:49 AM
F15436308: D17771.id.diff
Mar 25 2025, 1:21 PM
F15434782: D17771.id42749.diff
Mar 25 2025, 5:22 AM
F15431650: D17771.id.diff
Mar 24 2025, 1:43 PM
F15428242: D17771.diff
Mar 23 2025, 6:46 PM
Unknown Object (File)
Mar 1 2025, 3:13 PM
Subscribers
None

Details

Summary

Fixes T10929. Currently, the ordering of Remarkup block rules is ambiguous (multiple rules may have the same priority number) and depends on sort stability (if elements with the same value have their ordered retained by the sort).

Sort stability changed between PHP5 and PHP7, so the result of functions like asort() changed too if some of the values are the same.

Currently, some tests fail and some edge-case beahviors differ under PHP7 because of this. Particularly, the Remarkup literal test case fails under PHP 7.1 locally, because <space><space>%%% gets interpreted as a code block instead of a literal block.

To fix this:

  • Use msortv() with PhutilSortVector, which is a stable sort.
  • Sort on <priority, ClassName>. The class name is guaranteed unique so this ordering is unambiguous.
Test Plan

Previously, a literal block test case failed on PHP7.1 locally:

Screen Shot 2017-04-23 at 4.55.29 AM.png (214×1 px, 47 KB)

This test now passes.

Diff Detail

Repository
rPHU libphutil
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Apr 23 2017, 5:39 PM
This revision was automatically updated to reflect the committed changes.