Skip to content

Commit

Permalink
Upgrade report: cv version and cleaner redactions
Browse files Browse the repository at this point in the history
  • Loading branch information
agh1 committed May 10, 2017
1 parent cdfb2ab commit 8b703b5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Command/UpgradeReportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
// `upgradeReport` List of upgrade messages [[WRITE-ONCE]]
// `finished` Time (seconds since epoch) at which we generated the finish report [[WRITE-ONCE]]
// `finishReport` JSON report from "System.get" [[WRITE-ONCE]]
// `testsReport` JSON report from a testing suite

$opts = $input->getOptions();

Expand All @@ -77,6 +78,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
// Set up identity of report
$report = array(
'siteId' => \Civi\Cv\Util\Cv::run("ev \"return md5('We need to talk about your TPS reports' . CIVICRM_SITE_KEY);\" --level=settings"),
'cvVersion' => '@package_version@',
);

if ($opts['downloadurl']) {
Expand Down Expand Up @@ -171,9 +173,26 @@ protected function systemReport() {
catch (\Exception $e) {
$report = array('error' => 'Could not produce report');
}
$vars = \Civi\Cv\Util\Cv::run('vars:show');
$domain = empty($vars['CMS_URL']) ? NULL : preg_replace(";https?://;", '', $vars['CMS_URL']);
$this->recursiveRedact($report, $domain);
return $report;
}

protected function recursiveRedact(&$report, $domain) {
foreach ($report as $k => &$v) {
if (is_array($v)) {
$this->recursiveRedact($v, $domain);
}
elseif ($v == "REDACTED") {
unset($report[$k]);
}
elseif ($domain) {
$v = preg_replace(";(https?://)?$domain;", 'REDACTEDURL/', $v);
}
}
}

/**
* Check to see if the report contains necessary information.
*
Expand Down

0 comments on commit 8b703b5

Please sign in to comment.