From bf3879b1c72fa77abefd9e0707a0b5c414b0271c Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 28 Mar 2016 10:20:43 -0700 Subject: [PATCH] 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 --- src/infrastructure/markup/PhabricatorMarkupEngine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/infrastructure/markup/PhabricatorMarkupEngine.php b/src/infrastructure/markup/PhabricatorMarkupEngine.php index f32971646a..38eb0c500e 100644 --- a/src/infrastructure/markup/PhabricatorMarkupEngine.php +++ b/src/infrastructure/markup/PhabricatorMarkupEngine.php @@ -517,7 +517,7 @@ final class PhabricatorMarkupEngine extends Phobject { $rules[] = new PhutilRemarkupHighlightRule(); foreach (self::loadCustomInlineRules() as $rule) { - $rules[] = $rule; + $rules[] = clone $rule; } $blocks = array();