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;
     }
 }
 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
0
 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;
     }
 }
 public function handleEvent(PhutilEvent $event)
 {
     if (AphrontWriteGuard::isGuardActive()) {
         AphrontWriteGuard::getInstance()->disposeAbruptly();
     }
 }