Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / config / issue / PhabricatorSetupIssue.php
blobcadedfc7daddf098a89bc05c7cc7f4da6b68d5f0
1 <?php
3 final class PhabricatorSetupIssue extends Phobject {
5 private $issueKey;
6 private $name;
7 private $message;
8 private $isFatal;
9 private $summary;
10 private $shortName;
11 private $group;
12 private $databaseRef;
14 private $isIgnored = false;
15 private $phpExtensions = array();
16 private $phabricatorConfig = array();
17 private $relatedPhabricatorConfig = array();
18 private $phpConfig = array();
19 private $commands = array();
20 private $mysqlConfig = array();
21 private $originalPHPConfigValues = array();
22 private $links;
24 public static function newDatabaseConnectionIssue(
25 Exception $ex,
26 $is_fatal) {
28 $message = pht(
29 "Unable to connect to MySQL!\n\n".
30 "%s\n\n".
31 "Make sure databases connection information and MySQL are ".
32 "correctly configured.",
33 $ex->getMessage());
35 $issue = id(new self())
36 ->setIssueKey('mysql.connect')
37 ->setName(pht('Can Not Connect to MySQL'))
38 ->setMessage($message)
39 ->setIsFatal($is_fatal)
40 ->addRelatedPhabricatorConfig('mysql.host')
41 ->addRelatedPhabricatorConfig('mysql.port')
42 ->addRelatedPhabricatorConfig('mysql.user')
43 ->addRelatedPhabricatorConfig('mysql.pass');
45 if (PhabricatorEnv::getEnvConfig('cluster.databases')) {
46 $issue->addRelatedPhabricatorConfig('cluster.databases');
49 return $issue;
52 public function addCommand($command) {
53 $this->commands[] = $command;
54 return $this;
57 public function getCommands() {
58 return $this->commands;
61 public function setShortName($short_name) {
62 $this->shortName = $short_name;
63 return $this;
66 public function getShortName() {
67 if ($this->shortName === null) {
68 return $this->getName();
70 return $this->shortName;
73 public function setDatabaseRef(PhabricatorDatabaseRef $database_ref) {
74 $this->databaseRef = $database_ref;
75 return $this;
78 public function getDatabaseRef() {
79 return $this->databaseRef;
82 public function setGroup($group) {
83 $this->group = $group;
84 return $this;
87 public function getGroup() {
88 if ($this->group) {
89 return $this->group;
90 } else {
91 return PhabricatorSetupCheck::GROUP_OTHER;
95 public function setName($name) {
96 $this->name = $name;
97 return $this;
100 public function getName() {
101 return $this->name;
104 public function setSummary($summary) {
105 $this->summary = $summary;
106 return $this;
109 public function getSummary() {
110 if ($this->summary === null) {
111 return $this->getMessage();
113 return $this->summary;
116 public function setIssueKey($issue_key) {
117 $this->issueKey = $issue_key;
118 return $this;
121 public function getIssueKey() {
122 return $this->issueKey;
125 public function setIsFatal($is_fatal) {
126 $this->isFatal = $is_fatal;
127 return $this;
130 public function getIsFatal() {
131 return $this->isFatal;
134 public function addPHPConfig($php_config) {
135 $this->phpConfig[] = $php_config;
136 return $this;
140 * Set an explicit value to display when showing the user PHP configuration
141 * values.
143 * If Phabricator has changed a value by the time a config issue is raised,
144 * you can provide the original value here so the UI makes sense. For example,
145 * we alter `memory_limit` during startup, so if the original value is not
146 * provided it will look like it is always set to `-1`.
148 * @param string PHP configuration option to provide a value for.
149 * @param string Explicit value to show in the UI.
150 * @return this
152 public function addPHPConfigOriginalValue($php_config, $value) {
153 $this->originalPHPConfigValues[$php_config] = $value;
154 return $this;
157 public function getPHPConfigOriginalValue($php_config, $default = null) {
158 return idx($this->originalPHPConfigValues, $php_config, $default);
161 public function getPHPConfig() {
162 return $this->phpConfig;
165 public function addMySQLConfig($mysql_config) {
166 $this->mysqlConfig[] = $mysql_config;
167 return $this;
170 public function getMySQLConfig() {
171 return $this->mysqlConfig;
174 public function addPhabricatorConfig($phabricator_config) {
175 $this->phabricatorConfig[] = $phabricator_config;
176 return $this;
179 public function getPhabricatorConfig() {
180 return $this->phabricatorConfig;
183 public function addRelatedPhabricatorConfig($phabricator_config) {
184 $this->relatedPhabricatorConfig[] = $phabricator_config;
185 return $this;
188 public function getRelatedPhabricatorConfig() {
189 return $this->relatedPhabricatorConfig;
192 public function addPHPExtension($php_extension) {
193 $this->phpExtensions[] = $php_extension;
194 return $this;
197 public function getPHPExtensions() {
198 return $this->phpExtensions;
201 public function setMessage($message) {
202 $this->message = $message;
203 return $this;
206 public function getMessage() {
207 return $this->message;
210 public function setIsIgnored($is_ignored) {
211 $this->isIgnored = $is_ignored;
212 return $this;
215 public function getIsIgnored() {
216 return $this->isIgnored;
219 public function addLink($href, $name) {
220 $this->links[] = array(
221 'href' => $href,
222 'name' => $name,
224 return $this;
227 public function getLinks() {
228 return $this->links;