DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-29 03:45:32 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group console
|
|
|
|
*/
|
|
|
|
final class DarkConsoleDataController extends PhabricatorController {
|
|
|
|
|
|
|
|
private $key;
|
|
|
|
|
2013-09-05 20:16:32 +02:00
|
|
|
public function shouldRequireLogin() {
|
|
|
|
return !PhabricatorEnv::getEnvConfig('darkconsole.always-on');
|
|
|
|
}
|
|
|
|
|
2013-10-04 04:05:47 +02:00
|
|
|
public function shouldRequireEnabledUser() {
|
|
|
|
return !PhabricatorEnv::getEnvConfig('darkconsole.always-on');
|
|
|
|
}
|
|
|
|
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-29 03:45:32 +01:00
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->key = $data['key'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$cache = new PhabricatorKeyValueDatabaseCache();
|
|
|
|
$cache = new PhutilKeyValueCacheProfiler($cache);
|
|
|
|
$cache->setProfiler(PhutilServiceProfiler::getInstance());
|
|
|
|
|
|
|
|
$result = $cache->getKey('darkconsole:'.$this->key);
|
|
|
|
if (!$result) {
|
|
|
|
return new Aphront400Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = json_decode($result, true);
|
|
|
|
|
|
|
|
if (!is_array($result)) {
|
|
|
|
return new Aphront400Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result['vers'] != DarkConsoleCore::STORAGE_VERSION) {
|
|
|
|
return new Aphront400Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result['user'] != $user->getPHID()) {
|
|
|
|
return new Aphront400Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$output = array();
|
|
|
|
$output['tabs'] = $result['tabs'];
|
|
|
|
$output['panel'] = array();
|
|
|
|
|
|
|
|
foreach ($result['data'] as $class => $data) {
|
|
|
|
try {
|
|
|
|
$obj = newv($class, array());
|
|
|
|
$obj->setData($data);
|
|
|
|
$obj->setRequest($request);
|
|
|
|
|
|
|
|
$panel = $obj->renderPanel();
|
|
|
|
|
2014-01-23 23:01:35 +01:00
|
|
|
// Because cookie names can now be prefixed, wipe out any cookie value
|
|
|
|
// with the session cookie name anywhere in its name.
|
|
|
|
$pattern = '('.preg_quote(PhabricatorCookies::COOKIE_SESSION).')';
|
|
|
|
foreach ($_COOKIE as $cookie_name => $cookie_value) {
|
|
|
|
if (preg_match($pattern, $cookie_name)) {
|
|
|
|
$panel = PhutilSafeHTML::applyFunction(
|
|
|
|
'str_replace',
|
|
|
|
$cookie_value,
|
|
|
|
'(session-key)',
|
|
|
|
$panel);
|
|
|
|
}
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-29 03:45:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$output['panel'][$class] = $panel;
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
$output['panel'][$class] = 'error';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return id(new AphrontAjaxResponse())->setContent($output);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|