if ($access_log) { $access_log->write(); } if ($original_exception) { $ex = new PhutilAggregateException("Multiple exceptions during processing and rendering.", array($original_exception, $ex)); } phabricator_fatal('[Rendering Exception] ' . $ex->getMessage()); } $write_guard->dispose(); // TODO: Share the $sink->writeResponse() pathway here? $sink = new AphrontPHPHTTPSink(); $sink->writeHTTPStatus($response->getHTTPResponseCode()); $headers = $response->getCacheHeaders(); $headers = array_merge($headers, $response->getHeaders()); $sink->writeHeaders($headers); $sink->writeData($response_string); if ($access_log) { $access_log->setData(array('c' => $response->getHTTPResponseCode(), 'T' => (int) (1000000 * (microtime(true) - $__start__)))); $access_log->write(); } if (DarkConsoleXHProfPluginAPI::isProfilerRequested()) { $profile = DarkConsoleXHProfPluginAPI::stopProfiler(); $profile_sample = id(new PhabricatorXHProfSample())->setFilePHID($profile); if (empty($_REQUEST['__profile__'])) { $sample_rate = PhabricatorEnv::getEnvConfig('debug.profile-rate'); } else { $sample_rate = 0; } $profile_sample->setSampleRate($sample_rate); if ($access_log) { $profile_sample->setUsTotal($access_log->getData('T'))->setHostname($access_log->getData('h'))->setRequestPath($access_log->getData('U'))->setController($access_log->getData('C'))->setUserPHID($request->getUser()->getPHID());
$write_guard->dispose(); // TODO: Share the $sink->writeResponse() pathway here? $sink = new AphrontPHPHTTPSink(); $sink->writeHTTPStatus($response->getHTTPResponseCode()); $headers = $response->getCacheHeaders(); $headers = array_merge($headers, $response->getHeaders()); $sink->writeHeaders($headers); // TODO: This shouldn't be possible in a production-configured environment. if (DarkConsoleXHProfPluginAPI::isProfilerRequested() && DarkConsoleXHProfPluginAPI::isProfilerRequested() === 'all') { $profile = DarkConsoleXHProfPluginAPI::stopProfiler(); $profile = '<div style="text-align: center; background: #ff00ff; padding: 1em; font-size: 24px; font-weight: bold;">' . '<a href="/xhprof/profile/' . $profile . '/">' . '>>> View Profile <<<' . '</a>' . '</div>'; if (strpos($response_string, '<body>') !== false) { $response_string = str_replace('<body>', '<body>' . $profile, $response_string); } else { $sink->writeData($profile); } } $sink->writeData($response_string); if ($access_log) { $access_log->setData(array('c' => $response->getHTTPResponseCode(), 'T' => (int) (1000000 * (microtime(true) - $__start__)))); $access_log->write(); } /** * @group aphront */ function setup_aphront_basics() { $aphront_root = dirname(dirname(__FILE__)); $libraries_root = dirname($aphront_root); $root = null;