private function printErrors(array $errors, $default_return) { if (!$errors) { return $default_return; } $console = PhutilConsole::getConsole(); $table = id(new PhutilConsoleTable())->addColumn('target', array('title' => pht('Target')))->addColumn('error', array('title' => pht('Error'))); $any_surplus = false; $all_surplus = true; $any_access = false; $all_access = true; foreach ($errors as $error) { $pieces = array_select_keys($error, array('database', 'table', 'name')); $pieces = array_filter($pieces); $target = implode('.', $pieces); $name = PhabricatorConfigStorageSchema::getIssueName($error['issue']); $issue = $error['issue']; if ($issue === PhabricatorConfigStorageSchema::ISSUE_SURPLUS) { $any_surplus = true; } else { $all_surplus = false; } if ($issue === PhabricatorConfigStorageSchema::ISSUE_ACCESSDENIED) { $any_access = true; } else { $all_access = false; } $table->addRow(array('target' => $target, 'error' => $name)); } $console->writeOut("\n"); $table->draw(); $console->writeOut("\n"); $message = array(); if ($all_surplus) { $message[] = pht('You have surplus schemata (extra tables or columns which Phabricator ' . 'does not expect). For information on resolving these ' . 'issues, see the "Surplus Schemata" section in the "Managing Storage ' . 'Adjustments" article in the documentation.'); } else { if ($all_access) { $message[] = pht('The user you are connecting to MySQL with does not have the correct ' . 'permissions, and can not access some databases or tables that it ' . 'needs to be able to access. GRANT the user additional permissions.'); } else { $message[] = pht('The schemata have errors (detailed above) which the adjustment ' . 'workflow can not fix.'); if ($any_access) { $message[] = pht('Some of these errors are caused by access control problems. ' . 'The user you are connecting with does not have permission to see ' . 'all of the database or tables that Phabricator uses. You need to ' . 'GRANT the user more permission, or use a different user.'); } if ($any_surplus) { $message[] = pht('Some of these errors are caused by surplus schemata (extra ' . 'tables or columns which Phabricator does not expect). These are ' . 'not serious. For information on resolving these issues, see the ' . '"Surplus Schemata" section in the "Managing Storage Adjustments" ' . 'article in the documentation.'); } $message[] = pht('If you are not developing Phabricator itself, report this issue to ' . 'the upstream.'); $message[] = pht('If you are developing Phabricator, these errors usually indicate ' . 'that your schema specifications do not agree with the schemata your ' . 'code actually builds.'); } } $message = implode("\n\n", $message); if ($all_surplus) { $console->writeOut("**<bg:yellow> %s </bg>**\n\n%s\n", pht('SURPLUS SCHEMATA'), phutil_console_wrap($message)); } else { if ($all_access) { $console->writeOut("**<bg:yellow> %s </bg>**\n\n%s\n", pht('ACCESS DENIED'), phutil_console_wrap($message)); } else { $console->writeOut("**<bg:red> %s </bg>**\n\n%s\n", pht('SCHEMATA ERRORS'), phutil_console_wrap($message)); } } return 2; }
private function buildProperties(array $properties, array $issues) { $view = id(new PHUIPropertyListView())->setUser($this->getRequest()->getUser()); foreach ($properties as $property) { list($key, $value) = $property; $view->addProperty($key, $value); } $status_view = new PHUIStatusListView(); if (!$issues) { $status_view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')->setTarget(pht('No Schema Issues'))); } else { foreach ($issues as $issue) { $note = PhabricatorConfigStorageSchema::getIssueDescription($issue); $status = PhabricatorConfigStorageSchema::getIssueStatus($issue); switch ($status) { case PhabricatorConfigStorageSchema::STATUS_WARN: $icon = PHUIStatusItemView::ICON_WARNING; $color = 'yellow'; break; case PhabricatorConfigStorageSchema::STATUS_FAIL: default: $icon = PHUIStatusItemView::ICON_REJECT; $color = 'red'; break; } $item = id(new PHUIStatusItemView())->setTarget(PhabricatorConfigStorageSchema::getIssueName($issue))->setIcon($icon, $color)->setNote($note); $status_view->addItem($item); } } $view->addProperty(pht('Schema Status'), $status_view); return phutil_tag_div('config-page-property', $view); }