Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/env/PhabricatorEnv.php
Show First 20 Lines • Show All 548 Lines • ▼ Show 20 Lines | public static function setReadOnly($read_only, $reason) { | ||||
self::$readOnlyReason = $reason; | self::$readOnlyReason = $reason; | ||||
} | } | ||||
public static function getReadOnlyMessage() { | public static function getReadOnlyMessage() { | ||||
$reason = self::getReadOnlyReason(); | $reason = self::getReadOnlyReason(); | ||||
switch ($reason) { | switch ($reason) { | ||||
case self::READONLY_MASTERLESS: | case self::READONLY_MASTERLESS: | ||||
return pht( | return pht( | ||||
'Phabricator is in read-only mode (no writable database '. | '%s is in read-only mode (no writable database '. | ||||
'is configured).'); | 'is configured).', | ||||
PhabricatorPlatformSite::getName()); | |||||
case self::READONLY_UNREACHABLE: | case self::READONLY_UNREACHABLE: | ||||
return pht( | return pht( | ||||
'Phabricator is in read-only mode (unreachable master).'); | '%s is in read-only mode (unreachable master).', | ||||
PhabricatorPlatformSite::getName()); | |||||
case self::READONLY_SEVERED: | case self::READONLY_SEVERED: | ||||
return pht( | return pht( | ||||
'Phabricator is in read-only mode (major interruption).'); | '%s is in read-only mode (major interruption).', | ||||
PhabricatorPlatformSite::getName()); | |||||
} | } | ||||
return pht('Phabricator is in read-only mode.'); | return pht('%s is in read-only mode.', PhabricatorPlatformSite::getName()); | ||||
} | } | ||||
public static function getReadOnlyURI() { | public static function getReadOnlyURI() { | ||||
return urisprintf( | return urisprintf( | ||||
'/readonly/%s/', | '/readonly/%s/', | ||||
self::getReadOnlyReason()); | self::getReadOnlyReason()); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 303 Lines • ▼ Show 20 Lines | public static function isClusterRemoteAddress() { | ||||
return self::isClusterAddress($address); | return self::isClusterAddress($address); | ||||
} | } | ||||
public static function isClusterAddress($address) { | public static function isClusterAddress($address) { | ||||
$cluster_addresses = self::getEnvConfig('cluster.addresses'); | $cluster_addresses = self::getEnvConfig('cluster.addresses'); | ||||
if (!$cluster_addresses) { | if (!$cluster_addresses) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Phabricator is not configured to serve cluster requests. '. | '%s is not configured to serve cluster requests. '. | ||||
'Set `cluster.addresses` in the configuration to whitelist '. | 'Set `cluster.addresses` in the configuration to whitelist '. | ||||
'cluster hosts before sending requests that use a cluster '. | 'cluster hosts before sending requests that use a cluster '. | ||||
'authentication mechanism.')); | 'authentication mechanism.', | ||||
PhabricatorPlatformSite::getName())); | |||||
} | } | ||||
return PhutilCIDRList::newList($cluster_addresses) | return PhutilCIDRList::newList($cluster_addresses) | ||||
->containsAddress($address); | ->containsAddress($address); | ||||
} | } | ||||
public static function getRemoteAddress() { | public static function getRemoteAddress() { | ||||
$address = idx($_SERVER, 'REMOTE_ADDR'); | $address = idx($_SERVER, 'REMOTE_ADDR'); | ||||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0