Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / config / issue / PhabricatorSetupIssue.php
bloba2e9532ede9340cd8112b9362c1f249aa42f7d86
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 Phabricator and MySQL are correctly configured.",
32 $ex->getMessage());
34 $issue = id(new self())
35 ->setIssueKey('mysql.connect')
36 ->setName(pht('Can Not Connect to MySQL'))
37 ->setMessage($message)
38 ->setIsFatal($is_fatal)
39 ->addRelatedPhabricatorConfig('mysql.host')
40 ->addRelatedPhabricatorConfig('mysql.port')
41 ->addRelatedPhabricatorConfig('mysql.user')
42 ->addRelatedPhabricatorConfig('mysql.pass');
44 if (PhabricatorEnv::getEnvConfig('cluster.databases')) {
45 $issue->addRelatedPhabricatorConfig('cluster.databases');
48 return $issue;
51 public function addCommand($command) {
52 $this->commands[] = $command;
53 return $this;
56 public function getCommands() {
57 return $this->commands;
60 public function setShortName($short_name) {
61 $this->shortName = $short_name;
62 return $this;
65 public function getShortName() {
66 if ($this->shortName === null) {
67 return $this->getName();
69 return $this->shortName;
72 public function setDatabaseRef(PhabricatorDatabaseRef $database_ref) {
73 $this->databaseRef = $database_ref;
74 return $this;
77 public function getDatabaseRef() {
78 return $this->databaseRef;
81 public function setGroup($group) {
82 $this->group = $group;
83 return $this;
86 public function getGroup() {
87 if ($this->group) {
88 return $this->group;
89 } else {
90 return PhabricatorSetupCheck::GROUP_OTHER;
94 public function setName($name) {
95 $this->name = $name;
96 return $this;
99 public function getName() {
100 return $this->name;
103 public function setSummary($summary) {
104 $this->summary = $summary;
105 return $this;
108 public function getSummary() {
109 if ($this->summary === null) {
110 return $this->getMessage();
112 return $this->summary;
115 public function setIssueKey($issue_key) {
116 $this->issueKey = $issue_key;
117 return $this;
120 public function getIssueKey() {
121 return $this->issueKey;
124 public function setIsFatal($is_fatal) {
125 $this->isFatal = $is_fatal;
126 return $this;
129 public function getIsFatal() {
130 return $this->isFatal;
133 public function addPHPConfig($php_config) {
134 $this->phpConfig[] = $php_config;
135 return $this;
139 * Set an explicit value to display when showing the user PHP configuration
140 * values.
142 * If Phabricator has changed a value by the time a config issue is raised,
143 * you can provide the original value here so the UI makes sense. For example,
144 * we alter `memory_limit` during startup, so if the original value is not
145 * provided it will look like it is always set to `-1`.
147 * @param string PHP configuration option to provide a value for.
148 * @param string Explicit value to show in the UI.
149 * @return this
151 public function addPHPConfigOriginalValue($php_config, $value) {
152 $this->originalPHPConfigValues[$php_config] = $value;
153 return $this;
156 public function getPHPConfigOriginalValue($php_config, $default = null) {
157 return idx($this->originalPHPConfigValues, $php_config, $default);
160 public function getPHPConfig() {
161 return $this->phpConfig;
164 public function addMySQLConfig($mysql_config) {
165 $this->mysqlConfig[] = $mysql_config;
166 return $this;
169 public function getMySQLConfig() {
170 return $this->mysqlConfig;
173 public function addPhabricatorConfig($phabricator_config) {
174 $this->phabricatorConfig[] = $phabricator_config;
175 return $this;
178 public function getPhabricatorConfig() {
179 return $this->phabricatorConfig;
182 public function addRelatedPhabricatorConfig($phabricator_config) {
183 $this->relatedPhabricatorConfig[] = $phabricator_config;
184 return $this;
187 public function getRelatedPhabricatorConfig() {
188 return $this->relatedPhabricatorConfig;
191 public function addPHPExtension($php_extension) {
192 $this->phpExtensions[] = $php_extension;
193 return $this;
196 public function getPHPExtensions() {
197 return $this->phpExtensions;
200 public function setMessage($message) {
201 $this->message = $message;
202 return $this;
205 public function getMessage() {
206 return $this->message;
209 public function setIsIgnored($is_ignored) {
210 $this->isIgnored = $is_ignored;
211 return $this;
214 public function getIsIgnored() {
215 return $this->isIgnored;
218 public function addLink($href, $name) {
219 $this->links[] = array(
220 'href' => $href,
221 'name' => $name,
223 return $this;
226 public function getLinks() {
227 return $this->links;