@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix PhabricatorBot macro cacheing

Summary:
Previously, if there were no macros, we would ping conduit for a list of macros until we got something. Now we cache false when there are no results.
T3045

Test Plan: Ensure the init doesn't call the ##macro.query## conduit method more than once during the PhabricatorBot's lifetime.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

Maniphest Tasks: T3045

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

authored by

Korvin Szanto and committed by
epriestley
61f0671e 40cf765c

+8 -5
+8 -5
src/infrastructure/daemon/bot/handler/PhabricatorBotMacroHandler.php
··· 8 8 private $macros; 9 9 private $regexp; 10 10 11 - private $next = 0; 11 + private $next = 0; 12 12 13 13 private function init() { 14 14 if ($this->macros === false) { ··· 22 22 $macros = $this->getConduit()->callMethodSynchronous( 23 23 'macro.query', 24 24 array()); 25 - // bail if we have no macros 26 - if (empty($macros)) { 25 + 26 + // If we have no macros, cache `false` (meaning "no macros") and return 27 + // immediately. 28 + if (!$macros) { 29 + $this->macros = false; 27 30 return false; 28 31 } 29 - $this->macros = $macros; 30 32 31 33 $regexp = array(); 32 - foreach ($this->macros as $macro_name => $macro) { 34 + foreach ($macros as $macro_name => $macro) { 33 35 $regexp[] = preg_quote($macro_name, '/'); 34 36 } 35 37 $regexp = '/('.implode('|', $regexp).')/'; 36 38 39 + $this->macros = $macros; 37 40 $this->regexp = $regexp; 38 41 39 42 return true;