本文整理汇总了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();
}
}