mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10:55 +01:00
Add a very basic cache status page
Summary: Ref T5501. This is just getting version detection and availability right, probably. Eventually, this will get lifted up a bit and "$remedy" will turn into setup issues (or maybe one setup issue saying "your cache setup is messed up, click here to understand why"). Test Plan: {F362935} I intend to shove these up to production one-by-one since production is APC and local is Opcache + APCu. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5501 Differential Revision: https://secure.phabricator.com/D12314
This commit is contained in:
parent
f4baa3bd15
commit
c6b05dbb63
4 changed files with 177 additions and 0 deletions
|
@ -1537,6 +1537,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorConduitTokensSettingsPanel' => 'applications/conduit/settings/PhabricatorConduitTokensSettingsPanel.php',
|
||||
'PhabricatorConfigAllController' => 'applications/config/controller/PhabricatorConfigAllController.php',
|
||||
'PhabricatorConfigApplication' => 'applications/config/application/PhabricatorConfigApplication.php',
|
||||
'PhabricatorConfigCacheController' => 'applications/config/controller/PhabricatorConfigCacheController.php',
|
||||
'PhabricatorConfigColumnSchema' => 'applications/config/schema/PhabricatorConfigColumnSchema.php',
|
||||
'PhabricatorConfigConfigPHIDType' => 'applications/config/phid/PhabricatorConfigConfigPHIDType.php',
|
||||
'PhabricatorConfigController' => 'applications/config/controller/PhabricatorConfigController.php',
|
||||
|
@ -4841,6 +4842,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorConduitTokensSettingsPanel' => 'PhabricatorSettingsPanel',
|
||||
'PhabricatorConfigAllController' => 'PhabricatorConfigController',
|
||||
'PhabricatorConfigApplication' => 'PhabricatorApplication',
|
||||
'PhabricatorConfigCacheController' => 'PhabricatorConfigController',
|
||||
'PhabricatorConfigColumnSchema' => 'PhabricatorConfigStorageSchema',
|
||||
'PhabricatorConfigConfigPHIDType' => 'PhabricatorPHIDType',
|
||||
'PhabricatorConfigController' => 'PhabricatorController',
|
||||
|
|
|
@ -55,6 +55,7 @@ final class PhabricatorConfigApplication extends PhabricatorApplication {
|
|||
'' => 'PhabricatorConfigIssueListController',
|
||||
'(?P<key>[^/]+)/' => 'PhabricatorConfigIssueViewController',
|
||||
),
|
||||
'cache/' => 'PhabricatorConfigCacheController',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,172 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorConfigCacheController
|
||||
extends PhabricatorConfigController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$nav = $this->buildSideNavView();
|
||||
$nav->selectFilter('cache/');
|
||||
|
||||
$title = pht('Cache Status');
|
||||
|
||||
$crumbs = $this
|
||||
->buildApplicationCrumbs()
|
||||
->addTextCrumb(pht('Cache Status'));
|
||||
|
||||
$nav->setCrumbs($crumbs);
|
||||
|
||||
list($remedy, $properties) = $this->getProperties();
|
||||
|
||||
$property_list = id(new PHUIPropertyListView());
|
||||
foreach ($properties as $property) {
|
||||
list($name, $value) = $property;
|
||||
$property_list->addProperty($name, $value);
|
||||
}
|
||||
|
||||
|
||||
$box = id(new PHUIObjectBoxView())
|
||||
->setFormErrors($remedy)
|
||||
->setHeaderText(pht('Cache'))
|
||||
->addPropertyList($property_list);
|
||||
|
||||
$nav->appendChild($box);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
$nav,
|
||||
array(
|
||||
'title' => $title,
|
||||
));
|
||||
}
|
||||
|
||||
private function getProperties() {
|
||||
$remedy = array();
|
||||
|
||||
$properties = array();
|
||||
|
||||
// NOTE: If APCu is installed, it reports that APC is installed.
|
||||
if (extension_loaded('apc') && !extension_loaded('apcu')) {
|
||||
$cache_installed = true;
|
||||
$cache_name = pht('APC');
|
||||
$cache_version = phpversion('apc');
|
||||
$cache_enabled = (bool)ini_get('apc.enabled');
|
||||
if (!$cache_enabled) {
|
||||
$remedy[] = pht('Enable APC');
|
||||
}
|
||||
$datacache_installed = true;
|
||||
$datacache_name = pht('APC User Cache');
|
||||
$datacache_version = phpversion('apc');
|
||||
$datacache_enabled = true;
|
||||
} else {
|
||||
if (extension_loaded('Zend OPcache')) {
|
||||
$cache_installed = true;
|
||||
$cache_name = pht('Zend Opcache');
|
||||
$cache_enabled = (bool)ini_get('opcache.enable');
|
||||
$cache_version = phpversion('Zend OPcache');
|
||||
if (!$cache_enabled) {
|
||||
$remedy[] = pht('Enable Opcache.');
|
||||
}
|
||||
} else {
|
||||
if (version_compare(phpversion(), '5.5', '>=')) {
|
||||
$remedy[] = pht('Install OPcache.');
|
||||
} else {
|
||||
$remedy[] = pht('Install APC.');
|
||||
}
|
||||
|
||||
$cache_installed = false;
|
||||
$cache_name = pht('None');
|
||||
$cache_enabled = false;
|
||||
$cache_version = null;
|
||||
}
|
||||
|
||||
if (extension_loaded('apcu')) {
|
||||
$datacache_installed = true;
|
||||
$datacache_name = pht('APCu');
|
||||
$datacache_version = phpversion('apcu');
|
||||
$datacache_enabled = (bool)ini_get('apc.enabled');
|
||||
} else {
|
||||
if (version_compare(phpversion(), '5.5', '>=')) {
|
||||
$remedy[] = pht('Install APCu.');
|
||||
} else {
|
||||
// We already suggested installing APC above.
|
||||
}
|
||||
|
||||
$datacache_installed = false;
|
||||
$datacache_name = pht('None');
|
||||
$datacache_version = null;
|
||||
$datacache_enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($cache_installed) {
|
||||
$cache_property = $this->renderYes($cache_name);
|
||||
} else {
|
||||
$cache_property = $this->renderNo($cache_name);
|
||||
}
|
||||
|
||||
if ($cache_enabled) {
|
||||
$cache_enabled_property = $this->renderYes(pht('Enabled'));
|
||||
} else {
|
||||
$cache_enabled_property = $this->renderNo(pht('Not Enabled'));
|
||||
}
|
||||
|
||||
$properties[] = array(pht('Opcode Cache'), $cache_property);
|
||||
$properties[] = array(pht('Enabled'), $cache_enabled_property);
|
||||
if ($cache_version) {
|
||||
$properties[] = array(
|
||||
pht('Version'),
|
||||
$this->renderInfo($cache_version),
|
||||
);
|
||||
}
|
||||
|
||||
if ($datacache_installed) {
|
||||
$datacache_property = $this->renderYes($datacache_name);
|
||||
} else {
|
||||
$datacache_property = $this->renderNo($datacache_name);
|
||||
}
|
||||
|
||||
if ($datacache_enabled) {
|
||||
$datacache_enabled_property = $this->renderYes(pht('Enabled'));
|
||||
} else {
|
||||
$datacache_enabled_property = $this->renderNo(pht('Not Enabled'));
|
||||
}
|
||||
|
||||
$properties[] = array(pht('Data Cache'), $datacache_property);
|
||||
$properties[] = array(pht('Enabled'), $datacache_enabled_property);
|
||||
if ($datacache_version) {
|
||||
$properties[] = array(
|
||||
pht('Version'),
|
||||
$this->renderInfo($datacache_version),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return array($remedy, $properties);
|
||||
}
|
||||
|
||||
private function renderYes($info) {
|
||||
return array(
|
||||
id(new PHUIIconView())->setIconFont('fa-check', 'green'),
|
||||
' ',
|
||||
$info,
|
||||
);
|
||||
}
|
||||
|
||||
private function renderNo($info) {
|
||||
return array(
|
||||
id(new PHUIIconView())->setIconFont('fa-times-circle', 'red'),
|
||||
' ',
|
||||
$info,
|
||||
);
|
||||
}
|
||||
|
||||
private function renderInfo($info) {
|
||||
return array(
|
||||
id(new PHUIIconView())->setIconFont('fa-info-circle', 'grey'),
|
||||
' ',
|
||||
$info,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -20,6 +20,8 @@ abstract class PhabricatorConfigController extends PhabricatorController {
|
|||
$nav->addLabel(pht('Database'));
|
||||
$nav->addFilter('database/', pht('Database Status'));
|
||||
$nav->addFilter('dbissue/', pht('Database Issues'));
|
||||
$nav->addLabel(pht('Cache'));
|
||||
$nav->addFilter('cache/', pht('Cache Status'));
|
||||
$nav->addLabel(pht('Welcome'));
|
||||
$nav->addFilter('welcome/', pht('Welcome Screen'));
|
||||
|
||||
|
|
Loading…
Reference in a new issue