本文整理匯總了PHP中AphrontWriteGuard::isGuardActive方法的典型用法代碼示例。如果您正苦於以下問題:PHP AphrontWriteGuard::isGuardActive方法的具體用法?PHP AphrontWriteGuard::isGuardActive怎麽用?PHP AphrontWriteGuard::isGuardActive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類AphrontWriteGuard
的用法示例。
在下文中一共展示了AphrontWriteGuard::isGuardActive方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: resetSetupState
public static final function resetSetupState()
{
$cache = PhabricatorCaches::getSetupCache();
$cache->deleteKey('phabricator.setup.issue-keys');
$server_cache = PhabricatorCaches::getServerStateCache();
$server_cache->deleteKey('phabricator.in-flight');
$use_scope = AphrontWriteGuard::isGuardActive();
if ($use_scope) {
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
} else {
AphrontWriteGuard::allowDangerousUnguardedWrites(true);
}
$caught = null;
try {
$db_cache = new PhabricatorKeyValueDatabaseCache();
$db_cache->deleteKey('phabricator.setup.issue-keys');
} catch (Exception $ex) {
$caught = $ex;
}
if ($use_scope) {
unset($unguarded);
} else {
AphrontWriteGuard::allowDangerousUnguardedWrites(false);
}
if ($caught) {
throw $caught;
}
}
示例2: stopProfiler
public static function stopProfiler()
{
if (self::$profilerStarted) {
$data = xhprof_disable();
$data = serialize($data);
$file_class = 'PhabricatorFile';
// Since these happen on GET we can't do guarded writes. These also
// sometimes happen after we've disposed of the write guard; in this
// case we need to disable the whole mechanism.
$use_scope = AphrontWriteGuard::isGuardActive();
if ($use_scope) {
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
} else {
AphrontWriteGuard::allowDangerousUnguardedWrites(true);
}
$caught = null;
try {
$file = call_user_func(array($file_class, 'newFromFileData'), $data, array('mime-type' => 'application/xhprof', 'name' => 'profile.xhprof'));
} catch (Exception $ex) {
$caught = $ex;
}
if ($use_scope) {
unset($unguarded);
} else {
AphrontWriteGuard::allowDangerousUnguardedWrites(false);
}
if ($caught) {
throw $caught;
} else {
return $file->getPHID();
}
} else {
return null;
}
}
示例3: saveEvents
public function saveEvents()
{
if (!$this->isActive()) {
return;
}
$events = $this->events;
if (!$events) {
return;
}
if ($this->sampleRate === null) {
throw new PhutilInvalidStateException('setSampleRate');
}
$this->addServiceEvents();
// Don't sample any of this stuff.
$this->pauseMultimeter();
$use_scope = AphrontWriteGuard::isGuardActive();
if ($use_scope) {
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
} else {
AphrontWriteGuard::allowDangerousUnguardedWrites(true);
}
$caught = null;
try {
$this->writeEvents();
} catch (Exception $ex) {
$caught = $ex;
}
if ($use_scope) {
unset($unguarded);
} else {
AphrontWriteGuard::allowDangerousUnguardedWrites(false);
}
$this->unpauseMultimeter();
if ($caught) {
throw $caught;
}
}
示例4: handleEvent
public function handleEvent(PhutilEvent $event)
{
if (AphrontWriteGuard::isGuardActive()) {
AphrontWriteGuard::getInstance()->disposeAbruptly();
}
}