1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Fully fix a bad rule object aliasing issue custom remarkup rules

Summary:
Fixes T10234. This is a more thorough fix.

Root issue is that some time around D13589, we started hitting an object cache for `loadCustomInlineRules()`, but didn't adjust the code to account for that.

So if a page created multiple similar engines, we'd return the same `$rule` object for multiple engines, call `setEngine()` on it with different engines, and then possibly try to render using an already-expired engine the second time through.

Instead, create a separate `$rule` object for each separate `$engine`.

Test Plan:
Repro is something like this:

  - Create a custominlinerule which uses an engine.
  - Purge the remarkup cache.
  - Load a page which uses the rule in two engines (e.g., in a revision description, and also in an inline comment).
  - Before change: second one could fatal. After change: clean load.

Reviewers: thoughtpolice, chad

Reviewed By: thoughtpolice, chad

Subscribers: thoughtpolice, eadler

Maniphest Tasks: T10234

Differential Revision: https://secure.phabricator.com/D15535
This commit is contained in:
epriestley 2016-03-28 10:20:43 -07:00
parent da1ebac8d8
commit bf3879b1c7

View file

@ -517,7 +517,7 @@ final class PhabricatorMarkupEngine extends Phobject {
$rules[] = new PhutilRemarkupHighlightRule(); $rules[] = new PhutilRemarkupHighlightRule();
foreach (self::loadCustomInlineRules() as $rule) { foreach (self::loadCustomInlineRules() as $rule) {
$rules[] = $rule; $rules[] = clone $rule;
} }
$blocks = array(); $blocks = array();