Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/aphront/console/plugin/xhprof/DarkConsoleXHProfPlugin.php b/src/aphront/console/plugin/xhprof/DarkConsoleXHProfPlugin.php
index bf8c337d78..c12181493b 100755
--- a/src/aphront/console/plugin/xhprof/DarkConsoleXHProfPlugin.php
+++ b/src/aphront/console/plugin/xhprof/DarkConsoleXHProfPlugin.php
@@ -1,135 +1,135 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class DarkConsoleXHProfPlugin extends DarkConsolePlugin {
protected $xhprofID;
public function getName() {
$run = $this->getData();
if ($run) {
return '<span style="color: #ff00ff;">&bull;</span> XHProf';
}
return 'XHProf';
}
public function getDescription() {
return 'Provides detailed PHP profiling information through XHProf.';
}
public function generateData() {
return $this->xhprofID;
}
public function getXHProfRunID() {
return $this->xhprofID;
}
public function render() {
if (!DarkConsoleXHProfPluginAPI::isProfilerAvailable()) {
return
'<p>The "xhprof" PHP extension is not available. Install xhprof '.
'to enable the XHProf plugin.';
}
-
+
$run = $this->getXHProfRunID();
if ($run) {
return '<a href="/xhprof/profile/'.$run.'/">View Run</a>';
} else {
$hidden = array();
$data = array('__profile__' => 'page') + $_GET;
-
+
foreach ($data as $k => $v) {
$hidden[] = phutil_render_tag(
'input',
array(
'type' => 'hidden',
'name' => $k,
'value' => $v,
));
}
$hidden = implode("\n", $hidden);
-
-
+
+
return
'<form method="get">'.
$hidden.
'<button>Enable XHProf</button>'.
'</form>';
}
}
public function willShutdown() {
if (isset($_REQUEST['__profile__']) &&
$_REQUEST['__profile__'] != 'all') {
$this->xhprofID = DarkConsoleXHProfPluginAPI::stopProfiler();
}
}
}
/*
public function render() {
$run = $this->getData();
if ($run) {
$uri = 'http://www.intern.facebook.com/intern/phprof/?run='.$run;
return
<x:frag>
<h1>XHProf Results</h1>
<div class="XHProfPlugin">
<a href={$uri} target="_blank" class="XHProfPlugin">Permalink</a>
<iframe src={$uri} width="100%" height="600" />
</div>
</x:frag>;
}
$uri = URI::getRequestURI();
return
<x:frag>
<h1>XHProf</h1>
<form action={$uri} method="get" class="EnableFeature">
<fieldset>
<legend>Enable Profiling</legend>
<p>Profiling was not enabled for this request. Click the button
below to rerun the request with profiling enabled.</p>
<button type="submit" name="_profile_" value="all"
style="margin: 2px 1em; width: 75%;">
Profile Page (With Includes)
</button>
<button type="submit" name="_profile_" value="exec"
style="margin: 2px 1em; width: 75%;">
Profile Page (No Includes)
</button>
</fieldset>
</form>
</x:frag>;
}
public function didShutdown() {
if ($this->xhprofData) {
require_module_lazy('profiling/phprof');
$this->xhprofID = phprof_save_run($this->xhprofData);
}
}
}
-*/
\ No newline at end of file
+*/
diff --git a/src/aphront/console/plugin/xhprof/__init__.php b/src/aphront/console/plugin/xhprof/__init__.php
index 147b5ce3ad..32fd5d88d9 100644
--- a/src/aphront/console/plugin/xhprof/__init__.php
+++ b/src/aphront/console/plugin/xhprof/__init__.php
@@ -1,13 +1,15 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'aphront/console/plugin/base');
phutil_require_module('phabricator', 'aphront/console/plugin/xhprof/api');
+phutil_require_module('phutil', 'markup');
+
phutil_require_source('DarkConsoleXHProfPlugin.php');
diff --git a/src/applications/people/controller/settings/PhabricatorUserSettingsController.php b/src/applications/people/controller/settings/PhabricatorUserSettingsController.php
index 40ffbc38d8..6b013f056f 100644
--- a/src/applications/people/controller/settings/PhabricatorUserSettingsController.php
+++ b/src/applications/people/controller/settings/PhabricatorUserSettingsController.php
@@ -1,235 +1,235 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class PhabricatorUserSettingsController extends PhabricatorPeopleController {
private $page;
public function willProcessRequest(array $data) {
$this->page = idx($data, 'page');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$pages = array(
'account' => 'Account',
// 'password' => 'Password',
// 'facebook' => 'Facebook Account',
'arcanist' => 'Arcanist Certificate',
);
if (empty($pages[$this->page])) {
$this->page = key($pages);
}
if ($request->isFormPost()) {
switch ($this->page) {
case 'arcanist':
if (!$request->isDialogFormPost()) {
$dialog = new AphrontDialogView();
$dialog->setUser($user);
$dialog->setTitle('Really regenerate session?');
$dialog->setSubmitURI('/settings/page/arcanist/');
$dialog->addSubmitButton('Regenerate');
$dialog->addCancelbutton('/settings/page/arcanist/');
$dialog->appendChild(
'<p>Really destroy the old certificate? Any established '.
'sessions will be terminated.');
return id(new AphrontDialogResponse())
->setDialog($dialog);
}
$conn = $user->establishConnection('w');
queryfx(
$conn,
'DELETE FROM %T WHERE userPHID = %s AND type LIKE %>',
PhabricatorUser::SESSION_TABLE,
$user->getPHID(),
'conduit');
// This implicitly regenerates the certificate.
$user->setConduitCertificate(null);
$user->save();
return id(new AphrontRedirectResponse())
->setURI('/settings/page/arcanist/?regenerated=true');
case 'account':
if (!empty($_FILES['profile'])) {
$file = PhabricatorFile::newFromPHPUpload($_FILES['profile']);
$user->setProfileImagePHID($file->getPHID());
}
-
+
$user->save();
return id(new AphrontRedirectResponse())
->setURI('/settings/page/account/');
}
}
switch ($this->page) {
case 'arcanist':
$content = $this->renderArcanistCertificateForm();
break;
case 'account':
$content = $this->renderAccountForm();
break;
default:
$content = 'derp derp';
break;
}
$sidenav = new AphrontSideNavView();
foreach ($pages as $page => $name) {
$sidenav->addNavItem(
phutil_render_tag(
'a',
array(
'href' => '/settings/page/'.$page.'/',
'class' => ($page == $this->page)
? 'aphront-side-nav-selected'
: null,
),
phutil_escape_html($name)));
}
$sidenav->appendChild($content);
return $this->buildStandardPageResponse(
$sidenav,
array(
'title' => 'Account Settings',
));
}
private function renderArcanistCertificateForm() {
$request = $this->getRequest();
$user = $request->getUser();
if ($request->getStr('regenerated')) {
$notice = new AphrontErrorView();
$notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
$notice->setTitle('Certificate Regenerated');
$notice->appendChild(
'<p>Your old certificate has been destroyed and you have been issued '.
'a new certificate. Sessions established under the old certificate '.
'are no longer valid.</p>');
$notice = $notice->render();
} else {
$notice = null;
}
$host = PhabricatorEnv::getEnvConfig('phabricator.conduit-uri');
$cert_form = new AphrontFormView();
$cert_form
->setUser($user)
->appendChild(
'<p class="aphront-form-instructions">Copy and paste this certificate '.
'into your <tt>~/.arcrc</tt> in the "hosts" section to enable '.
'Arcanist to authenticate against this host.</p>')
->appendChild(
id(new AphrontFormTextAreaControl())
->setLabel('Certificate')
->setHeight(AphrontFormTextAreaControl::HEIGHT_SHORT)
->setValue($user->getConduitCertificate()));
$cert = new AphrontPanelView();
$cert->setHeader('Arcanist Certificate');
$cert->appendChild($cert_form);
$cert->setWidth(AphrontPanelView::WIDTH_FORM);
$regen_form = new AphrontFormView();
$regen_form
->setUser($user)
->setWorkflow(true)
->setAction('/settings/page/arcanist/')
->appendChild(
'<p class="aphront-form-instructions">You can regenerate this '.
'certificate, which will invalidate the old certificate and create '.
'a new one.</p>')
->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Regenerate Certificate'));
$regen = new AphrontPanelView();
$regen->setHeader('Regenerate Certificate');
$regen->appendChild($regen_form);
$regen->setWidth(AphrontPanelView::WIDTH_FORM);
return $notice.$cert->render().$regen->render();
}
-
+
private function renderAccountForm() {
$request = $this->getRequest();
$user = $request->getUser();
-
+
$img_src = PhabricatorFileURI::getViewURIForPHID(
$user->getProfileImagePHID());
-
+
$form = new AphrontFormView();
$form
->setUser($user)
->setEncType('multipart/form-data')
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Username')
->setValue($user->getUsername()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Email')
->setValue($user->getEmail()))
->appendChild(
id(new AphrontFormTextControl())
->setLabel('Real Name')
->setValue($user->getRealName()))
->appendChild(
id(new AphrontFormMarkupControl())
->setValue('<hr />'))
->appendChild(
id(new AphrontFormMarkupControl())
->setLabel('Profile Image')
->setValue(
phutil_render_tag(
'img',
array(
'src' => $img_src,
))))
->appendChild(
id(new AphrontFormFileControl())
->setLabel('Change Image')
->setName('profile')
->setCaption('Upload a 50x50px image.'))
->appendChild(
id(new AphrontFormMarkupControl())
->setValue('<hr />'))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Save'));
-
+
$panel = new AphrontPanelView();
$panel->setHeader('Profile Settings');
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$panel->appendChild($form);
-
+
return $panel->render();
}
}
diff --git a/src/applications/people/controller/settings/__init__.php b/src/applications/people/controller/settings/__init__.php
index b6600f1bcd..7a772e97cd 100644
--- a/src/applications/people/controller/settings/__init__.php
+++ b/src/applications/people/controller/settings/__init__.php
@@ -1,27 +1,29 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'aphront/response/dialog');
phutil_require_module('phabricator', 'aphront/response/redirect');
+phutil_require_module('phabricator', 'applications/files/storage/file');
+phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phabricator', 'applications/people/controller/base');
phutil_require_module('phabricator', 'applications/people/storage/user');
phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phabricator', 'storage/queryfx');
phutil_require_module('phabricator', 'view/dialog');
phutil_require_module('phabricator', 'view/form/base');
phutil_require_module('phabricator', 'view/form/control/submit');
phutil_require_module('phabricator', 'view/form/control/textarea');
phutil_require_module('phabricator', 'view/form/error');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phabricator', 'view/layout/sidenav');
phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorUserSettingsController.php');
diff --git a/src/applications/xhprof/view/symbol/PhabricatorXHProfProfileSymbolView.php b/src/applications/xhprof/view/symbol/PhabricatorXHProfProfileSymbolView.php
index bfdaf3b502..9561dbece7 100644
--- a/src/applications/xhprof/view/symbol/PhabricatorXHProfProfileSymbolView.php
+++ b/src/applications/xhprof/view/symbol/PhabricatorXHProfProfileSymbolView.php
@@ -1,171 +1,171 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class PhabricatorXHProfProfileSymbolView extends AphrontView {
private $profileData;
private $baseURI;
private $symbol;
public function setProfileData(array $data) {
$this->profileData = $data;
return $this;
}
public function setBaseURI($uri) {
$this->baseURI = $uri;
return $this;
}
public function setSymbol($symbol) {
$this->symbol = $symbol;
return $this;
}
public function render() {
DarkConsoleXHProfPluginAPI::includeXHProfLib();
$data = $this->profileData;
$GLOBALS['display_calls'] = true;
$totals = array();
$flat = xhprof_compute_flat_info($data, $totals);
unset($GLOBALS['display_calls']);
$symbol = $this->symbol;
$children = array();
$parents = array();
foreach ($this->profileData as $key => $counters) {
if (strpos($key, '==>') !== false) {
list($parent, $child) = explode('==>', $key, 2);
} else {
continue;
}
if ($parent == $symbol) {
$children[$key] = $child;
} else if ($child == $symbol) {
$parents[$key] = $parent;
}
}
$base_uri = $this->baseURI;
$rows = array();
$rows[] = array(
'Metrics for this Call',
'',
'',
'',
);
$rows[] = array(
phutil_render_tag(
'a',
array(
'href' => $base_uri.'?symbol='.$symbol,
),
phutil_escape_html($symbol)),
$flat[$symbol]['ct'],
$flat[$symbol]['wt'],
'100%',
);
$rows[] = array(
'Parent Calls',
'',
'',
'',
);
foreach ($parents as $key => $name) {
$rows[] = array(
phutil_render_tag(
'a',
array(
'href' => $base_uri.'?symbol='.$name,
),
phutil_escape_html($name)),
$data[$key]['ct'],
$data[$key]['wt'],
'',
);
}
$rows[] = array(
'Child Calls',
'',
'',
'',
);
$child_rows = array();
foreach ($children as $key => $name) {
$child_rows[] = array(
$name,
$data[$key]['ct'],
$data[$key]['wt'],
$data[$key]['wt'] / $flat[$symbol]['wt'],
);
}
$child_rows = isort($child_rows, 2);
$child_rows = array_reverse($child_rows);
$rows = array_merge($rows, $this->formatRows($child_rows));
$table = new AphrontTableView($rows);
$table->setHeaders(
array(
'Symbol',
'Count',
'Wall Time',
'%',
));
$table->setColumnClasses(
array(
'wide pri',
'n',
'n',
'n',
));
$panel = new AphrontPanelView();
$panel->setHeader('XHProf Profile');
$panel->appendChild($table);
return $panel->render();
}
-
+
private function formatRows($rows) {
$base_uri = $this->baseURI;
-
+
$result = array();
foreach ($rows as $row) {
$result[] = array(
phutil_render_tag(
'a',
array(
'href' => $base_uri.'?symbol='.$row[0],
),
phutil_escape_html($row[0])),
number_format($row[1]),
number_format($row[2]).' us',
sprintf('%.1f%%', 100 * $row[3]),
);
}
return $result;
}
-
+
}
diff --git a/src/applications/xhprof/view/symbol/__init__.php b/src/applications/xhprof/view/symbol/__init__.php
index 01a23facf8..3ff4e39d21 100644
--- a/src/applications/xhprof/view/symbol/__init__.php
+++ b/src/applications/xhprof/view/symbol/__init__.php
@@ -1,17 +1,18 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'aphront/console/plugin/xhprof/api');
phutil_require_module('phabricator', 'view/base');
phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phutil', 'markup');
+phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorXHProfProfileSymbolView.php');

File Metadata

Mime Type
text/x-diff
Expires
Mon, Mar 16, 10:55 AM (3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
962623
Default Alt Text
(19 KB)

Event Timeline