Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/config/issue/PhabricatorSetupIssue.php
12256 views
1
<?php
2
3
final class PhabricatorSetupIssue extends Phobject {
4
5
private $issueKey;
6
private $name;
7
private $message;
8
private $isFatal;
9
private $summary;
10
private $shortName;
11
private $group;
12
private $databaseRef;
13
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;
23
24
public static function newDatabaseConnectionIssue(
25
Exception $ex,
26
$is_fatal) {
27
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());
34
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');
44
45
if (PhabricatorEnv::getEnvConfig('cluster.databases')) {
46
$issue->addRelatedPhabricatorConfig('cluster.databases');
47
}
48
49
return $issue;
50
}
51
52
public function addCommand($command) {
53
$this->commands[] = $command;
54
return $this;
55
}
56
57
public function getCommands() {
58
return $this->commands;
59
}
60
61
public function setShortName($short_name) {
62
$this->shortName = $short_name;
63
return $this;
64
}
65
66
public function getShortName() {
67
if ($this->shortName === null) {
68
return $this->getName();
69
}
70
return $this->shortName;
71
}
72
73
public function setDatabaseRef(PhabricatorDatabaseRef $database_ref) {
74
$this->databaseRef = $database_ref;
75
return $this;
76
}
77
78
public function getDatabaseRef() {
79
return $this->databaseRef;
80
}
81
82
public function setGroup($group) {
83
$this->group = $group;
84
return $this;
85
}
86
87
public function getGroup() {
88
if ($this->group) {
89
return $this->group;
90
} else {
91
return PhabricatorSetupCheck::GROUP_OTHER;
92
}
93
}
94
95
public function setName($name) {
96
$this->name = $name;
97
return $this;
98
}
99
100
public function getName() {
101
return $this->name;
102
}
103
104
public function setSummary($summary) {
105
$this->summary = $summary;
106
return $this;
107
}
108
109
public function getSummary() {
110
if ($this->summary === null) {
111
return $this->getMessage();
112
}
113
return $this->summary;
114
}
115
116
public function setIssueKey($issue_key) {
117
$this->issueKey = $issue_key;
118
return $this;
119
}
120
121
public function getIssueKey() {
122
return $this->issueKey;
123
}
124
125
public function setIsFatal($is_fatal) {
126
$this->isFatal = $is_fatal;
127
return $this;
128
}
129
130
public function getIsFatal() {
131
return $this->isFatal;
132
}
133
134
public function addPHPConfig($php_config) {
135
$this->phpConfig[] = $php_config;
136
return $this;
137
}
138
139
/**
140
* Set an explicit value to display when showing the user PHP configuration
141
* values.
142
*
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`.
147
*
148
* @param string PHP configuration option to provide a value for.
149
* @param string Explicit value to show in the UI.
150
* @return this
151
*/
152
public function addPHPConfigOriginalValue($php_config, $value) {
153
$this->originalPHPConfigValues[$php_config] = $value;
154
return $this;
155
}
156
157
public function getPHPConfigOriginalValue($php_config, $default = null) {
158
return idx($this->originalPHPConfigValues, $php_config, $default);
159
}
160
161
public function getPHPConfig() {
162
return $this->phpConfig;
163
}
164
165
public function addMySQLConfig($mysql_config) {
166
$this->mysqlConfig[] = $mysql_config;
167
return $this;
168
}
169
170
public function getMySQLConfig() {
171
return $this->mysqlConfig;
172
}
173
174
public function addPhabricatorConfig($phabricator_config) {
175
$this->phabricatorConfig[] = $phabricator_config;
176
return $this;
177
}
178
179
public function getPhabricatorConfig() {
180
return $this->phabricatorConfig;
181
}
182
183
public function addRelatedPhabricatorConfig($phabricator_config) {
184
$this->relatedPhabricatorConfig[] = $phabricator_config;
185
return $this;
186
}
187
188
public function getRelatedPhabricatorConfig() {
189
return $this->relatedPhabricatorConfig;
190
}
191
192
public function addPHPExtension($php_extension) {
193
$this->phpExtensions[] = $php_extension;
194
return $this;
195
}
196
197
public function getPHPExtensions() {
198
return $this->phpExtensions;
199
}
200
201
public function setMessage($message) {
202
$this->message = $message;
203
return $this;
204
}
205
206
public function getMessage() {
207
return $this->message;
208
}
209
210
public function setIsIgnored($is_ignored) {
211
$this->isIgnored = $is_ignored;
212
return $this;
213
}
214
215
public function getIsIgnored() {
216
return $this->isIgnored;
217
}
218
219
public function addLink($href, $name) {
220
$this->links[] = array(
221
'href' => $href,
222
'name' => $name,
223
);
224
return $this;
225
}
226
227
public function getLinks() {
228
return $this->links;
229
}
230
231
}
232
233