code
stringlengths
17
247k
docstring
stringlengths
30
30.3k
func_name
stringlengths
1
89
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
153
url
stringlengths
51
209
license
stringclasses
4 values
public function getCommandDescription() { return null; }
Return a longer human-readable description of the command effect. This can be as long as necessary to explain the command. @return string Human-readable remarkup of whatever length is desired. @task docs
getCommandDescription
php
phacility/phabricator
src/applications/metamta/command/MetaMTAEmailTransactionCommand.php
https://github.com/phacility/phabricator/blob/master/src/applications/metamta/command/MetaMTAEmailTransactionCommand.php
Apache-2.0
public static function getSessionKindFromToken($session_token) { if (strpos($session_token, '/') === false) { // Old-style session, these are all user sessions. return self::KIND_USER; } list($kind, $key) = explode('/', $session_token, 2); switch ($kind) { case self::KIND_ANONYMOUS: case self::KIND_USER: case self::KIND_EXTERNAL: return $kind; default: return self::KIND_UNKNOWN; } }
Get the session kind (e.g., anonymous, user, external account) from a session token. Returns a `KIND_` constant. @param string Session token. @return const Session kind constant.
getSessionKindFromToken
php
phacility/phabricator
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phacility/phabricator/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
public function loadUserForSession($session_type, $session_token) { $session_kind = self::getSessionKindFromToken($session_token); switch ($session_kind) { case self::KIND_ANONYMOUS: // Don't bother trying to load a user for an anonymous session, since // neither the session nor the user exist. return null; case self::KIND_UNKNOWN: // If we don't know what kind of session this is, don't go looking for // it. return null; case self::KIND_USER: break; case self::KIND_EXTERNAL: // TODO: Implement these (T4310). return null; } $session_table = new PhabricatorAuthSession(); $user_table = new PhabricatorUser(); $conn = $session_table->establishConnection('r'); // TODO: See T13225. We're moving sessions to a more modern digest // algorithm, but still accept older cookies for compatibility. $session_key = PhabricatorAuthSession::newSessionDigest( new PhutilOpaqueEnvelope($session_token)); $weak_key = PhabricatorHash::weakDigest($session_token); $cache_parts = $this->getUserCacheQueryParts($conn); list($cache_selects, $cache_joins, $cache_map, $types_map) = $cache_parts; $info = queryfx_one( $conn, 'SELECT s.id AS s_id, s.phid AS s_phid, s.sessionExpires AS s_sessionExpires, s.sessionStart AS s_sessionStart, s.highSecurityUntil AS s_highSecurityUntil, s.isPartial AS s_isPartial, s.signedLegalpadDocuments as s_signedLegalpadDocuments, IF(s.sessionKey = %P, 1, 0) as s_weak, u.* %Q FROM %R u JOIN %R s ON u.phid = s.userPHID AND s.type = %s AND s.sessionKey IN (%P, %P) %Q', new PhutilOpaqueEnvelope($weak_key), $cache_selects, $user_table, $session_table, $session_type, new PhutilOpaqueEnvelope($session_key), new PhutilOpaqueEnvelope($weak_key), $cache_joins); if (!$info) { return null; } // TODO: Remove this, see T13225. $is_weak = (bool)$info['s_weak']; unset($info['s_weak']); $session_dict = array( 'userPHID' => $info['phid'], 'sessionKey' => $session_key, 'type' => $session_type, ); $cache_raw = array_fill_keys($cache_map, null); foreach ($info as $key => $value) { if (strncmp($key, 's_', 2) === 0) { unset($info[$key]); $session_dict[substr($key, 2)] = $value; continue; } if (isset($cache_map[$key])) { unset($info[$key]); $cache_raw[$cache_map[$key]] = $value; continue; } } $user = $user_table->loadFromArray($info); $cache_raw = $this->filterRawCacheData($user, $types_map, $cache_raw); $user->attachRawCacheData($cache_raw); switch ($session_type) { case PhabricatorAuthSession::TYPE_WEB: // Explicitly prevent bots and mailing lists from establishing web // sessions. It's normally impossible to attach authentication to these // accounts, and likewise impossible to generate sessions, but it's // technically possible that a session could exist in the database. If // one does somehow, refuse to load it. if (!$user->canEstablishWebSessions()) { return null; } break; } $session = id(new PhabricatorAuthSession())->loadFromArray($session_dict); $this->extendSession($session); // TODO: Remove this, see T13225. if ($is_weak) { $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $conn_w = $session_table->establishConnection('w'); queryfx( $conn_w, 'UPDATE %T SET sessionKey = %P WHERE id = %d', $session->getTableName(), new PhutilOpaqueEnvelope($session_key), $session->getID()); unset($unguarded); } $user->attachSession($session); return $user; }
Load the user identity associated with a session of a given type, identified by token. When the user presents a session token to an API, this method verifies it is of the correct type and loads the corresponding identity if the session exists and is valid. NOTE: `$session_type` is the type of session that is required by the loading context. This prevents use of a Conduit sesssion as a Web session, for example. @param const The type of session to load. @param string The session token. @return PhabricatorUser|null @task use
loadUserForSession
php
phacility/phabricator
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phacility/phabricator/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
public function requireHighSecurityToken( PhabricatorUser $viewer, AphrontRequest $request, $cancel_uri) { return $this->newHighSecurityToken( $viewer, $request, $cancel_uri, false, false); }
Require the user respond to a high security (MFA) check. This method differs from @{method:requireHighSecuritySession} in that it does not upgrade the user's session as a side effect. This method is appropriate for one-time checks. @param PhabricatorUser User whose session needs to be in high security. @param AphrontRequest Current request. @param string URI to return the user to if they cancel. @return PhabricatorAuthHighSecurityToken Security token. @task hisec
requireHighSecurityToken
php
phacility/phabricator
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phacility/phabricator/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
public function requireHighSecuritySession( PhabricatorUser $viewer, AphrontRequest $request, $cancel_uri, $jump_into_hisec = false) { return $this->newHighSecurityToken( $viewer, $request, $cancel_uri, $jump_into_hisec, true); }
Require high security, or prompt the user to enter high security. If the user's session is in high security, this method will return a token. Otherwise, it will throw an exception which will eventually be converted into a multi-factor authentication workflow. This method upgrades the user's session to high security for a short period of time, and is appropriate if you anticipate they may need to take multiple high security actions. To perform a one-time check instead, use @{method:requireHighSecurityToken}. @param PhabricatorUser User whose session needs to be in high security. @param AphrontRequest Current request. @param string URI to return the user to if they cancel. @param bool True to jump partial sessions directly into high security instead of just upgrading them to full sessions. @return PhabricatorAuthHighSecurityToken Security token. @task hisec
requireHighSecuritySession
php
phacility/phabricator
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phacility/phabricator/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
private function issueHighSecurityToken( PhabricatorAuthSession $session, $force = false) { if ($session->isHighSecuritySession() || $force) { return new PhabricatorAuthHighSecurityToken(); } return null; }
Issue a high security token for a session, if authorized. @param PhabricatorAuthSession Session to issue a token for. @param bool Force token issue. @return PhabricatorAuthHighSecurityToken|null Token, if authorized. @task hisec
issueHighSecurityToken
php
phacility/phabricator
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phacility/phabricator/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
public function exitHighSecurity( PhabricatorUser $viewer, PhabricatorAuthSession $session) { if (!$session->getHighSecurityUntil()) { return; } queryfx( $session->establishConnection('w'), 'UPDATE %T SET highSecurityUntil = NULL WHERE id = %d', $session->getTableName(), $session->getID()); $log = PhabricatorUserLog::initializeNewLog( $viewer, $viewer->getPHID(), PhabricatorExitHisecUserLogType::LOGTYPE); $log->save(); }
Strip the high security flag from a session. Kicks a session out of high security and logs the exit. @param PhabricatorUser Acting user. @param PhabricatorAuthSession Session to return to normal security. @return void @task hisec
exitHighSecurity
php
phacility/phabricator
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phacility/phabricator/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
public function upgradePartialSession(PhabricatorUser $viewer) { if (!$viewer->hasSession()) { throw new Exception( pht('Upgrading partial session of user with no session!')); } $session = $viewer->getSession(); if (!$session->getIsPartial()) { throw new Exception(pht('Session is not partial!')); } $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $session->setIsPartial(0); queryfx( $session->establishConnection('w'), 'UPDATE %T SET isPartial = %d WHERE id = %d', $session->getTableName(), 0, $session->getID()); $log = PhabricatorUserLog::initializeNewLog( $viewer, $viewer->getPHID(), PhabricatorFullLoginUserLogType::LOGTYPE); $log->save(); unset($unguarded); }
Upgrade a partial session to a full session. @param PhabricatorAuthSession Session to upgrade. @return void @task partial
upgradePartialSession
php
phacility/phabricator
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phacility/phabricator/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
public function signLegalpadDocuments(PhabricatorUser $viewer, array $docs) { if (!$viewer->hasSession()) { throw new Exception( pht('Signing session legalpad documents of user with no session!')); } $session = $viewer->getSession(); if ($session->getSignedLegalpadDocuments()) { throw new Exception(pht( 'Session has already signed required legalpad documents!')); } $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $session->setSignedLegalpadDocuments(1); queryfx( $session->establishConnection('w'), 'UPDATE %T SET signedLegalpadDocuments = %d WHERE id = %d', $session->getTableName(), 1, $session->getID()); if (!empty($docs)) { $log = PhabricatorUserLog::initializeNewLog( $viewer, $viewer->getPHID(), PhabricatorSignDocumentsUserLogType::LOGTYPE); $log->save(); } unset($unguarded); }
Upgrade a session to have all legalpad documents signed. @param PhabricatorUser User whose session should upgrade. @param array LegalpadDocument objects @return void @task partial
signLegalpadDocuments
php
phacility/phabricator
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phacility/phabricator/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
public function getOneTimeLoginURI( PhabricatorUser $user, PhabricatorUserEmail $email = null, $type = self::ONETIME_RESET, $force_full_session = false) { $key = Filesystem::readRandomCharacters(32); $key_hash = $this->getOneTimeLoginKeyHash($user, $email, $key); $onetime_type = PhabricatorAuthOneTimeLoginTemporaryTokenType::TOKENTYPE; $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $token = id(new PhabricatorAuthTemporaryToken()) ->setTokenResource($user->getPHID()) ->setTokenType($onetime_type) ->setTokenExpires(time() + phutil_units('1 day in seconds')) ->setTokenCode($key_hash) ->setShouldForceFullSession($force_full_session) ->save(); unset($unguarded); $uri = '/login/once/'.$type.'/'.$user->getID().'/'.$key.'/'; if ($email) { $uri = $uri.$email->getID().'/'; } try { $uri = PhabricatorEnv::getProductionURI($uri); } catch (Exception $ex) { // If a user runs `bin/auth recover` before configuring the base URI, // just show the path. We don't have any way to figure out the domain. // See T4132. } return $uri; }
Retrieve a temporary, one-time URI which can log in to an account. These URIs are used for password recovery and to regain access to accounts which users have been locked out of. @param PhabricatorUser User to generate a URI for. @param PhabricatorUserEmail Optionally, email to verify when link is used. @param string Optional context string for the URI. This is purely cosmetic and used only to customize workflow and error messages. @param bool True to generate a URI which forces an immediate upgrade to a full session, bypassing MFA and other login checks. @return string Login URI. @task onetime
getOneTimeLoginURI
php
phacility/phabricator
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phacility/phabricator/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
public function loadOneTimeLoginKey( PhabricatorUser $user, PhabricatorUserEmail $email = null, $key = null) { $key_hash = $this->getOneTimeLoginKeyHash($user, $email, $key); $onetime_type = PhabricatorAuthOneTimeLoginTemporaryTokenType::TOKENTYPE; return id(new PhabricatorAuthTemporaryTokenQuery()) ->setViewer($user) ->withTokenResources(array($user->getPHID())) ->withTokenTypes(array($onetime_type)) ->withTokenCodes(array($key_hash)) ->withExpired(false) ->executeOne(); }
Load the temporary token associated with a given one-time login key. @param PhabricatorUser User to load the token for. @param PhabricatorUserEmail Optionally, email to verify when link is used. @param string Key user is presenting as a valid one-time login key. @return PhabricatorAuthTemporaryToken|null Token, if one exists. @task onetime
loadOneTimeLoginKey
php
phacility/phabricator
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phacility/phabricator/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
private function getOneTimeLoginKeyHash( PhabricatorUser $user, PhabricatorUserEmail $email = null, $key = null) { $parts = array( $key, $user->getAccountSecret(), ); if ($email) { $parts[] = $email->getVerificationCode(); } return PhabricatorHash::weakDigest(implode(':', $parts)); }
Hash a one-time login key for storage as a temporary token. @param PhabricatorUser User this key is for. @param PhabricatorUserEmail Optionally, email to verify when link is used. @param string The one time login key. @return string Hash of the key. task onetime
getOneTimeLoginKeyHash
php
phacility/phabricator
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phacility/phabricator/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
public function withInvoices($invoices) { $this->invoices = $invoices; return $this; }
Include or exclude carts which represent invoices with payments due. @param bool `true` to select invoices; `false` to exclude invoices. @return this
withInvoices
php
phacility/phabricator
src/applications/phortune/query/PhortuneCartQuery.php
https://github.com/phacility/phabricator/blob/master/src/applications/phortune/query/PhortuneCartQuery.php
Apache-2.0
public function getURILineRange($key, $limit) { $range = $this->getURIData($key); return self::parseURILineRange($range, $limit); }
Read line range parameter data from the request. Applications like Paste, Diffusion, and Harbormaster use "$12-14" in the URI to allow users to link to particular lines. @param string URI data key to pull line range information from. @param int|null Maximum length of the range. @return null|pair<int, int> Null, or beginning and end of the range.
getURILineRange
php
phacility/phabricator
src/aphront/AphrontRequest.php
https://github.com/phacility/phabricator/blob/master/src/aphront/AphrontRequest.php
Apache-2.0
public function canSetCookies() { return (bool)$this->getCookieDomainURI(); }
Determine if security policy rules will allow cookies to be set when responding to the request. @return bool True if setCookie() will succeed. If this method returns false, setCookie() will throw. @task cookie
canSetCookies
php
phacility/phabricator
src/aphront/AphrontRequest.php
https://github.com/phacility/phabricator/blob/master/src/aphront/AphrontRequest.php
Apache-2.0
public function setCookie($name, $value) { $far_future = time() + (60 * 60 * 24 * 365 * 5); return $this->setCookieWithExpiration($name, $value, $far_future); }
Set a cookie which does not expire for a long time. To set a temporary cookie, see @{method:setTemporaryCookie}. @param string Cookie name. @param string Cookie value. @return this @task cookie
setCookie
php
phacility/phabricator
src/aphront/AphrontRequest.php
https://github.com/phacility/phabricator/blob/master/src/aphront/AphrontRequest.php
Apache-2.0
public function setTemporaryCookie($name, $value) { return $this->setCookieWithExpiration($name, $value, 0); }
Set a cookie which expires soon. To set a durable cookie, see @{method:setCookie}. @param string Cookie name. @param string Cookie value. @return this @task cookie
setTemporaryCookie
php
phacility/phabricator
src/aphront/AphrontRequest.php
https://github.com/phacility/phabricator/blob/master/src/aphront/AphrontRequest.php
Apache-2.0
private function setCookieWithExpiration( $name, $value, $expire) { $is_secure = false; $base_domain_uri = $this->getCookieDomainURI(); if (!$base_domain_uri) { $configured_as = PhabricatorEnv::getEnvConfig('phabricator.base-uri'); $accessed_as = $this->getHost(); throw new AphrontMalformedRequestException( pht('Bad Host Header'), pht( 'This server is configured as "%s", but you are using the domain '. 'name "%s" to access a page which is trying to set a cookie. '. 'Access this service on the configured primary domain or a '. 'configured alternate domain. Cookies will not be set on other '. 'domains for security reasons.', $configured_as, $accessed_as), true); } $base_domain = $base_domain_uri->getDomain(); $is_secure = ($base_domain_uri->getProtocol() == 'https'); $name = $this->getPrefixedCookieName($name); if (php_sapi_name() == 'cli') { // Do nothing, to avoid triggering "Cannot modify header information" // warnings. // TODO: This is effectively a test for whether we're running in a unit // test or not. Move this actual call to HTTPSink? } else { setcookie( $name, $value, $expire, $path = '/', $base_domain, $is_secure, $http_only = true); } $_COOKIE[$name] = $value; return $this; }
Set a cookie with a given expiration policy. @param string Cookie name. @param string Cookie value. @param int Epoch timestamp for cookie expiration. @return this @task cookie
setCookieWithExpiration
php
phacility/phabricator
src/aphront/AphrontRequest.php
https://github.com/phacility/phabricator/blob/master/src/aphront/AphrontRequest.php
Apache-2.0
public function getPassthroughRequestParameters($include_quicksand = false) { return self::flattenData( $this->getPassthroughRequestData($include_quicksand)); }
Get application request parameters in a flattened form suitable for inclusion in an HTTP request, excluding parameters with special meanings. This is primarily useful if you want to ask the user for more input and then resubmit their request. @return dict<string, string> Original request parameters.
getPassthroughRequestParameters
php
phacility/phabricator
src/aphront/AphrontRequest.php
https://github.com/phacility/phabricator/blob/master/src/aphront/AphrontRequest.php
Apache-2.0
public function getPassthroughRequestData($include_quicksand = false) { $data = $this->getRequestData(); // Remove magic parameters like __dialog__ and __ajax__. foreach ($data as $key => $value) { if ($include_quicksand && $key == self::TYPE_QUICKSAND) { continue; } if (!strncmp($key, '__', 2)) { unset($data[$key]); } } return $data; }
Get request data other than "magic" parameters. @return dict<string, wild> Request data, with magic filtered out.
getPassthroughRequestData
php
phacility/phabricator
src/aphront/AphrontRequest.php
https://github.com/phacility/phabricator/blob/master/src/aphront/AphrontRequest.php
Apache-2.0
public static function getHTTPHeader($name, $default = null, $data = null) { // PHP mangles HTTP headers by uppercasing them and replacing hyphens with // underscores, then prepending 'HTTP_'. $php_index = strtoupper($name); $php_index = str_replace('-', '_', $php_index); $try_names = array(); $try_names[] = 'HTTP_'.$php_index; if ($php_index == 'CONTENT_TYPE' || $php_index == 'CONTENT_LENGTH') { // These headers may be available under alternate names. See // http://www.php.net/manual/en/reserved.variables.server.php#110763 $try_names[] = $php_index; } if ($data === null) { $data = $_SERVER; } foreach ($try_names as $try_name) { if (array_key_exists($try_name, $data)) { return $data[$try_name]; } } return $default; }
Read the value of an HTTP header from `$_SERVER`, or a similar datasource. This function accepts a canonical header name, like `"Accept-Encoding"`, and looks up the appropriate value in `$_SERVER` (in this case, `"HTTP_ACCEPT_ENCODING"`). @param string Canonical header name, like `"Accept-Encoding"`. @param wild Default value to return if header is not present. @param array? Read this instead of `$_SERVER`. @return string|wild Header value if present, or `$default` if not.
getHTTPHeader
php
phacility/phabricator
src/aphront/AphrontRequest.php
https://github.com/phacility/phabricator/blob/master/src/aphront/AphrontRequest.php
Apache-2.0
public function isProxiedClusterRequest() { return (bool)self::getHTTPHeader('X-Phabricator-Cluster'); }
Is this a proxied request originating from within the Phabricator cluster? IMPORTANT: This means the request is dangerous! These requests are **more dangerous** than normal requests (they can not be safely proxied, because proxying them may cause a loop). Cluster requests are not guaranteed to come from a trusted source, and should never be treated as safer than normal requests. They are strictly less safe.
isProxiedClusterRequest
php
phacility/phabricator
src/aphront/AphrontRequest.php
https://github.com/phacility/phabricator/blob/master/src/aphront/AphrontRequest.php
Apache-2.0
public function deleteFileDataIfUnused( PhabricatorFileStorageEngine $engine, $engine_identifier, $handle) { // Check to see if any files are using storage. $usage = id(new PhabricatorFile())->loadAllWhere( 'storageEngine = %s AND storageHandle = %s LIMIT 1', $engine_identifier, $handle); // If there are no files using the storage, destroy the actual storage. if (!$usage) { try { $engine->deleteFile($handle); } catch (Exception $ex) { // In the worst case, we're leaving some data stranded in a storage // engine, which is not a big deal. phlog($ex); } } }
Destroy stored file data if there are no remaining files which reference it.
deleteFileDataIfUnused
php
phacility/phabricator
src/applications/files/storage/PhabricatorFile.php
https://github.com/phacility/phabricator/blob/master/src/applications/files/storage/PhabricatorFile.php
Apache-2.0
public function getFileDataIterator($begin = null, $end = null) { $engine = $this->instantiateStorageEngine(); $format = $this->newStorageFormat(); $iterator = $engine->getRawFileDataIterator( $this, $begin, $end, $format); return $iterator; }
Return an iterable which emits file content bytes. @param int Offset for the start of data. @param int Offset for the end of data. @return Iterable Iterable object which emits requested data.
getFileDataIterator
php
phacility/phabricator
src/applications/files/storage/PhabricatorFile.php
https://github.com/phacility/phabricator/blob/master/src/applications/files/storage/PhabricatorFile.php
Apache-2.0
public static function loadBuiltin(PhabricatorUser $user, $name) { $builtin = id(new PhabricatorFilesOnDiskBuiltinFile()) ->setName($name); $key = $builtin->getBuiltinFileKey(); return idx(self::loadBuiltins($user, array($builtin)), $key); }
Convenience wrapper for @{method:loadBuiltins}. @param PhabricatorUser Viewing user. @param string Single builtin name to load. @return PhabricatorFile Corresponding builtin file.
loadBuiltin
php
phacility/phabricator
src/applications/files/storage/PhabricatorFile.php
https://github.com/phacility/phabricator/blob/master/src/applications/files/storage/PhabricatorFile.php
Apache-2.0
public function attachToObject($phid) { $attachment_table = new PhabricatorFileAttachment(); $attachment_conn = $attachment_table->establishConnection('w'); queryfx( $attachment_conn, 'INSERT INTO %R (objectPHID, filePHID, attachmentMode, attacherPHID, dateCreated, dateModified) VALUES (%s, %s, %s, %ns, %d, %d) ON DUPLICATE KEY UPDATE attachmentMode = VALUES(attachmentMode), attacherPHID = VALUES(attacherPHID), dateModified = VALUES(dateModified)', $attachment_table, $phid, $this->getPHID(), PhabricatorFileAttachment::MODE_ATTACH, null, PhabricatorTime::getNow(), PhabricatorTime::getNow()); return $this; }
Write the policy edge between this file and some object. @param phid Object PHID to attach to. @return this
attachToObject
php
phacility/phabricator
src/applications/files/storage/PhabricatorFile.php
https://github.com/phacility/phabricator/blob/master/src/applications/files/storage/PhabricatorFile.php
Apache-2.0
public function withUnread($unread) { $this->unread = $unread; return $this; }
Filter results by read/unread status. Note that `true` means to return only unread notifications, while `false` means to return only //read// notifications. The default is `null`, which returns both. @param mixed True or false to filter results by read status. Null to remove the filter. @return this @task config
withUnread
php
phacility/phabricator
src/applications/notification/query/PhabricatorNotificationQuery.php
https://github.com/phacility/phabricator/blob/master/src/applications/notification/query/PhabricatorNotificationQuery.php
Apache-2.0
public static function isCommonPassword($password) { static $list; if ($list === null) { $list = self::loadWordlist(); } return isset($list[strtolower($password)]); }
Check if a password is extremely common. @param string Password to test. @return bool True if the password is pathologically weak. @task common
isCommonPassword
php
phacility/phabricator
src/applications/auth/constants/PhabricatorCommonPasswords.php
https://github.com/phacility/phabricator/blob/master/src/applications/auth/constants/PhabricatorCommonPasswords.php
Apache-2.0
public function shouldAllocateSupplementalResource( DrydockBlueprint $blueprint, DrydockResource $resource, DrydockLease $lease) { return false; }
Return true to try to allocate a new resource and expand the resource pool instead of permitting an otherwise valid acquisition on an existing resource. This allows the blueprint to provide a soft hint about when the resource pool should grow. Returning "true" in all cases generally makes sense when a blueprint controls a fixed pool of resources, like a particular number of physical hosts: you want to put all the hosts in service, so whenever it is possible to allocate a new host you want to do this. Returning "false" in all cases generally make sense when a blueprint has a flexible pool of expensive resources and you want to pack leases onto them as tightly as possible. @param DrydockBlueprint The blueprint for an existing resource being acquired. @param DrydockResource The resource being acquired, which we may want to build a supplemental resource for. @param DrydockLease The current lease performing acquisition. @return bool True to prefer allocating a supplemental resource. @task lease
shouldAllocateSupplementalResource
php
phacility/phabricator
src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
https://github.com/phacility/phabricator/blob/master/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
Apache-2.0
public static function getAllForAllocatingLease( DrydockLease $lease) { $impls = self::getAllBlueprintImplementations(); $keep = array(); foreach ($impls as $key => $impl) { // Don't use disabled blueprint types. if (!$impl->isEnabled()) { continue; } // Don't use blueprint types which can't allocate the correct kind of // resource. if ($impl->getType() != $lease->getResourceType()) { continue; } if (!$impl->canAnyBlueprintEverAllocateResourceForLease($lease)) { continue; } $keep[$key] = $impl; } return $keep; }
Get all the @{class:DrydockBlueprintImplementation}s which can possibly build a resource to satisfy a lease. This method returns blueprints which might, at some time, be able to build a resource which can satisfy the lease. They may not be able to build that resource right now. @param DrydockLease Requested lease. @return list<DrydockBlueprintImplementation> List of qualifying blueprint implementations.
getAllForAllocatingLease
php
phacility/phabricator
src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
https://github.com/phacility/phabricator/blob/master/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
Apache-2.0
protected function shouldUseConcurrentResourceLimit() { return false; }
Does this implementation use concurrent resource limits? Implementations can override this method to opt into standard limit behavior, which provides a simple concurrent resource limit. @return bool True to use limits.
shouldUseConcurrentResourceLimit
php
phacility/phabricator
src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
https://github.com/phacility/phabricator/blob/master/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
Apache-2.0
protected function getConcurrentResourceLimit(DrydockBlueprint $blueprint) { if ($this->shouldUseConcurrentResourceLimit()) { $limit = $blueprint->getFieldValue('allocator.limit'); $limit = (int)$limit; if ($limit > 0) { return $limit; } else { return null; } } return null; }
Get the effective concurrent resource limit for this blueprint. @param DrydockBlueprint Blueprint to get the limit for. @return int|null Limit, or `null` for no limit.
getConcurrentResourceLimit
php
phacility/phabricator
src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
https://github.com/phacility/phabricator/blob/master/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
Apache-2.0
protected function shouldLimitAllocatingPoolSize( DrydockBlueprint $blueprint) { // Limit on total number of active resources. $total_limit = $this->getConcurrentResourceLimit($blueprint); if ($total_limit === null) { return false; } $resource = new DrydockResource(); $conn = $resource->establishConnection('r'); $counts = queryfx_all( $conn, 'SELECT status, COUNT(*) N FROM %R WHERE blueprintPHID = %s AND status != %s GROUP BY status', $resource, $blueprint->getPHID(), DrydockResourceStatus::STATUS_DESTROYED); $counts = ipull($counts, 'N', 'status'); $n_alloc = idx($counts, DrydockResourceStatus::STATUS_PENDING, 0); $n_active = idx($counts, DrydockResourceStatus::STATUS_ACTIVE, 0); $n_broken = idx($counts, DrydockResourceStatus::STATUS_BROKEN, 0); $n_released = idx($counts, DrydockResourceStatus::STATUS_RELEASED, 0); // If we're at the limit on total active resources, limit additional // allocations. $n_total = ($n_alloc + $n_active + $n_broken + $n_released); if ($n_total >= $total_limit) { return true; } return false; }
Apply standard limits on resource allocation rate. @param DrydockBlueprint The blueprint requesting an allocation. @return bool True if further allocations should be limited.
shouldLimitAllocatingPoolSize
php
phacility/phabricator
src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
https://github.com/phacility/phabricator/blob/master/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
Apache-2.0
private static function replace(&$str, $check, $repl, $m = null) { $len = 0 - strlen($check); if (substr($str, $len) == $check) { $substr = substr($str, 0, $len); if (is_null($m) OR self::m($substr) > $m) { $str = $substr . $repl; } return true; } return false; }
Replaces the first string with the second, at the end of the string If third arg is given, then the preceding string must match that m count at least. @param string $str String to check @param string $check Ending to check for @param string $repl Replacement string @param int $m Optional minimum number of m() to meet @return bool Whether the $check string was at the end of the $str string. True does not necessarily mean that it was replaced.
replace
php
phacility/phabricator
externals/porter-stemmer/src/Porter.php
https://github.com/phacility/phabricator/blob/master/externals/porter-stemmer/src/Porter.php
Apache-2.0
private static function m($str) { $c = self::$regex_consonant; $v = self::$regex_vowel; $str = preg_replace("#^$c+#", '', $str); $str = preg_replace("#$v+$#", '', $str); preg_match_all("#($v+$c+)#", $str, $matches); return count($matches[1]); }
What, you mean it's not obvious from the name? m() measures the number of consonant sequences in $str. if c is a consonant sequence and v a vowel sequence, and <..> indicates arbitrary presence, <c><v> gives 0 <c>vc<v> gives 1 <c>vcvc<v> gives 2 <c>vcvcvc<v> gives 3 @param string $str The string to return the m count for @return int The m count
m
php
phacility/phabricator
externals/porter-stemmer/src/Porter.php
https://github.com/phacility/phabricator/blob/master/externals/porter-stemmer/src/Porter.php
Apache-2.0
private static function doubleConsonant($str) { $c = self::$regex_consonant; return preg_match("#$c{2}$#", $str, $matches) AND $matches[0][0] == $matches[0][1]; }
Returns true/false as to whether the given string contains two of the same consonant next to each other at the end of the string. @param string $str String to check @return bool Result
doubleConsonant
php
phacility/phabricator
externals/porter-stemmer/src/Porter.php
https://github.com/phacility/phabricator/blob/master/externals/porter-stemmer/src/Porter.php
Apache-2.0
private static function cvc($str) { $c = self::$regex_consonant; $v = self::$regex_vowel; return preg_match("#($c$v$c)$#", $str, $matches) AND strlen($matches[1]) == 3 AND $matches[1][2] != 'w' AND $matches[1][2] != 'x' AND $matches[1][2] != 'y'; }
Checks for ending CVC sequence where second C is not W, X or Y @param string $str String to check @return bool Result
cvc
php
phacility/phabricator
externals/porter-stemmer/src/Porter.php
https://github.com/phacility/phabricator/blob/master/externals/porter-stemmer/src/Porter.php
Apache-2.0
public function withIdentifiers(array $identifiers) { // Some workflows (like blame lookups) can pass in large numbers of // duplicate identifiers. We only care about unique identifiers, so // get rid of duplicates immediately. $identifiers = array_fuse($identifiers); $this->identifiers = $identifiers; return $this; }
Load commits by partial or full identifiers, e.g. "rXab82393", "rX1234", or "a9caf12". When an identifier matches multiple commits, they will all be returned; callers should be prepared to deal with more results than they queried for.
withIdentifiers
php
phacility/phabricator
src/applications/diffusion/query/DiffusionCommitQuery.php
https://github.com/phacility/phabricator/blob/master/src/applications/diffusion/query/DiffusionCommitQuery.php
Apache-2.0
public function withRepository(PhabricatorRepository $repository) { $this->withDefaultRepository($repository); $this->withRepositoryIDs(array($repository->getID())); return $this; }
Look up commits in a specific repository. This is a shorthand for calling @{method:withDefaultRepository} and @{method:withRepositoryIDs}.
withRepository
php
phacility/phabricator
src/applications/diffusion/query/DiffusionCommitQuery.php
https://github.com/phacility/phabricator/blob/master/src/applications/diffusion/query/DiffusionCommitQuery.php
Apache-2.0
public function withRepositoryPHIDs(array $phids) { $this->repositoryPHIDs = $phids; return $this; }
Look up commits in a specific repository. Prefer @{method:withRepositoryIDs}; the underlying table is keyed by ID such that this method requires a separate initial query to map PHID to ID.
withRepositoryPHIDs
php
phacility/phabricator
src/applications/diffusion/query/DiffusionCommitQuery.php
https://github.com/phacility/phabricator/blob/master/src/applications/diffusion/query/DiffusionCommitQuery.php
Apache-2.0
public function withDefaultRepository(PhabricatorRepository $repository) { $this->defaultRepository = $repository; return $this; }
If a default repository is provided, ambiguous commit identifiers will be assumed to belong to the default repository. For example, "r123" appearing in a commit message in repository X is likely to be unambiguously "rX123". Normally the reference would be considered ambiguous, but if you provide a default repository it will be correctly resolved.
withDefaultRepository
php
phacility/phabricator
src/applications/diffusion/query/DiffusionCommitQuery.php
https://github.com/phacility/phabricator/blob/master/src/applications/diffusion/query/DiffusionCommitQuery.php
Apache-2.0
private function newRoutingResult() { return id(new AphrontRoutingResult()) ->setSite($this->getSite()) ->setApplication($this->getApplication()); }
Build a new routing result for this map. @return AphrontRoutingResult New, empty routing result. @task routing
newRoutingResult
php
phacility/phabricator
src/aphront/site/AphrontRoutingMap.php
https://github.com/phacility/phabricator/blob/master/src/aphront/site/AphrontRoutingMap.php
Apache-2.0
public static function renderOneObject( PhabricatorMarkupInterface $object, $field, PhabricatorUser $viewer, $context_object = null) { return id(new PhabricatorMarkupEngine()) ->setViewer($viewer) ->setContextObject($context_object) ->addObject($object, $field) ->process() ->getOutput($object, $field); }
Convenience method for pushing a single object through the markup pipeline. @param PhabricatorMarkupInterface The object to render. @param string The field to render. @param PhabricatorUser User viewing the markup. @param object A context object for policy checks @return string Marked up output. @task markup
renderOneObject
php
phacility/phabricator
src/infrastructure/markup/PhabricatorMarkupEngine.php
https://github.com/phacility/phabricator/blob/master/src/infrastructure/markup/PhabricatorMarkupEngine.php
Apache-2.0
public function addObject(PhabricatorMarkupInterface $object, $field) { $key = $this->getMarkupFieldKey($object, $field); $this->objects[$key] = array( 'object' => $object, 'field' => $field, ); return $this; }
Queue an object for markup generation when @{method:process} is called. You can retrieve the output later with @{method:getOutput}. @param PhabricatorMarkupInterface The object to render. @param string The field to render. @return this @task markup
addObject
php
phacility/phabricator
src/infrastructure/markup/PhabricatorMarkupEngine.php
https://github.com/phacility/phabricator/blob/master/src/infrastructure/markup/PhabricatorMarkupEngine.php
Apache-2.0
public function getOutput(PhabricatorMarkupInterface $object, $field) { $key = $this->getMarkupFieldKey($object, $field); $this->requireKeyProcessed($key); return $this->objects[$key]['output']; }
Get the output of markup processing for a field queued with @{method:addObject}. Before you can call this method, you must call @{method:process}. @param PhabricatorMarkupInterface The object to retrieve. @param string The field to retrieve. @return string Processed output. @task markup
getOutput
php
phacility/phabricator
src/infrastructure/markup/PhabricatorMarkupEngine.php
https://github.com/phacility/phabricator/blob/master/src/infrastructure/markup/PhabricatorMarkupEngine.php
Apache-2.0
public function getEngineMetadata( PhabricatorMarkupInterface $object, $field, $metadata_key, $default = null) { $key = $this->getMarkupFieldKey($object, $field); $this->requireKeyProcessed($key); return idx($this->engineCaches[$key]['metadata'], $metadata_key, $default); }
Retrieve engine metadata for a given field. @param PhabricatorMarkupInterface The object to retrieve. @param string The field to retrieve. @param string The engine metadata field to retrieve. @param wild Optional default value. @task markup
getEngineMetadata
php
phacility/phabricator
src/infrastructure/markup/PhabricatorMarkupEngine.php
https://github.com/phacility/phabricator/blob/master/src/infrastructure/markup/PhabricatorMarkupEngine.php
Apache-2.0
public function setContextObject($object) { $this->contextObject = $object; return $this; }
Set the context object. Used to implement object permissions. @param The object in which context this remarkup is used. @return this @task markup
setContextObject
php
phacility/phabricator
src/infrastructure/markup/PhabricatorMarkupEngine.php
https://github.com/phacility/phabricator/blob/master/src/infrastructure/markup/PhabricatorMarkupEngine.php
Apache-2.0
public function getIsHealthy() { return $this->isHealthy; }
Is the database currently healthy?
getIsHealthy
php
phacility/phabricator
src/infrastructure/cluster/PhabricatorClusterServiceHealthRecord.php
https://github.com/phacility/phabricator/blob/master/src/infrastructure/cluster/PhabricatorClusterServiceHealthRecord.php
Apache-2.0
public function getShouldCheck() { return $this->shouldCheck; }
Should this request check database health?
getShouldCheck
php
phacility/phabricator
src/infrastructure/cluster/PhabricatorClusterServiceHealthRecord.php
https://github.com/phacility/phabricator/blob/master/src/infrastructure/cluster/PhabricatorClusterServiceHealthRecord.php
Apache-2.0
public function getUpEventCount() { return $this->upEventCount; }
How many recent health checks were successful?
getUpEventCount
php
phacility/phabricator
src/infrastructure/cluster/PhabricatorClusterServiceHealthRecord.php
https://github.com/phacility/phabricator/blob/master/src/infrastructure/cluster/PhabricatorClusterServiceHealthRecord.php
Apache-2.0
public function getDownEventCount() { return $this->downEventCount; }
How many recent health checks failed?
getDownEventCount
php
phacility/phabricator
src/infrastructure/cluster/PhabricatorClusterServiceHealthRecord.php
https://github.com/phacility/phabricator/blob/master/src/infrastructure/cluster/PhabricatorClusterServiceHealthRecord.php
Apache-2.0
public function getRequiredEventCount() { // NOTE: If you change this value, update the "Cluster: Databases" docs. return 5; }
Number of failures or successes we need to see in a row before we change the state.
getRequiredEventCount
php
phacility/phabricator
src/infrastructure/cluster/PhabricatorClusterServiceHealthRecord.php
https://github.com/phacility/phabricator/blob/master/src/infrastructure/cluster/PhabricatorClusterServiceHealthRecord.php
Apache-2.0
public function getHealthCheckFrequency() { // NOTE: If you change this value, update the "Cluster: Databases" docs. return 3; }
Seconds to wait between health checks.
getHealthCheckFrequency
php
phacility/phabricator
src/infrastructure/cluster/PhabricatorClusterServiceHealthRecord.php
https://github.com/phacility/phabricator/blob/master/src/infrastructure/cluster/PhabricatorClusterServiceHealthRecord.php
Apache-2.0
public function addPHPConfigOriginalValue($php_config, $value) { $this->originalPHPConfigValues[$php_config] = $value; return $this; }
Set an explicit value to display when showing the user PHP configuration values. If Phabricator has changed a value by the time a config issue is raised, you can provide the original value here so the UI makes sense. For example, we alter `memory_limit` during startup, so if the original value is not provided it will look like it is always set to `-1`. @param string PHP configuration option to provide a value for. @param string Explicit value to show in the UI. @return this
addPHPConfigOriginalValue
php
phacility/phabricator
src/applications/config/issue/PhabricatorSetupIssue.php
https://github.com/phacility/phabricator/blob/master/src/applications/config/issue/PhabricatorSetupIssue.php
Apache-2.0
public function overrideEnvConfig($key, $value) { PhabricatorEnv::overrideTestEnvConfig( $this->key, $key, $value); return $this; }
Override a configuration key in this scope, setting it to a new value. @param string Key to override. @param wild New value. @return this @task override
overrideEnvConfig
php
phacility/phabricator
src/infrastructure/env/PhabricatorScopedEnv.php
https://github.com/phacility/phabricator/blob/master/src/infrastructure/env/PhabricatorScopedEnv.php
Apache-2.0
public function __destruct() { if (!$this->isPopped) { PhabricatorEnv::popTestEnvironment($this->key); $this->isPopped = true; } }
Release the scoped environment. @return void @task internal
__destruct
php
phacility/phabricator
src/infrastructure/env/PhabricatorScopedEnv.php
https://github.com/phacility/phabricator/blob/master/src/infrastructure/env/PhabricatorScopedEnv.php
Apache-2.0
private function markReviewerComments($object, array $xactions) { $acting_phid = $this->getActingAsPHID(); if (!$acting_phid) { return; } $diff = $this->getActiveDiff($object); if (!$diff) { return; } $has_comment = false; foreach ($xactions as $xaction) { if ($xaction->hasComment()) { $has_comment = true; break; } } if (!$has_comment) { return; } $reviewer_table = new DifferentialReviewer(); $conn = $reviewer_table->establishConnection('w'); queryfx( $conn, 'UPDATE %T SET lastCommentDiffPHID = %s WHERE revisionPHID = %s AND reviewerPHID = %s', $reviewer_table->getTableName(), $diff->getPHID(), $object->getPHID(), $acting_phid); }
When a reviewer makes a comment, mark the last revision they commented on. This allows us to show a hint to help authors and other reviewers quickly distinguish between reviewers who have participated in the discussion and reviewers who haven't been part of it.
markReviewerComments
php
phacility/phabricator
src/applications/differential/editor/DifferentialTransactionEditor.php
https://github.com/phacility/phabricator/blob/master/src/applications/differential/editor/DifferentialTransactionEditor.php
Apache-2.0
public function getAdapterContentType() { return get_class($this); }
NOTE: You generally should not override this; it exists to support legacy adapters which had hard-coded content types.
getAdapterContentType
php
phacility/phabricator
src/applications/herald/adapter/HeraldAdapter.php
https://github.com/phacility/phabricator/blob/master/src/applications/herald/adapter/HeraldAdapter.php
Apache-2.0
public function isSingleEventAdapter() { return false; }
Does this adapter's event fire only once? Single use adapters (like pre-commit and diff adapters) only fire once, so fields like "Is new object" don't make sense to apply to their content. @return bool
isSingleEventAdapter
php
phacility/phabricator
src/applications/herald/adapter/HeraldAdapter.php
https://github.com/phacility/phabricator/blob/master/src/applications/herald/adapter/HeraldAdapter.php
Apache-2.0
public function setIcon($icon) { phlog( pht('Deprecated call to setIcon(), use setImageIcon() instead.')); return $this->setImageIcon($icon); }
This method has been deprecated, use @{method:setImageIcon} instead. @deprecated
setIcon
php
phacility/phabricator
src/view/phui/PHUIObjectItemView.php
https://github.com/phacility/phabricator/blob/master/src/view/phui/PHUIObjectItemView.php
Apache-2.0
public function setContinueOnNoEffect($continue) { $this->continueOnNoEffect = $continue; return $this; }
When the editor tries to apply transactions that have no effect, should it raise an exception (default) or drop them and continue? Generally, you will set this flag for edits coming from "Edit" interfaces, and leave it cleared for edits coming from "Comment" interfaces, so the user will get a useful error if they try to submit a comment that does nothing (e.g., empty comment with a status change that has already been performed by another user). @param bool True to drop transactions without effect and continue. @return this
setContinueOnNoEffect
php
phacility/phabricator
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
https://github.com/phacility/phabricator/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Apache-2.0
public function setContinueOnMissingFields($continue_on_missing_fields) { $this->continueOnMissingFields = $continue_on_missing_fields; return $this; }
When the editor tries to apply transactions which don't populate all of an object's required fields, should it raise an exception (default) or drop them and continue? For example, if a user adds a new required custom field (like "Severity") to a task, all existing tasks won't have it populated. When users manually edit existing tasks, it's usually desirable to have them provide a severity. However, other operations (like batch editing just the owner of a task) will fail by default. By setting this flag for edit operations which apply to specific fields (like the priority, batch, and merge editors in Maniphest), these operations can continue to function even if an object is outdated. @param bool True to continue when transactions don't completely satisfy all required fields. @return this
setContinueOnMissingFields
php
phacility/phabricator
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
https://github.com/phacility/phabricator/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Apache-2.0
public function setParentMessageID($parent_message_id) { $this->parentMessageID = $parent_message_id; return $this; }
Not strictly necessary, but reply handlers ideally set this value to make email threading work better.
setParentMessageID
php
phacility/phabricator
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
https://github.com/phacility/phabricator/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Apache-2.0
protected function applyBuiltinInternalTransaction( PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction) { switch ($xaction->getTransactionType()) { case PhabricatorTransactions::TYPE_VIEW_POLICY: $object->setViewPolicy($xaction->getNewValue()); break; case PhabricatorTransactions::TYPE_EDIT_POLICY: $object->setEditPolicy($xaction->getNewValue()); break; case PhabricatorTransactions::TYPE_JOIN_POLICY: $object->setJoinPolicy($xaction->getNewValue()); break; case PhabricatorTransactions::TYPE_INTERACT_POLICY: $object->setInteractPolicy($xaction->getNewValue()); break; case PhabricatorTransactions::TYPE_SPACE: $object->setSpacePHID($xaction->getNewValue()); break; case PhabricatorTransactions::TYPE_SUBTYPE: $object->setEditEngineSubtype($xaction->getNewValue()); break; } }
@{class:PhabricatorTransactions} provides many built-in transactions which should not require much - if any - code in specific applications. This method is a hook for the exceedingly-rare cases where you may need to do **additional** work for built-in transactions. Developers should extend this method, making sure to return the parent implementation regardless of handling any transactions. See also @{method:applyBuiltinExternalTransaction}.
applyBuiltinInternalTransaction
php
phacility/phabricator
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
https://github.com/phacility/phabricator/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Apache-2.0
protected function populateTransaction( PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction) { $actor = $this->getActor(); // TODO: This needs to be more sophisticated once we have meta-policies. $xaction->setViewPolicy(PhabricatorPolicies::POLICY_PUBLIC); if ($actor->isOmnipotent()) { $xaction->setEditPolicy(PhabricatorPolicies::POLICY_NOONE); } else { $xaction->setEditPolicy($this->getActingAsPHID()); } // If the transaction already has an explicit author PHID, allow it to // stand. This is used by applications like Owners that hook into the // post-apply change pipeline. if (!$xaction->getAuthorPHID()) { $xaction->setAuthorPHID($this->getActingAsPHID()); } $xaction->setContentSource($this->getContentSource()); $xaction->attachViewer($actor); $xaction->attachObject($object); if ($object->getPHID()) { $xaction->setObjectPHID($object->getPHID()); } if ($this->getIsSilent()) { $xaction->setIsSilentTransaction(true); } return $xaction; }
Fill in a transaction's common values, like author and content source.
populateTransaction
php
phacility/phabricator
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
https://github.com/phacility/phabricator/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Apache-2.0
protected function willPublish(PhabricatorLiskDAO $object, array $xactions) { return $object; }
Load any object state which is required to publish transactions. This hook is invoked in the main process before we compute data related to publishing transactions (like email "To" and "CC" lists), and again in the worker before publishing occurs. @return object Publishable object. @task workers
willPublish
php
phacility/phabricator
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
https://github.com/phacility/phabricator/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Apache-2.0
private function getWorkerState() { $state = array(); foreach ($this->getAutomaticStateProperties() as $property) { $state[$property] = $this->$property; } $custom_state = $this->getCustomWorkerState(); $custom_encoding = $this->getCustomWorkerStateEncoding(); $state += array( 'excludeMailRecipientPHIDs' => $this->getExcludeMailRecipientPHIDs(), 'custom' => $this->encodeStateForStorage($custom_state, $custom_encoding), 'custom.encoding' => $custom_encoding, ); return $state; }
Convert the editor state to a serializable dictionary which can be passed to a worker. This data will be loaded with @{method:loadWorkerState} in the worker. @return dict<string, wild> Serializable editor state. @task workers
getWorkerState
php
phacility/phabricator
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
https://github.com/phacility/phabricator/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Apache-2.0
protected function getCustomWorkerState() { return array(); }
Hook; return custom properties which need to be passed to workers. @return dict<string, wild> Custom properties. @task workers
getCustomWorkerState
php
phacility/phabricator
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
https://github.com/phacility/phabricator/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Apache-2.0
protected function getCustomWorkerStateEncoding() { return array(); }
Hook; return storage encoding for custom properties which need to be passed to workers. This primarily allows binary data to be passed to workers and survive JSON encoding. @return dict<string, string> Property encodings. @task workers
getCustomWorkerStateEncoding
php
phacility/phabricator
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
https://github.com/phacility/phabricator/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Apache-2.0
protected function loadCustomWorkerState(array $state) { return $this; }
Hook; set custom properties on the editor from data emitted by @{method:getCustomWorkerState}. @param dict<string, wild> Custom state, from @{method:getCustomWorkerState}. @return this @task workers
loadCustomWorkerState
php
phacility/phabricator
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
https://github.com/phacility/phabricator/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Apache-2.0
private function getAutomaticStateProperties() { return array( 'parentMessageID', 'isNewObject', 'heraldEmailPHIDs', 'heraldForcedEmailPHIDs', 'heraldHeader', 'mailToPHIDs', 'mailCCPHIDs', 'feedNotifyPHIDs', 'feedRelatedPHIDs', 'feedShouldPublish', 'mailShouldSend', 'mustEncrypt', 'mailStamps', 'mailUnexpandablePHIDs', 'mailMutedPHIDs', 'webhookMap', 'silent', 'sendHistory', ); }
Get a list of object properties which should be automatically sent to workers in the state data. These properties will be automatically stored and loaded by the editor in the worker. @return list<string> List of properties. @task workers
getAutomaticStateProperties
php
phacility/phabricator
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
https://github.com/phacility/phabricator/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Apache-2.0
private function shouldScramblePolicy($policy) { switch ($policy) { case PhabricatorPolicies::POLICY_PUBLIC: case PhabricatorPolicies::POLICY_USER: return false; } return true; }
Check if a policy is strong enough to justify scrambling. Objects which are set to very open policies don't need to scramble their files, and files with very open policies don't need to be scrambled when associated objects change.
shouldScramblePolicy
php
phacility/phabricator
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
https://github.com/phacility/phabricator/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Apache-2.0
public function isUnlisted() { return false; }
Return `true` if this application should never appear in application lists in the UI. Primarily intended for unit test applications or other pseudo-applications. Few applications should be unlisted. For most applications, use @{method:isLaunchable} to hide them from main launch views instead. @return bool True to remove application from UI lists.
isUnlisted
php
phacility/phabricator
src/applications/base/PhabricatorApplication.php
https://github.com/phacility/phabricator/blob/master/src/applications/base/PhabricatorApplication.php
Apache-2.0
public function isLaunchable() { return true; }
Return `true` if this application is a normal application with a base URI and a web interface. Launchable applications can be pinned to the home page, and show up in the "Launcher" view of the Applications application. Making an application unlaunchable prevents pinning and hides it from this view. Usually, an application should be marked unlaunchable if: - it is available on every page anyway (like search); or - it does not have a web interface (like subscriptions); or - it is still pre-release and being intentionally buried. To hide applications more completely, use @{method:isUnlisted}. @return bool True if the application is launchable.
isLaunchable
php
phacility/phabricator
src/applications/base/PhabricatorApplication.php
https://github.com/phacility/phabricator/blob/master/src/applications/base/PhabricatorApplication.php
Apache-2.0
public function isPinnedByDefault(PhabricatorUser $viewer) { return false; }
Return `true` if this application should be pinned by default. Users who have not yet set preferences see a default list of applications. @param PhabricatorUser User viewing the pinned application list. @return bool True if this application should be pinned by default.
isPinnedByDefault
php
phacility/phabricator
src/applications/base/PhabricatorApplication.php
https://github.com/phacility/phabricator/blob/master/src/applications/base/PhabricatorApplication.php
Apache-2.0
public function getFlavorText() { return null; }
You can provide an optional piece of flavor text for the application. This is currently rendered in application launch views if the application has no status elements. @return string|null Flavor text. @task ui
getFlavorText
php
phacility/phabricator
src/applications/base/PhabricatorApplication.php
https://github.com/phacility/phabricator/blob/master/src/applications/base/PhabricatorApplication.php
Apache-2.0
public function buildMainMenuItems( PhabricatorUser $user, PhabricatorController $controller = null) { return array(); }
Build items for the main menu. @param PhabricatorUser The viewing user. @param AphrontController The current controller. May be null for special pages like 404, exception handlers, etc. @return list<PHUIListItemView> List of menu items. @task ui
buildMainMenuItems
php
phacility/phabricator
src/applications/base/PhabricatorApplication.php
https://github.com/phacility/phabricator/blob/master/src/applications/base/PhabricatorApplication.php
Apache-2.0
public function canApplyToObject(PhabricatorPolicyInterface $object) { return true; }
Return `true` if this rule can be applied to the given object. Some policy rules may only operation on certain kinds of objects. For example, a "task author" rule can only operate on tasks.
canApplyToObject
php
phacility/phabricator
src/applications/policy/rule/PhabricatorPolicyRule.php
https://github.com/phacility/phabricator/blob/master/src/applications/policy/rule/PhabricatorPolicyRule.php
Apache-2.0
public function ruleHasEffect($value) { return true; }
Return `true` if the given value creates a rule with a meaningful effect. An example of a rule with no meaningful effect is a "users" rule with no users specified. @return bool True if the value creates a meaningful rule.
ruleHasEffect
php
phacility/phabricator
src/applications/policy/rule/PhabricatorPolicyRule.php
https://github.com/phacility/phabricator/blob/master/src/applications/policy/rule/PhabricatorPolicyRule.php
Apache-2.0
public static function passTransactionHintToRule( PhabricatorPolicyInterface $object, PhabricatorPolicyRule $rule, $hint) { $cache = PhabricatorCaches::getRequestCache(); $cache->setKey(self::getObjectPolicyCacheKey($object, $rule), $hint); }
Tell policy rules about upcoming transaction effects. Before transaction effects are applied, we try to stop users from making edits which will lock them out of objects. We can't do this perfectly, since they can set a policy to "the moon is full" moments before it wanes, but we try to prevent as many mistakes as possible. Some policy rules depend on complex checks against object state which we can't set up ahead of time. For example, subscriptions require database writes. In cases like this, instead of doing writes, you can pass a hint about an object to a policy rule. The rule can then look for hints and use them in rendering a verdict about whether the user will be able to see the object or not after applying the policy change. @param PhabricatorPolicyInterface Object to pass a hint about. @param PhabricatorPolicyRule Rule to pass hint to. @param wild Hint. @return void
passTransactionHintToRule
php
phacility/phabricator
src/applications/policy/rule/PhabricatorPolicyRule.php
https://github.com/phacility/phabricator/blob/master/src/applications/policy/rule/PhabricatorPolicyRule.php
Apache-2.0
public function getObjectPolicyKey() { return null; }
Return a unique string like "maniphest.author" to expose this rule as an object policy. Object policy rules, like "Task Author", are more advanced than basic policy rules (like "All Users") but not as powerful as custom rules. @return string Unique identifier for this rule. @task objectpolicy
getObjectPolicyKey
php
phacility/phabricator
src/applications/policy/rule/PhabricatorPolicyRule.php
https://github.com/phacility/phabricator/blob/master/src/applications/policy/rule/PhabricatorPolicyRule.php
Apache-2.0
public function instanceUrl() { $id = $this['id']; if (!$id) { $class = get_class($this); $msg = "Could not determine which URL to request: $class instance " . "has invalid ID: $id"; throw new Stripe_InvalidRequestError($msg, null); } if (isset($this['customer'])) { $parent = $this['customer']; $base = self::classUrl('Stripe_Customer'); } else if (isset($this['recipient'])) { $parent = $this['recipient']; $base = self::classUrl('Stripe_Recipient'); } else { return null; } $parent = Stripe_ApiRequestor::utf8($parent); $id = Stripe_ApiRequestor::utf8($id); $parentExtn = urlencode($parent); $extn = urlencode($id); return "$base/$parentExtn/cards/$extn"; }
@return string The instance URL for this resource. It needs to be special cased because it doesn't fit into the standard resource pattern.
instanceUrl
php
phacility/phabricator
externals/stripe-php/lib/Stripe/Card.php
https://github.com/phacility/phabricator/blob/master/externals/stripe-php/lib/Stripe/Card.php
Apache-2.0
public function setComplete($complete) { $this->complete = $complete; return $this; }
Set whether or not the underlying object is complete. See @{method:isComplete} for an explanation of what it means to be complete. @param bool True if the handle represents a complete object. @return this
setComplete
php
phacility/phabricator
src/applications/phid/PhabricatorObjectHandle.php
https://github.com/phacility/phabricator/blob/master/src/applications/phid/PhabricatorObjectHandle.php
Apache-2.0
public function isComplete() { return $this->complete; }
Determine if the handle represents an object which was completely loaded (i.e., the underlying object exists) vs an object which could not be completely loaded (e.g., the type or data for the PHID could not be identified or located). Basically, @{class:PhabricatorHandleQuery} gives you back a handle for any PHID you give it, but it gives you a complete handle only for valid PHIDs. @return bool True if the handle represents a complete object.
isComplete
php
phacility/phabricator
src/applications/phid/PhabricatorObjectHandle.php
https://github.com/phacility/phabricator/blob/master/src/applications/phid/PhabricatorObjectHandle.php
Apache-2.0
private function getDatesInMonth() { $viewer = $this->getViewer(); $timezone = new DateTimeZone($viewer->getTimezoneIdentifier()); $month = $this->month; $year = $this->year; list($next_year, $next_month) = $this->getNextYearAndMonth(); $end_date = new DateTime("{$next_year}-{$next_month}-01", $timezone); list($start_of_week, $end_of_week) = $this->getWeekStartAndEnd(); $days_in_month = id(clone $end_date)->modify('-1 day')->format('d'); $first_month_day_date = new DateTime("{$year}-{$month}-01", $timezone); $last_month_day_date = id(clone $end_date)->modify('-1 day'); $first_weekday_of_month = $first_month_day_date->format('w'); $last_weekday_of_month = $last_month_day_date->format('w'); $day_date = id(clone $first_month_day_date); $num_days_display = $days_in_month; if ($start_of_week !== $first_weekday_of_month) { $interim_start_num = ($first_weekday_of_month + 7 - $start_of_week) % 7; $num_days_display += $interim_start_num; $day_date->modify('-'.$interim_start_num.' days'); } if ($end_of_week !== $last_weekday_of_month) { $interim_end_day_num = ($end_of_week - $last_weekday_of_month + 7) % 7; $num_days_display += $interim_end_day_num; $end_date->modify('+'.$interim_end_day_num.' days'); } $days = array(); for ($day = 1; $day <= $num_days_display; $day++) { $day_epoch = $day_date->format('U'); $end_epoch = $end_date->format('U'); if ($day_epoch >= $end_epoch) { break; } else { $days[] = clone $day_date; } $day_date->modify('+1 day'); } return $days; }
Return a DateTime object representing the first moment in each day in the month, according to the user's locale. @return list List of DateTimes, one for each day.
getDatesInMonth
php
phacility/phabricator
src/view/phui/calendar/PHUICalendarMonthView.php
https://github.com/phacility/phabricator/blob/master/src/view/phui/calendar/PHUICalendarMonthView.php
Apache-2.0
function xhprof_parse_parent_child($parent_child) { $ret = explode("==>", $parent_child); // Return if both parent and child are set if (isset($ret[1])) { return $ret; } return array(null, $ret[0]); }
Takes a parent/child function name encoded as "a==>b" and returns array("a", "b"). @author Kannan
xhprof_parse_parent_child
php
phacility/phabricator
externals/xhprof/xhprof_lib.php
https://github.com/phacility/phabricator/blob/master/externals/xhprof/xhprof_lib.php
Apache-2.0
function xhprof_build_parent_child_key($parent, $child) { if ($parent) { return $parent . "==>" . $child; } else { return $child; } }
Given parent & child function name, composes the key in the format present in the raw data. @author Kannan
xhprof_build_parent_child_key
php
phacility/phabricator
externals/xhprof/xhprof_lib.php
https://github.com/phacility/phabricator/blob/master/externals/xhprof/xhprof_lib.php
Apache-2.0
function xhprof_valid_run($run_id, $raw_data) { $main_info = $raw_data["main()"]; if (empty($main_info)) { xhprof_error("XHProf: main() missing in raw data for Run ID: $run_id"); return false; } // raw data should contain either wall time or samples information... if (isset($main_info["wt"])) { $metric = "wt"; } else if (isset($main_info["samples"])) { $metric = "samples"; } else { xhprof_error("XHProf: Wall Time information missing from Run ID: $run_id"); return false; } foreach ($raw_data as $info) { $val = $info[$metric]; // basic sanity checks... if ($val < 0) { xhprof_error("XHProf: $metric should not be negative: Run ID $run_id" . serialize($info)); return false; } if ($val > (86400000000)) { xhprof_error("XHProf: $metric > 1 day found in Run ID: $run_id " . serialize($info)); return false; } } return true; }
Checks if XHProf raw data appears to be valid and not corrupted. @param int $run_id Run id of run to be pruned. [Used only for reporting errors.] @param array $raw_data XHProf raw data to be pruned & validated. @return bool true on success, false on failure @author Kannan
xhprof_valid_run
php
phacility/phabricator
externals/xhprof/xhprof_lib.php
https://github.com/phacility/phabricator/blob/master/externals/xhprof/xhprof_lib.php
Apache-2.0
function xhprof_normalize_metrics($raw_data, $num_runs) { if (empty($raw_data) || ($num_runs == 0)) { return $raw_data; } $raw_data_total = array(); if (isset($raw_data["==>main()"]) && isset($raw_data["main()"])) { xhprof_error("XHProf Error: both ==>main() and main() set in raw data..."); } foreach ($raw_data as $parent_child => $info) { foreach ($info as $metric => $value) { $raw_data_total[$parent_child][$metric] = ($value / $num_runs); } } return $raw_data_total; }
Takes raw XHProf data that was aggregated over "$num_runs" number of runs averages/nomalizes the data. Essentially the various metrics collected are divided by $num_runs. @author Kannan
xhprof_normalize_metrics
php
phacility/phabricator
externals/xhprof/xhprof_lib.php
https://github.com/phacility/phabricator/blob/master/externals/xhprof/xhprof_lib.php
Apache-2.0
function xhprof_compute_diff($xhprof_data1, $xhprof_data2) { global $display_calls; // use the second run to decide what metrics we will do the diff on $metrics = xhprof_get_metrics($xhprof_data2); $xhprof_delta = $xhprof_data2; foreach ($xhprof_data1 as $parent_child => $info) { if (!isset($xhprof_delta[$parent_child])) { // this pc combination was not present in run1; // initialize all values to zero. if ($display_calls) { $xhprof_delta[$parent_child] = array("ct" => 0); } else { $xhprof_delta[$parent_child] = array(); } foreach ($metrics as $metric) { $xhprof_delta[$parent_child][$metric] = 0; } } if ($display_calls) { $xhprof_delta[$parent_child]["ct"] -= $info["ct"]; } foreach ($metrics as $metric) { $xhprof_delta[$parent_child][$metric] -= $info[$metric]; } } return $xhprof_delta; }
Hierarchical diff: Compute and return difference of two call graphs: Run2 - Run1. @author Kannan
xhprof_compute_diff
php
phacility/phabricator
externals/xhprof/xhprof_lib.php
https://github.com/phacility/phabricator/blob/master/externals/xhprof/xhprof_lib.php
Apache-2.0
function xhprof_array_set($arr, $k, $v) { $arr[$k] = $v; return $arr; }
Set one key in an array and return the array @author Kannan
xhprof_array_set
php
phacility/phabricator
externals/xhprof/xhprof_lib.php
https://github.com/phacility/phabricator/blob/master/externals/xhprof/xhprof_lib.php
Apache-2.0
function xhprof_array_unset($arr, $k) { unset($arr[$k]); return $arr; }
Removes/unsets one key in an array and return the array @author Kannan
xhprof_array_unset
php
phacility/phabricator
externals/xhprof/xhprof_lib.php
https://github.com/phacility/phabricator/blob/master/externals/xhprof/xhprof_lib.php
Apache-2.0
function xhprof_get_param_helper($param) { $val = null; if (isset($_GET[$param])) $val = $_GET[$param]; else if (isset($_POST[$param])) { $val = $_POST[$param]; } return $val; }
Internal helper function used by various xhprof_get_param* flavors for various types of parameters. @param string name of the URL query string param @author Kannan
xhprof_get_param_helper
php
phacility/phabricator
externals/xhprof/xhprof_lib.php
https://github.com/phacility/phabricator/blob/master/externals/xhprof/xhprof_lib.php
Apache-2.0
function xhprof_get_string_param($param, $default = '') { $val = xhprof_get_param_helper($param); if ($val === null) return $default; return $val; }
Extracts value for string param $param from query string. If param is not specified, return the $default value. @author Kannan
xhprof_get_string_param
php
phacility/phabricator
externals/xhprof/xhprof_lib.php
https://github.com/phacility/phabricator/blob/master/externals/xhprof/xhprof_lib.php
Apache-2.0
function xhprof_get_uint_param($param, $default = 0) { $val = xhprof_get_param_helper($param); if ($val === null) $val = $default; // trim leading/trailing whitespace $val = trim($val); // if it only contains digits, then ok.. if (ctype_digit($val)) { return $val; } xhprof_error("$param is $val. It must be an unsigned integer."); return null; }
Extracts value for unsigned integer param $param from query string. If param is not specified, return the $default value. If value is not a valid unsigned integer, logs error and returns null. @author Kannan
xhprof_get_uint_param
php
phacility/phabricator
externals/xhprof/xhprof_lib.php
https://github.com/phacility/phabricator/blob/master/externals/xhprof/xhprof_lib.php
Apache-2.0
function xhprof_get_float_param($param, $default = 0) { $val = xhprof_get_param_helper($param); if ($val === null) $val = $default; // trim leading/trailing whitespace $val = trim($val); // TBD: confirm the value is indeed a float. if (true) // for now.. return (float)$val; xhprof_error("$param is $val. It must be a float."); return null; }
Extracts value for a float param $param from query string. If param is not specified, return the $default value. If value is not a valid unsigned integer, logs error and returns null. @author Kannan
xhprof_get_float_param
php
phacility/phabricator
externals/xhprof/xhprof_lib.php
https://github.com/phacility/phabricator/blob/master/externals/xhprof/xhprof_lib.php
Apache-2.0
function xhprof_get_bool_param($param, $default = false) { $val = xhprof_get_param_helper($param); if ($val === null) $val = $default; // trim leading/trailing whitespace $val = trim($val); switch (strtolower($val)) { case '0': case '1': $val = (bool)$val; break; case 'true': case 'on': case 'yes': $val = true; break; case 'false': case 'off': case 'no': $val = false; break; default: xhprof_error("$param is $val. It must be a valid boolean string."); return null; } return $val; }
Extracts value for a boolean param $param from query string. If param is not specified, return the $default value. If value is not a valid unsigned integer, logs error and returns null. @author Kannan
xhprof_get_bool_param
php
phacility/phabricator
externals/xhprof/xhprof_lib.php
https://github.com/phacility/phabricator/blob/master/externals/xhprof/xhprof_lib.php
Apache-2.0
function xhprof_param_init($params) { /* Create variables specified in $params keys, init defaults */ foreach ($params as $k => $v) { switch ($v[0]) { case XHPROF_STRING_PARAM: $p = xhprof_get_string_param($k, $v[1]); break; case XHPROF_UINT_PARAM: $p = xhprof_get_uint_param($k, $v[1]); break; case XHPROF_FLOAT_PARAM: $p = xhprof_get_float_param($k, $v[1]); break; case XHPROF_BOOL_PARAM: $p = xhprof_get_bool_param($k, $v[1]); break; default: xhprof_error("Invalid param type passed to xhprof_param_init: " . $v[0]); exit(); } // create a global variable using the parameter name. $GLOBALS[$k] = $p; } }
Initialize params from URL query string. The function creates globals variables for each of the params and if the URL query string doesn't specify a particular param initializes them with the corresponding default value specified in the input. @params array $params An array whose keys are the names of URL params who value needs to be retrieved from the URL query string. PHP globals are created with these names. The value is itself an array with 2-elems (the param type, and its default value). If a param is not specified in the query string the default value is used. @author Kannan
xhprof_param_init
php
phacility/phabricator
externals/xhprof/xhprof_lib.php
https://github.com/phacility/phabricator/blob/master/externals/xhprof/xhprof_lib.php
Apache-2.0
public function dispose() { if (!self::$instance) { throw new Exception(pht( 'Attempting to dispose of write guard, but no write guard is active!')); } if ($this->allowDepth > 0) { throw new Exception( pht( 'Imbalanced %s: more %s calls than %s calls.', __CLASS__, 'beginUnguardedWrites()', 'endUnguardedWrites()')); } self::$instance = null; }
Dispose of the active write guard. You must call this method when you are done with a write guard. You do not normally need to call this yourself. @return void @task manage
dispose
php
phacility/phabricator
src/aphront/writeguard/AphrontWriteGuard.php
https://github.com/phacility/phabricator/blob/master/src/aphront/writeguard/AphrontWriteGuard.php
Apache-2.0
public static function isGuardActive() { return (bool)self::$instance; }
Determine if there is an active write guard. @return bool @task manage
isGuardActive
php
phacility/phabricator
src/aphront/writeguard/AphrontWriteGuard.php
https://github.com/phacility/phabricator/blob/master/src/aphront/writeguard/AphrontWriteGuard.php
Apache-2.0