Page MenuHomePhorge

D25990.1746657578.diff
No OneTemporary

D25990.1746657578.diff

diff --git a/src/infrastructure/env/PhabricatorEnv.php b/src/infrastructure/env/PhabricatorEnv.php
--- a/src/infrastructure/env/PhabricatorEnv.php
+++ b/src/infrastructure/env/PhabricatorEnv.php
@@ -55,6 +55,7 @@
private static $overrideSource;
private static $requestBaseURI;
private static $cache;
+ private static $cacheSelfDomains;
private static $localeCode;
private static $readOnly;
private static $readOnlyReason;
@@ -455,15 +456,26 @@
$host = phutil_utf8_strtolower($host);
- $self_map = self::getSelfURIMap();
+ $self_map = self::getSelfURIMapCached();
return isset($self_map[$host]);
}
- private static function getSelfURIMap() {
- // Note: here we always re-build some PhutilURI(s), but this is not
- // blazing fast, so, we could add a small cache for our result.
- // https://we.phorge.it/T16061
+ /**
+ * Get the self URI map, cached.
+ * @return array Map of trusted domains, in both the key and the value.
+ */
+ private static function getSelfURIMapCached() {
+ if (!self::$cacheSelfDomains) {
+ self::$cacheSelfDomains = self::getSelfURIMap();
+ }
+ return self::$cacheSelfDomains;
+ }
+ /**
+ * Get the self URI map, uncached.
+ * @return array Map of trusted domains, in both the key and the value.
+ */
+ private static function getSelfURIMap() {
$self_uris = array();
$self_uris[] = self::getProductionURI('/');
$self_uris[] = self::getURI('/');
@@ -976,6 +988,7 @@
private static function dropConfigCache() {
self::$cache = array();
+ self::$cacheSelfDomains = array();
}
private static function resetUmask() {

File Metadata

Mime Type
text/plain
Expires
Wed, May 7, 22:39 (9 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1516305
Default Alt Text
D25990.1746657578.diff (1 KB)

Event Timeline