mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-01 11:12:42 +01:00
943c62d1e9
Summary: Ref T1191. - Adds definitions for missing keys and keys with wrong uniqueness. Generally, I defined these before fixing the key query to actually pull all keys and support uniqueness. - Moves "key uniqueness" to note severity; this is fixable (probably?) and there are no remaining issues. - Moves "Missing Key" to note severity; missing keys are fixable and all remaining missing keys are really missing (either missing edge keys, or missing PHID keys): {F210089} - Moves "Surplus Key" to note seveirty; surplus keys are fixable all remaining surplus keys are really surplus (duplicate key in Harbormaster, key on unused column in Worker): {F210090} Test Plan: - Vetted missing/surplus/unique messages. - 146 issues remaining. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T1191 Differential Revision: https://secure.phabricator.com/D10590
176 lines
4.5 KiB
PHP
176 lines
4.5 KiB
PHP
<?php
|
|
|
|
final class PhabricatorConfigDatabaseIssueController
|
|
extends PhabricatorConfigDatabaseController {
|
|
|
|
public function processRequest() {
|
|
$request = $this->getRequest();
|
|
$viewer = $request->getUser();
|
|
|
|
$query = $this->buildSchemaQuery();
|
|
|
|
$actual = $query->loadActualSchema();
|
|
$expect = $query->loadExpectedSchema();
|
|
$comp = $query->buildComparisonSchema($expect, $actual);
|
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
$crumbs->addTextCrumb(pht('Database Issues'));
|
|
|
|
// Collect all open issues.
|
|
$issues = array();
|
|
foreach ($comp->getDatabases() as $database_name => $database) {
|
|
foreach ($database->getLocalIssues() as $issue) {
|
|
$issues[] = array(
|
|
$database_name,
|
|
null,
|
|
null,
|
|
null,
|
|
$issue);
|
|
}
|
|
foreach ($database->getTables() as $table_name => $table) {
|
|
foreach ($table->getLocalIssues() as $issue) {
|
|
$issues[] = array(
|
|
$database_name,
|
|
$table_name,
|
|
null,
|
|
null,
|
|
$issue);
|
|
}
|
|
foreach ($table->getColumns() as $column_name => $column) {
|
|
foreach ($column->getLocalIssues() as $issue) {
|
|
$issues[] = array(
|
|
$database_name,
|
|
$table_name,
|
|
'column',
|
|
$column_name,
|
|
$issue);
|
|
}
|
|
}
|
|
foreach ($table->getKeys() as $key_name => $key) {
|
|
foreach ($key->getLocalIssues() as $issue) {
|
|
$issues[] = array(
|
|
$database_name,
|
|
$table_name,
|
|
'key',
|
|
$key_name,
|
|
$issue);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// Sort all open issues so that the most severe issues appear first.
|
|
$order = array();
|
|
$counts = array();
|
|
foreach ($issues as $key => $issue) {
|
|
$const = $issue[4];
|
|
$status = PhabricatorConfigStorageSchema::getIssueStatus($const);
|
|
$severity = PhabricatorConfigStorageSchema::getStatusSeverity($status);
|
|
$order[$key] = sprintf(
|
|
'~%d~%s%s%s',
|
|
9 - $severity,
|
|
$issue[0],
|
|
$issue[1],
|
|
$issue[3]);
|
|
|
|
if (empty($counts[$status])) {
|
|
$counts[$status] = 0;
|
|
}
|
|
|
|
$counts[$status]++;
|
|
}
|
|
asort($order);
|
|
$issues = array_select_keys($issues, array_keys($order));
|
|
|
|
|
|
// Render the issues.
|
|
$rows = array();
|
|
foreach ($issues as $issue) {
|
|
$const = $issue[4];
|
|
|
|
$database_link = phutil_tag(
|
|
'a',
|
|
array(
|
|
'href' => $this->getApplicationURI('/database/'.$issue[0].'/'),
|
|
),
|
|
$issue[0]);
|
|
|
|
$rows[] = array(
|
|
$this->renderIcon(
|
|
PhabricatorConfigStorageSchema::getIssueStatus($const)),
|
|
$database_link,
|
|
$issue[1],
|
|
$issue[2],
|
|
$issue[3],
|
|
PhabricatorConfigStorageSchema::getIssueDescription($const),
|
|
);
|
|
}
|
|
|
|
$table = id(new AphrontTableView($rows))
|
|
->setHeaders(
|
|
array(
|
|
null,
|
|
pht('Database'),
|
|
pht('Table'),
|
|
pht('Type'),
|
|
pht('Column/Key'),
|
|
pht('Issue'),
|
|
))
|
|
->setColumnClasses(
|
|
array(
|
|
null,
|
|
null,
|
|
null,
|
|
null,
|
|
null,
|
|
'wide',
|
|
));
|
|
|
|
$errors = array();
|
|
|
|
$errors[] = pht(
|
|
'IMPORTANT: This feature is in development and the information below '.
|
|
'is not accurate! Ignore it for now. See T1191.');
|
|
|
|
if (isset($counts[PhabricatorConfigStorageSchema::STATUS_FAIL])) {
|
|
$errors[] = pht(
|
|
'Detected %s serious issue(s) with the schemata.',
|
|
new PhutilNumber($counts[PhabricatorConfigStorageSchema::STATUS_FAIL]));
|
|
}
|
|
|
|
if (isset($counts[PhabricatorConfigStorageSchema::STATUS_WARN])) {
|
|
$errors[] = pht(
|
|
'Detected %s warning(s) with the schemata.',
|
|
new PhutilNumber($counts[PhabricatorConfigStorageSchema::STATUS_WARN]));
|
|
}
|
|
|
|
if (isset($counts[PhabricatorConfigStorageSchema::STATUS_NOTE])) {
|
|
$errors[] = pht(
|
|
'Detected %s minor issue(s) with the scheamata.',
|
|
new PhutilNumber($counts[PhabricatorConfigStorageSchema::STATUS_NOTE]));
|
|
}
|
|
|
|
$title = pht('Database Issues');
|
|
|
|
$table_box = id(new PHUIObjectBoxView())
|
|
->setHeaderText($title)
|
|
->setFormErrors($errors)
|
|
->appendChild($table);
|
|
|
|
$nav = $this->buildSideNavView();
|
|
$nav->selectFilter('dbissue/');
|
|
$nav->appendChild(
|
|
array(
|
|
$crumbs,
|
|
$table_box,
|
|
));
|
|
|
|
return $this->buildApplicationPage(
|
|
$nav,
|
|
array(
|
|
'title' => $title,
|
|
));
|
|
}
|
|
|
|
}
|