Page MenuHomePhabricator

Remarkup block rules rely on sort stability
Closed, ResolvedPublic

Description

RemarkupBlockRule has a getPriority() method which is used to sort block rules in PhutilRemarkupEngine near line 44:

https://secure.phabricator.com/diffusion/PHU/browse/master/src/markup/engine/PhutilRemarkupEngine.php;c0370f2f3c140d5048034ffdab617af7631d14ad$44

However, msort() is not stable, and the stability behavior changed between PHP5 and PHP7. Many block rules have the same priority. This can cause behavioral differences between the runtimes; see rPHUc0370f2f3c.

We should either use a stable sort (msortv()), require block rules to disambiguate their priorities to moot the issue, or maybe both (stabilize the sort, disambiguate first-party rules, let third-party rules go crazy?).