Home GnuPG

Stabilize sort order for Remarkup block rules
d78271470210Unpublished

Unpublished Commit ยท Learn More

Publishing Disabled: All publishing is disabled for this repository.

Description

Stabilize sort order for Remarkup block rules

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:

{F4920739}

This test now passes.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10929

Differential Revision: https://secure.phabricator.com/D17771

Details

Provenance
epriestley <git@epriestley.com>Authored on Apr 23 2017, 2:45 PM
marcusPushed on May 11 2017, 7:29 PM
Parents
rPHUTIL904f81a31b74: Make "fail quietly" flag in DeferredLog a little more quiet
Branches
Unknown
Tags
Unknown

Event Timeline

epriestley <git@epriestley.com> committed rPHUTILd78271470210: Stabilize sort order for Remarkup block rules (authored by epriestley <git@epriestley.com>).Apr 23 2017, 8:01 PM