2012-12-30 15:37:49 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorSetupIssueView extends AphrontView {
|
|
|
|
|
|
|
|
private $issue;
|
|
|
|
|
|
|
|
public function setIssue(PhabricatorSetupIssue $issue) {
|
|
|
|
$this->issue = $issue;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIssue() {
|
|
|
|
return $this->issue;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
|
|
|
$issue = $this->getIssue();
|
|
|
|
|
2013-01-29 20:29:56 +01:00
|
|
|
$description = array();
|
|
|
|
$description[] = phutil_tag(
|
2012-12-30 15:37:49 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'setup-issue-instructions',
|
|
|
|
),
|
2013-02-08 00:57:37 +01:00
|
|
|
phutil_escape_html_newlines($issue->getMessage()));
|
2012-12-30 15:37:49 +01:00
|
|
|
|
2012-12-31 02:04:38 +01:00
|
|
|
$configs = $issue->getPHPConfig();
|
2012-12-30 15:37:49 +01:00
|
|
|
if ($configs) {
|
2013-01-29 20:29:56 +01:00
|
|
|
$description[] = $this->renderPHPConfig($configs);
|
2012-12-30 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
2012-12-31 02:04:38 +01:00
|
|
|
$configs = $issue->getPhabricatorConfig();
|
2012-12-30 15:37:49 +01:00
|
|
|
if ($configs) {
|
2013-01-29 20:29:56 +01:00
|
|
|
$description[] = $this->renderPhabricatorConfig($configs);
|
2012-12-30 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$commands = $issue->getCommands();
|
|
|
|
if ($commands) {
|
|
|
|
$run_these = pht("Run these %d command(s):", count($commands));
|
2013-01-29 20:29:56 +01:00
|
|
|
$description[] = phutil_tag(
|
2012-12-30 15:37:49 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'setup-issue-config',
|
|
|
|
),
|
2013-01-18 09:32:58 +01:00
|
|
|
array(
|
2013-01-29 20:29:56 +01:00
|
|
|
phutil_tag('p', array(), $run_these),
|
2013-02-11 20:17:14 +01:00
|
|
|
phutil_tag('pre', array(), phutil_implode_html("\n", $commands)),
|
2013-01-18 09:32:58 +01:00
|
|
|
));
|
2012-12-30 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$extensions = $issue->getPHPExtensions();
|
|
|
|
if ($extensions) {
|
|
|
|
$install_these = pht(
|
|
|
|
"Install these %d PHP extension(s):", count($extensions));
|
|
|
|
|
2013-02-06 00:14:18 +01:00
|
|
|
$install_info = pht(
|
|
|
|
"You can usually install a PHP extension using %s or %s. Common ".
|
|
|
|
"package names are %s or %s. Try commands like these:",
|
|
|
|
phutil_tag('tt', array(), 'apt-get'),
|
|
|
|
phutil_tag('tt', array(), 'yum'),
|
|
|
|
hsprintf('<tt>php-<em>%s</em></tt>', pht('extname')),
|
|
|
|
hsprintf('<tt>php5-<em>%s</em></tt>', pht('extname')));
|
2012-12-30 15:37:49 +01:00
|
|
|
|
|
|
|
// TODO: We should do a better job of detecting how to install extensions
|
|
|
|
// on the current system.
|
2013-02-06 00:14:18 +01:00
|
|
|
$install_commands = hsprintf(
|
|
|
|
"\$ sudo apt-get install php5-<em>extname</em> # Debian / Ubuntu\n".
|
|
|
|
"\$ sudo yum install php-<em>extname</em> # Red Hat / Derivatives"
|
2012-12-30 15:37:49 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$fallback_info = pht(
|
|
|
|
"If those commands don't work, try Google. The process of installing ".
|
|
|
|
"PHP extensions is not specific to Phabricator, and any instructions ".
|
|
|
|
"you can find for installing them on your system should work. On Mac ".
|
|
|
|
"OS X, you might want to try Homebrew.");
|
|
|
|
|
|
|
|
$restart_info = pht(
|
|
|
|
"After installing new PHP extensions, <strong>restart your webserver ".
|
2013-02-06 00:14:18 +01:00
|
|
|
"for the changes to take effect</strong>.",
|
|
|
|
hsprintf(''));
|
2012-12-30 15:37:49 +01:00
|
|
|
|
2013-01-29 20:29:56 +01:00
|
|
|
$description[] = phutil_tag(
|
2012-12-30 15:37:49 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'setup-issue-config',
|
|
|
|
),
|
2013-01-18 09:32:58 +01:00
|
|
|
array(
|
2013-01-29 20:29:56 +01:00
|
|
|
phutil_tag('p', array(), $install_these),
|
|
|
|
phutil_tag('pre', array(), implode("\n", $extensions)),
|
|
|
|
phutil_tag('p', array(), $install_info),
|
|
|
|
phutil_tag('pre', array(), $install_commands),
|
|
|
|
phutil_tag('p', array(), $fallback_info),
|
|
|
|
phutil_tag('p', array(), $restart_info),
|
2013-01-18 09:32:58 +01:00
|
|
|
));
|
2012-12-30 15:37:49 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-01-18 04:15:06 +01:00
|
|
|
$next = phutil_tag(
|
2012-12-30 15:37:49 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'setup-issue-next',
|
|
|
|
),
|
|
|
|
pht('To continue, resolve this problem and reload the page.'));
|
|
|
|
|
2013-01-18 03:43:35 +01:00
|
|
|
$name = phutil_tag(
|
2012-12-30 15:37:49 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'setup-issue-name',
|
|
|
|
),
|
2013-01-18 03:43:35 +01:00
|
|
|
$issue->getName());
|
2012-12-30 15:37:49 +01:00
|
|
|
|
2013-01-18 09:32:58 +01:00
|
|
|
return phutil_tag(
|
2012-12-30 15:37:49 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'setup-issue',
|
|
|
|
),
|
2013-01-29 20:29:56 +01:00
|
|
|
$this->renderHTMLView(
|
|
|
|
array(
|
|
|
|
$name,
|
|
|
|
$description,
|
|
|
|
$next,
|
|
|
|
)));
|
2012-12-30 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private function renderPhabricatorConfig(array $configs) {
|
2012-12-31 02:04:38 +01:00
|
|
|
$issue = $this->getIssue();
|
|
|
|
|
2013-01-18 09:32:58 +01:00
|
|
|
$table_info = phutil_tag(
|
2012-12-30 15:37:49 +01:00
|
|
|
'p',
|
|
|
|
array(),
|
|
|
|
pht(
|
|
|
|
"The current Phabricator configuration has these %d value(s):",
|
|
|
|
count($configs)));
|
|
|
|
|
2013-01-29 20:29:56 +01:00
|
|
|
$dict = array();
|
2012-12-30 15:37:49 +01:00
|
|
|
foreach ($configs as $key) {
|
2013-01-29 20:29:56 +01:00
|
|
|
$dict[$key] = PhabricatorEnv::getUnrepairedEnvConfig($key);
|
2012-12-30 15:37:49 +01:00
|
|
|
}
|
2013-01-29 20:29:56 +01:00
|
|
|
$table = $this->renderValueTable($dict);
|
2012-12-30 15:37:49 +01:00
|
|
|
|
2013-01-22 22:57:02 +01:00
|
|
|
$options = PhabricatorApplicationConfigOptions::loadAllOptions();
|
|
|
|
|
2012-12-31 02:04:38 +01:00
|
|
|
if ($this->getIssue()->getIsFatal()) {
|
2013-01-18 09:32:58 +01:00
|
|
|
$update_info = phutil_tag(
|
2012-12-31 02:04:38 +01:00
|
|
|
'p',
|
|
|
|
array(),
|
|
|
|
pht(
|
|
|
|
"To update these %d value(s), run these command(s) from the command ".
|
|
|
|
"line:",
|
|
|
|
count($configs)));
|
2012-12-30 15:37:49 +01:00
|
|
|
|
2012-12-31 02:04:38 +01:00
|
|
|
$update = array();
|
|
|
|
foreach ($configs as $key) {
|
2013-01-29 20:29:56 +01:00
|
|
|
$update[] = hsprintf(
|
|
|
|
'<tt>phabricator/ $</tt> ./bin/config set %s <em>value</em>',
|
|
|
|
$key);
|
2012-12-31 02:04:38 +01:00
|
|
|
}
|
2013-02-11 20:17:14 +01:00
|
|
|
$update = phutil_tag('pre', array(), phutil_implode_html("\n", $update));
|
2012-12-31 02:04:38 +01:00
|
|
|
} else {
|
|
|
|
$update = array();
|
|
|
|
foreach ($configs as $config) {
|
2013-01-25 02:48:50 +01:00
|
|
|
if (!idx($options, $config) || $options[$config]->getLocked()) {
|
2013-01-22 22:57:02 +01:00
|
|
|
continue;
|
|
|
|
}
|
2013-01-18 09:32:58 +01:00
|
|
|
$link = phutil_tag(
|
2012-12-31 02:04:38 +01:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/config/edit/'.$config.'/?issue='.$issue->getIssueKey(),
|
|
|
|
),
|
2013-01-18 09:32:58 +01:00
|
|
|
pht('Edit %s', $config));
|
2013-01-29 20:29:56 +01:00
|
|
|
$update[] = phutil_tag('li', array(), $link);
|
2012-12-31 02:04:38 +01:00
|
|
|
}
|
2013-01-22 22:57:02 +01:00
|
|
|
if ($update) {
|
2013-01-29 20:29:56 +01:00
|
|
|
$update = phutil_tag('ul', array(), $update);
|
|
|
|
$update_info = phutil_tag(
|
2013-01-22 22:57:02 +01:00
|
|
|
'p',
|
|
|
|
array(),
|
|
|
|
pht("You can update these %d value(s) here:", count($configs)));
|
|
|
|
} else {
|
|
|
|
$update = null;
|
|
|
|
$update_info = null;
|
|
|
|
}
|
2012-12-30 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
2013-01-29 20:29:56 +01:00
|
|
|
return phutil_tag(
|
2012-12-30 15:37:49 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'setup-issue-config',
|
|
|
|
),
|
2013-01-29 20:29:56 +01:00
|
|
|
self::renderHTMLView(
|
2012-12-30 15:37:49 +01:00
|
|
|
array(
|
|
|
|
$table_info,
|
|
|
|
$table,
|
|
|
|
$update_info,
|
|
|
|
$update,
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderPHPConfig(array $configs) {
|
2013-01-18 09:32:58 +01:00
|
|
|
$table_info = phutil_tag(
|
2012-12-30 15:37:49 +01:00
|
|
|
'p',
|
|
|
|
array(),
|
|
|
|
pht(
|
|
|
|
"The current PHP configuration has these %d value(s):",
|
|
|
|
count($configs)));
|
|
|
|
|
2013-01-29 20:29:56 +01:00
|
|
|
$dict = array();
|
2012-12-30 15:37:49 +01:00
|
|
|
foreach ($configs as $key) {
|
2013-01-29 20:29:56 +01:00
|
|
|
$dict[$key] = ini_get($key);
|
2012-12-30 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
2013-01-29 20:29:56 +01:00
|
|
|
$table = $this->renderValueTable($dict);
|
2012-12-30 15:37:49 +01:00
|
|
|
|
|
|
|
ob_start();
|
|
|
|
phpinfo();
|
|
|
|
$phpinfo = ob_get_clean();
|
|
|
|
|
|
|
|
|
|
|
|
$rex = '@Loaded Configuration File\s*</td><td class="v">(.*?)</td>@i';
|
|
|
|
$matches = null;
|
|
|
|
|
|
|
|
$ini_loc = null;
|
|
|
|
if (preg_match($rex, $phpinfo, $matches)) {
|
|
|
|
$ini_loc = trim($matches[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
$rex = '@Additional \.ini files parsed\s*</td><td class="v">(.*?)</td>@i';
|
|
|
|
|
|
|
|
$more_loc = array();
|
|
|
|
if (preg_match($rex, $phpinfo, $matches)) {
|
|
|
|
$more_loc = trim($matches[1]);
|
|
|
|
if ($more_loc == '(none)') {
|
|
|
|
$more_loc = array();
|
|
|
|
} else {
|
|
|
|
$more_loc = preg_split('/\s*,\s*/', $more_loc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-29 20:29:56 +01:00
|
|
|
$info = array();
|
2012-12-30 15:37:49 +01:00
|
|
|
if (!$ini_loc) {
|
2013-01-29 20:29:56 +01:00
|
|
|
$info[] = phutil_tag(
|
2012-12-30 15:37:49 +01:00
|
|
|
'p',
|
|
|
|
array(),
|
|
|
|
pht(
|
|
|
|
"To update these %d value(s), edit your PHP configuration file.",
|
|
|
|
count($configs)));
|
|
|
|
} else {
|
2013-01-29 20:29:56 +01:00
|
|
|
$info[] = phutil_tag(
|
2012-12-30 15:37:49 +01:00
|
|
|
'p',
|
|
|
|
array(),
|
|
|
|
pht(
|
|
|
|
"To update these %d value(s), edit your PHP configuration file, ".
|
|
|
|
"located here:",
|
|
|
|
count($configs)));
|
2013-01-29 20:29:56 +01:00
|
|
|
$info[] = phutil_tag(
|
2012-12-30 15:37:49 +01:00
|
|
|
'pre',
|
|
|
|
array(),
|
2013-01-18 03:43:35 +01:00
|
|
|
$ini_loc);
|
2012-12-30 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($more_loc) {
|
2013-01-29 20:29:56 +01:00
|
|
|
$info[] = phutil_tag(
|
2012-12-30 15:37:49 +01:00
|
|
|
'p',
|
|
|
|
array(),
|
|
|
|
pht(
|
|
|
|
"PHP also loaded these configuration file(s):",
|
|
|
|
count($more_loc)));
|
2013-01-29 20:29:56 +01:00
|
|
|
$info[] = phutil_tag(
|
2012-12-30 15:37:49 +01:00
|
|
|
'pre',
|
|
|
|
array(),
|
2013-01-18 03:43:35 +01:00
|
|
|
implode("\n", $more_loc));
|
2012-12-30 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
2013-01-29 20:29:56 +01:00
|
|
|
$info[] = phutil_tag(
|
2012-12-30 15:37:49 +01:00
|
|
|
'p',
|
|
|
|
array(),
|
2013-02-06 00:14:18 +01:00
|
|
|
pht(
|
2013-01-18 09:32:58 +01:00
|
|
|
'You can find more information about PHP configuration values in the '.
|
|
|
|
'<a href="%s">PHP Documentation</a>.',
|
2013-02-06 00:14:18 +01:00
|
|
|
'http://php.net/manual/ini.list.php',
|
|
|
|
hsprintf('')));
|
2012-12-31 02:04:38 +01:00
|
|
|
|
2013-01-29 20:29:56 +01:00
|
|
|
$info[] = phutil_tag(
|
2012-12-31 02:04:38 +01:00
|
|
|
'p',
|
|
|
|
array(),
|
2013-02-06 00:14:18 +01:00
|
|
|
pht(
|
2012-12-31 02:04:38 +01:00
|
|
|
"After editing the PHP configuration, <strong>restart your ".
|
2013-02-06 00:14:18 +01:00
|
|
|
"webserver for the changes to take effect</strong>.",
|
|
|
|
hsprintf('')));
|
2012-12-30 15:37:49 +01:00
|
|
|
|
2013-01-18 09:32:58 +01:00
|
|
|
return phutil_tag(
|
2012-12-30 15:37:49 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'setup-issue-config',
|
|
|
|
),
|
2013-01-29 20:29:56 +01:00
|
|
|
$this->renderHTMLView(
|
|
|
|
array(
|
|
|
|
$table_info,
|
|
|
|
$table,
|
|
|
|
$info,
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderValueTable(array $dict) {
|
|
|
|
$rows = array();
|
|
|
|
foreach ($dict as $key => $value) {
|
|
|
|
$cols = array(
|
|
|
|
phutil_tag('th', array(), $key),
|
|
|
|
phutil_tag('td', array(), $this->renderValueForDisplay($value)),
|
|
|
|
);
|
|
|
|
$rows[] = phutil_tag('tr', array(), $cols);
|
|
|
|
}
|
|
|
|
return phutil_tag('table', array(), $rows);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderValueForDisplay($value) {
|
|
|
|
if ($value === null) {
|
|
|
|
return phutil_tag('em', array(), 'null');
|
|
|
|
} else if ($value === false) {
|
|
|
|
return phutil_tag('em', array(), 'false');
|
|
|
|
} else if ($value === true) {
|
|
|
|
return phutil_tag('em', array(), 'true');
|
|
|
|
} else if ($value === '') {
|
|
|
|
return phutil_tag('em', array(), 'empty string');
|
|
|
|
} else {
|
|
|
|
return PhabricatorConfigJSON::prettyPrintJSON($value);
|
|
|
|
}
|
2012-12-30 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|