Detect and raise setup warnings from within Phabricator
Summary: This is basicaly a light version of D4286. The major problem with D4286 is that it's a huge leap and completely replaces the setup process in one step. Instead, I want to do this: - Add the post-setup warnings (yellow bar with "6 unresolved warnings..."). - Copy all setup checks into post-setup warnings (so every check has an old-style check and a new-style check). - Run that for a little bit and make sure it's stable. - Implement fatal post-setup checks (the red screen, vs the yellow bar). - Run that for a little bit. - Nuke setup mode and delete all the old checks. This should give us a bunch of very gradual steps toward the brave new world of simpler setup. Test Plan: - Faked APC setup failures, saw warnings raise. - Verified that this runs after restart (get + set). - Verified that this costs us only one cache hit after first-run (get only). Reviewers: btrahan, codeblock, vrana, chad Reviewed By: codeblock CC: aran Maniphest Tasks: T2228 Differential Revision: https://secure.phabricator.com/D4295
This commit is contained in:
79
src/applications/config/check/PhabricatorSetupCheck.php
Normal file
79
src/applications/config/check/PhabricatorSetupCheck.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
abstract class PhabricatorSetupCheck {
|
||||
|
||||
private $issues;
|
||||
|
||||
abstract protected function executeChecks();
|
||||
|
||||
final protected function newIssue($key) {
|
||||
$issue = id(new PhabricatorSetupIssue())
|
||||
->setIssueKey($key);
|
||||
|
||||
$this->issues[$key] = $issue;
|
||||
|
||||
return $issue;
|
||||
}
|
||||
|
||||
final public function getIssues() {
|
||||
return $this->issues;
|
||||
}
|
||||
|
||||
final public function runSetupChecks() {
|
||||
$this->issues = array();
|
||||
$this->executeChecks();
|
||||
}
|
||||
|
||||
final public static function getOpenSetupIssueCount() {
|
||||
$cache = PhabricatorCaches::getSetupCache();
|
||||
return $cache->getKey('phabricator.setup.issues');
|
||||
}
|
||||
|
||||
final public static function setOpenSetupIssueCount($count) {
|
||||
$cache = PhabricatorCaches::getSetupCache();
|
||||
$cache->setKey('phabricator.setup.issues', $count);
|
||||
}
|
||||
|
||||
final public static function willProcessRequest() {
|
||||
$issue_count = self::getOpenSetupIssueCount();
|
||||
if ($issue_count !== null) {
|
||||
// We've already run setup checks, didn't hit any fatals, and then set
|
||||
// an issue count. This means we're good and don't need to do any extra
|
||||
// work.
|
||||
return null;
|
||||
}
|
||||
|
||||
$issues = self::runAllChecks();
|
||||
|
||||
self::setOpenSetupIssueCount(count($issues));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
final public static function runAllChecks() {
|
||||
$symbols = id(new PhutilSymbolLoader())
|
||||
->setAncestorClass('PhabricatorSetupCheck')
|
||||
->setConcreteOnly(true)
|
||||
->selectAndLoadSymbols();
|
||||
|
||||
$checks = array();
|
||||
foreach ($symbols as $symbol) {
|
||||
$checks[] = newv($symbol['name'], array());
|
||||
}
|
||||
|
||||
$issues = array();
|
||||
foreach ($checks as $check) {
|
||||
$check->runSetupChecks();
|
||||
foreach ($check->getIssues() as $key => $issue) {
|
||||
if (isset($issues[$key])) {
|
||||
throw new Exception(
|
||||
"Two setup checks raised an issue with key '{$key}'!");
|
||||
}
|
||||
$issues[$key] = $issue;
|
||||
}
|
||||
}
|
||||
|
||||
return $issues;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user