コード例 #1
0
 private static function stopProfiler()
 {
     $data = xhprof_disable();
     $data = @json_encode($data);
     self::$profilerRunning = false;
     // 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('PhabricatorFile', '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;
     }
     self::$profileFilePHID = $file->getPHID();
 }