Path: blob/master/src/applications/config/issue/PhabricatorSetupIssue.php
12256 views
<?php12final class PhabricatorSetupIssue extends Phobject {34private $issueKey;5private $name;6private $message;7private $isFatal;8private $summary;9private $shortName;10private $group;11private $databaseRef;1213private $isIgnored = false;14private $phpExtensions = array();15private $phabricatorConfig = array();16private $relatedPhabricatorConfig = array();17private $phpConfig = array();18private $commands = array();19private $mysqlConfig = array();20private $originalPHPConfigValues = array();21private $links;2223public static function newDatabaseConnectionIssue(24Exception $ex,25$is_fatal) {2627$message = pht(28"Unable to connect to MySQL!\n\n".29"%s\n\n".30"Make sure databases connection information and MySQL are ".31"correctly configured.",32$ex->getMessage());3334$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');4344if (PhabricatorEnv::getEnvConfig('cluster.databases')) {45$issue->addRelatedPhabricatorConfig('cluster.databases');46}4748return $issue;49}5051public function addCommand($command) {52$this->commands[] = $command;53return $this;54}5556public function getCommands() {57return $this->commands;58}5960public function setShortName($short_name) {61$this->shortName = $short_name;62return $this;63}6465public function getShortName() {66if ($this->shortName === null) {67return $this->getName();68}69return $this->shortName;70}7172public function setDatabaseRef(PhabricatorDatabaseRef $database_ref) {73$this->databaseRef = $database_ref;74return $this;75}7677public function getDatabaseRef() {78return $this->databaseRef;79}8081public function setGroup($group) {82$this->group = $group;83return $this;84}8586public function getGroup() {87if ($this->group) {88return $this->group;89} else {90return PhabricatorSetupCheck::GROUP_OTHER;91}92}9394public function setName($name) {95$this->name = $name;96return $this;97}9899public function getName() {100return $this->name;101}102103public function setSummary($summary) {104$this->summary = $summary;105return $this;106}107108public function getSummary() {109if ($this->summary === null) {110return $this->getMessage();111}112return $this->summary;113}114115public function setIssueKey($issue_key) {116$this->issueKey = $issue_key;117return $this;118}119120public function getIssueKey() {121return $this->issueKey;122}123124public function setIsFatal($is_fatal) {125$this->isFatal = $is_fatal;126return $this;127}128129public function getIsFatal() {130return $this->isFatal;131}132133public function addPHPConfig($php_config) {134$this->phpConfig[] = $php_config;135return $this;136}137138/**139* Set an explicit value to display when showing the user PHP configuration140* values.141*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 not145* provided it will look like it is always set to `-1`.146*147* @param string PHP configuration option to provide a value for.148* @param string Explicit value to show in the UI.149* @return this150*/151public function addPHPConfigOriginalValue($php_config, $value) {152$this->originalPHPConfigValues[$php_config] = $value;153return $this;154}155156public function getPHPConfigOriginalValue($php_config, $default = null) {157return idx($this->originalPHPConfigValues, $php_config, $default);158}159160public function getPHPConfig() {161return $this->phpConfig;162}163164public function addMySQLConfig($mysql_config) {165$this->mysqlConfig[] = $mysql_config;166return $this;167}168169public function getMySQLConfig() {170return $this->mysqlConfig;171}172173public function addPhabricatorConfig($phabricator_config) {174$this->phabricatorConfig[] = $phabricator_config;175return $this;176}177178public function getPhabricatorConfig() {179return $this->phabricatorConfig;180}181182public function addRelatedPhabricatorConfig($phabricator_config) {183$this->relatedPhabricatorConfig[] = $phabricator_config;184return $this;185}186187public function getRelatedPhabricatorConfig() {188return $this->relatedPhabricatorConfig;189}190191public function addPHPExtension($php_extension) {192$this->phpExtensions[] = $php_extension;193return $this;194}195196public function getPHPExtensions() {197return $this->phpExtensions;198}199200public function setMessage($message) {201$this->message = $message;202return $this;203}204205public function getMessage() {206return $this->message;207}208209public function setIsIgnored($is_ignored) {210$this->isIgnored = $is_ignored;211return $this;212}213214public function getIsIgnored() {215return $this->isIgnored;216}217218public function addLink($href, $name) {219$this->links[] = array(220'href' => $href,221'name' => $name,222);223return $this;224}225226public function getLinks() {227return $this->links;228}229230}231232233