Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2020-09-02 10:02:12 +0300
committerGitHub <noreply@github.com>2020-09-02 10:02:12 +0300
commit11f54ee6389bd8ac408385b0d1760936c496470c (patch)
tree92d398822189d5ccdc842fa6e1c996c7347ebf11
parent67d3486533579cb57c30e38074611c3ae80e9161 (diff)
Provide more debug information in system check (#16350)
* Provide more debug information in system check * hide some info in screenshots * try overriding some columns * hide tr instead of only the content * trying to get tests to work * try different way * try fix tests * make sure cookie exists * add overridejs to install * more tweaks * fix test * more tweaks * move things to DI * minor tweaks * minor tweaks * fix test * also anonymise DB username * Update Twig.php * Improve query performance * Fix ClientTest keywords Co-authored-by: diosmosis <diosmosis@users.noreply.github.com>
-rw-r--r--core/Twig.php34
-rw-r--r--plugins/Diagnostics/Diagnostic/ConfigInformational.php79
-rw-r--r--plugins/Diagnostics/Diagnostic/DatabaseInformational.php68
-rw-r--r--plugins/Diagnostics/Diagnostic/DiagnosticResult.php19
-rw-r--r--plugins/Diagnostics/Diagnostic/MatomoInformational.php55
-rw-r--r--plugins/Diagnostics/Diagnostic/PhpInformational.php78
-rw-r--r--plugins/Diagnostics/Diagnostic/ReportInformational.php68
-rw-r--r--plugins/Diagnostics/Diagnostic/ServerInformational.php38
-rw-r--r--plugins/Diagnostics/Diagnostic/UserInformational.php41
-rw-r--r--plugins/Diagnostics/DiagnosticReport.php16
-rw-r--r--plugins/Diagnostics/DiagnosticService.php11
-rw-r--r--plugins/Diagnostics/config/config.php11
-rw-r--r--plugins/Diagnostics/tests/UI/expected-screenshots/Diagnostics_page.png4
-rw-r--r--plugins/Diagnostics/tests/Unit/DiagnosticReportTest.php11
-rw-r--r--plugins/Diagnostics/tests/Unit/DiagnosticServiceTest.php4
-rw-r--r--plugins/Installation/Controller.php6
-rw-r--r--plugins/Installation/lang/en.json3
-rw-r--r--plugins/Installation/templates/_systemCheckSection.twig44
-rw-r--r--plugins/Installation/templates/systemCheckPage.twig3
-rw-r--r--plugins/Installation/tests/UI/expected-screenshots/Installation_system_check.png4
-rw-r--r--plugins/Marketplace/tests/System/Api/ClientTest.php2
-rw-r--r--tests/resources/screenshot-override/override.js22
22 files changed, 603 insertions, 18 deletions
diff --git a/core/Twig.php b/core/Twig.php
index 1ff38003ab..a4fe82be08 100644
--- a/core/Twig.php
+++ b/core/Twig.php
@@ -176,6 +176,7 @@ class Twig
$this->addFilter_prettyDate();
$this->addFilter_safeDecodeRaw();
$this->addFilter_number();
+ $this->addFilter_anonymiseSystemInfo();
$this->addFilter_nonce();
$this->addFilter_md5();
$this->addFilter_onlyDomain();
@@ -434,6 +435,39 @@ class Twig
$this->twig->addFilter($formatter);
}
+ protected function addFilter_anonymiseSystemInfo()
+ {
+ $formatter = new TwigFilter('anonymiseSystemInfo', function ($string) {
+ if ($string === null) {
+ return '';
+ }
+ if ($string === false || $string === true) {
+ return (int) $string;
+ }
+ $string = str_replace([PIWIK_DOCUMENT_ROOT, str_replace( '/', '\/', PIWIK_DOCUMENT_ROOT )], '$DOC_ROOT', $string);
+ $string = str_replace([PIWIK_USER_PATH, str_replace( '/', '\/', PIWIK_USER_PATH ) ], '$USER_PATH', $string);
+ $string = str_replace([PIWIK_INCLUDE_PATH, str_replace( '/', '\/', PIWIK_INCLUDE_PATH ) ], '$INCLUDE_PATH', $string);
+
+ // replace anything token like
+ $string = preg_replace('/[[:xdigit:]]{31,80}/', 'TOKEN_REPLACED', $string);
+
+ // just in case it was somehow show in a text
+ if (SettingsPiwik::isMatomoInstalled()) {
+ $string = str_replace(SettingsPiwik::getPiwikUrl(), '$MATOMO_URL', $string);
+ $string = str_replace(SettingsPiwik::getSalt(), '$MATOMO_SALT', $string);
+
+ $config = Config::getInstance();
+ $db = $config->database;
+ $string = str_replace($db['username'], '$DB_USERNAME', $string);
+ $string = str_replace($db['password'], '$DB_PASSWORD', $string);
+ $string = str_replace($db['host'], '$DB_HOST', $string);
+ $string = str_replace($db['dbname'], '$DB_NAME', $string);
+ }
+ return $string;
+ });
+ $this->twig->addFilter($formatter);
+ }
+
protected function addFilter_nonce()
{
$nonce = new TwigFilter('nonce', array('Piwik\\Nonce', 'getNonce'));
diff --git a/plugins/Diagnostics/Diagnostic/ConfigInformational.php b/plugins/Diagnostics/Diagnostic/ConfigInformational.php
new file mode 100644
index 0000000000..1d3e9ec182
--- /dev/null
+++ b/plugins/Diagnostics/Diagnostic/ConfigInformational.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Matomo - free/libre analytics platform
+ *
+ * @link https://matomo.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+namespace Piwik\Plugins\Diagnostics\Diagnostic;
+
+use Piwik\ArchiveProcessor\Rules;
+use Piwik\Development;
+use Piwik\Plugin\Manager;
+use Piwik\SettingsPiwik;
+use Piwik\Translation\Translator;
+
+/**
+ * Informatation about the Matomo configuration
+ */
+class ConfigInformational implements Diagnostic
+{
+ /**
+ * @var Translator
+ */
+ private $translator;
+
+ public function __construct(Translator $translator)
+ {
+ $this->translator = $translator;
+ }
+
+ public function execute()
+ {
+ $results = [];
+
+ if (SettingsPiwik::isMatomoInstalled()) {
+ $results[] = DiagnosticResult::informationalResult('Browser Archiving Enabled', Rules::isBrowserTriggerEnabled());
+ $results[] = DiagnosticResult::informationalResult('Browser Segment Archiving Enabled', Rules::isBrowserArchivingAvailableForSegments());
+ $results[] = DiagnosticResult::informationalResult('Development Mode Enabled', Development::isEnabled());
+ $results[] = DiagnosticResult::informationalResult('Internet Enabled',SettingsPiwik::isInternetEnabled());
+ $results[] = DiagnosticResult::informationalResult('Multi Server Environment', SettingsPiwik::isMultiServerEnvironment());
+ $results[] = DiagnosticResult::informationalResult('Custom User Path', PIWIK_USER_PATH != PIWIK_DOCUMENT_ROOT);
+ $results[] = DiagnosticResult::informationalResult('Custom Include Path', PIWIK_INCLUDE_PATH != PIWIK_DOCUMENT_ROOT);
+
+ $pluginsActivated = array();
+ $pluginsDeactivated = array();
+ $pluginsInvalid = array();
+ $plugins = Manager::getInstance()->loadAllPluginsAndGetTheirInfo();
+ foreach ($plugins as $pluginName => $plugin) {
+ $string = $pluginName;
+ if (!empty($plugin['info']['version'])
+ && !empty($plugin['uninstallable'])
+ && (!defined('PIWIK_TEST_MODE') || !PIWIK_TEST_MODE)) {
+ // we only want to show versions for plugins not shipped with core
+ // in tests we don't show version numbers to not always needing to update the screenshot
+ $string .= ' ' . $plugin['info']['version'];
+ }
+ if (!empty($plugin['activated'])) {
+ $pluginsActivated[] = $string;
+ } else {
+ $pluginsDeactivated[] = $string;
+ }
+ if (!empty($plugin['invalid'])) {
+ $pluginsInvalid[] = $string;
+ }
+ }
+
+ $results[] = DiagnosticResult::informationalResult('Plugins Activated', implode(', ', $pluginsActivated));
+ $results[] = DiagnosticResult::informationalResult('Plugins Deactivated', implode(', ', $pluginsDeactivated));
+ $results[] = DiagnosticResult::informationalResult('Plugins Invalid', implode(', ', $pluginsInvalid));
+
+ if (!empty($GLOBALS['MATOMO_PLUGIN_DIRS'])) {
+ $results[] = DiagnosticResult::informationalResult('Custom Plugins Directories', json_encode($GLOBALS['MATOMO_PLUGIN_DIRS']));
+ }
+ }
+
+ return $results;
+ }
+
+}
diff --git a/plugins/Diagnostics/Diagnostic/DatabaseInformational.php b/plugins/Diagnostics/Diagnostic/DatabaseInformational.php
new file mode 100644
index 0000000000..31aadc4901
--- /dev/null
+++ b/plugins/Diagnostics/Diagnostic/DatabaseInformational.php
@@ -0,0 +1,68 @@
+<?php
+/**
+ * Matomo - free/libre analytics platform
+ *
+ * @link https://matomo.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+namespace Piwik\Plugins\Diagnostics\Diagnostic;
+
+use Piwik\Common;
+use Piwik\Config;
+use Piwik\Db;
+use Piwik\SettingsPiwik;
+use Piwik\Translation\Translator;
+
+/**
+ * Informatation about the database.
+ */
+class DatabaseInformational implements Diagnostic
+{
+ /**
+ * @var Translator
+ */
+ private $translator;
+
+ public function __construct(Translator $translator)
+ {
+ $this->translator = $translator;
+ }
+
+ public function execute()
+ {
+ $results = [];
+
+ if (SettingsPiwik::isMatomoInstalled()) {
+ $dbConfig = Config::getInstance()->database;
+ $results[] = DiagnosticResult::informationalResult('DB Prefix', $dbConfig['tables_prefix']);
+ $results[] = DiagnosticResult::informationalResult('DB Charset', $dbConfig['charset']);
+ $results[] = DiagnosticResult::informationalResult('DB Adapter', $dbConfig['adapter']);
+ $results[] = DiagnosticResult::informationalResult('MySQL Version', $this->getServerVersion());
+ $results[] = DiagnosticResult::informationalResult('Num Tables', $this->getNumMatomoTables());
+ }
+
+ return $results;
+ }
+
+ private function getServerVErsion() {
+ try {
+ return Db::get()->getServerVersion();
+ } catch (\Exception $e) {
+ return $e->getMessage();
+ }
+ }
+
+ private function getNumMatomoTables() {
+ $prefix = Common::prefixTable('');
+
+ $results = null;
+ try {
+ $results = Db::get()->fetchAll('show tables like "' . $prefix . '%"');
+ } catch (\Exception $e) {
+ return $e->getMessage();
+ }
+
+ return count($results);
+ }
+
+}
diff --git a/plugins/Diagnostics/Diagnostic/DiagnosticResult.php b/plugins/Diagnostics/Diagnostic/DiagnosticResult.php
index 6e60db812d..f95407d40a 100644
--- a/plugins/Diagnostics/Diagnostic/DiagnosticResult.php
+++ b/plugins/Diagnostics/Diagnostic/DiagnosticResult.php
@@ -18,6 +18,7 @@ class DiagnosticResult
const STATUS_ERROR = 'error';
const STATUS_WARNING = 'warning';
const STATUS_OK = 'ok';
+ const STATUS_INFORMATIONAL = 'informational';
/**
* @var string
@@ -53,6 +54,24 @@ class DiagnosticResult
}
/**
+ * @param string $label
+ * @param string $status
+ * @param string $comment
+ * @return DiagnosticResult
+ */
+ public static function informationalResult($label, $comment = '')
+ {
+ if ($comment === true) {
+ $comment = '1';
+ } elseif ($comment === false) {
+ $comment = '0';
+ }
+ $result = new self($label);
+ $result->addItem(new DiagnosticResultItem(self::STATUS_INFORMATIONAL, $comment));
+ return $result;
+ }
+
+ /**
* @return string
*/
public function getLabel()
diff --git a/plugins/Diagnostics/Diagnostic/MatomoInformational.php b/plugins/Diagnostics/Diagnostic/MatomoInformational.php
new file mode 100644
index 0000000000..bcb43a5908
--- /dev/null
+++ b/plugins/Diagnostics/Diagnostic/MatomoInformational.php
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Matomo - free/libre analytics platform
+ *
+ * @link https://matomo.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+namespace Piwik\Plugins\Diagnostics\Diagnostic;
+
+use Piwik\DbHelper;
+use Piwik\SettingsPiwik;
+use Piwik\Translation\Translator;
+use Piwik\Version;
+
+/**
+ * Information about Matomo itself
+ */
+class MatomoInformational implements Diagnostic
+{
+ /**
+ * @var Translator
+ */
+ private $translator;
+
+ public function __construct(Translator $translator)
+ {
+ $this->translator = $translator;
+ }
+
+ public function execute()
+ {
+ $results = [];
+
+ $results[] = DiagnosticResult::informationalResult('Matomo Version', Version::VERSION);
+
+ if (SettingsPiwik::isMatomoInstalled()) {
+ $results[] = DiagnosticResult::informationalResult('Matomo Install Version', $this->getInstallVersion());
+ }
+
+ return $results;
+ }
+
+ private function getInstallVersion() {
+ try {
+ $version = DbHelper::getInstallVersion();
+ if (empty($version)) {
+ $version = 'Unknown - pre 3.8.';
+ }
+ return $version;
+ } catch (\Exception $e) {
+ return $e->getMessage();
+ }
+ }
+
+}
diff --git a/plugins/Diagnostics/Diagnostic/PhpInformational.php b/plugins/Diagnostics/Diagnostic/PhpInformational.php
new file mode 100644
index 0000000000..e2f33259f0
--- /dev/null
+++ b/plugins/Diagnostics/Diagnostic/PhpInformational.php
@@ -0,0 +1,78 @@
+<?php
+/**
+ * Matomo - free/libre analytics platform
+ *
+ * @link https://matomo.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+namespace Piwik\Plugins\Diagnostics\Diagnostic;
+
+use Piwik\CliMulti\CliPhp;
+use Piwik\Date;
+use Piwik\SettingsPiwik;
+use Piwik\Translation\Translator;
+
+/**
+ * Information about PHP.
+ */
+class PhpInformational implements Diagnostic
+{
+ /**
+ * @var Translator
+ */
+ private $translator;
+
+ public function __construct(Translator $translator)
+ {
+ $this->translator = $translator;
+ }
+
+ public function execute()
+ {
+ $results = [];
+
+ if (defined('PHP_OS') && PHP_OS) {
+ $results[] = DiagnosticResult::informationalResult('PHP_OS', PHP_OS);
+ }
+ if (SettingsPiwik::isMatomoInstalled() && defined('PHP_BINARY') && PHP_BINARY) {
+ $results[] = DiagnosticResult::informationalResult('PHP_BINARY', PHP_BINARY);
+ }
+ $results[] = DiagnosticResult::informationalResult('PHP SAPI', php_sapi_name());
+
+ if (SettingsPiwik::isMatomoInstalled()) {
+ $cliPhp = new CliPhp();
+ $binary = $cliPhp->findPhpBinary();
+ if (!empty($binary)) {
+ $binary = basename($binary);
+ $rows[] = array(
+ 'name' => 'PHP Found Binary',
+ 'value' => $binary,
+ );
+ }
+ }
+ $results[] = DiagnosticResult::informationalResult('PHP Timezone', date_default_timezone_get());
+ $results[] = DiagnosticResult::informationalResult('PHP Time', time());
+ $results[] = DiagnosticResult::informationalResult('PHP Datetime', Date::now()->getDatetime());
+
+ $disabled_functions = ini_get('disable_functions');
+ if (!empty($disabled_functions)) {
+ $results[] = DiagnosticResult::informationalResult('PHP Disabled functions', $disabled_functions);
+ }
+
+ foreach (['max_execution_time', 'post_max_size', 'max_input_vars', 'zlib.output_compression'] as $iniSetting) {
+ $results[] = DiagnosticResult::informationalResult('PHP INI ' . $iniSetting, @ini_get($iniSetting));
+ }
+
+ if (function_exists('curl_version')) {
+ $curl_version = curl_version();
+ $curl_version = $curl_version['version'] . ', ' . $curl_version['ssl_version'];
+ $results[] = DiagnosticResult::informationalResult('Curl Version', $curl_version);
+ }
+ $suhosin_installed = ( extension_loaded( 'suhosin' ) || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) );
+
+ $results[] = DiagnosticResult::informationalResult('Suhosin Installed', $suhosin_installed);
+
+ return $results;
+ }
+
+}
diff --git a/plugins/Diagnostics/Diagnostic/ReportInformational.php b/plugins/Diagnostics/Diagnostic/ReportInformational.php
new file mode 100644
index 0000000000..180dcf080c
--- /dev/null
+++ b/plugins/Diagnostics/Diagnostic/ReportInformational.php
@@ -0,0 +1,68 @@
+<?php
+/**
+ * Matomo - free/libre analytics platform
+ *
+ * @link https://matomo.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+namespace Piwik\Plugins\Diagnostics\Diagnostic;
+
+use Piwik\ArchiveProcessor\Rules;
+use Piwik\Common;
+use Piwik\CronArchive;
+use Piwik\Date;
+use Piwik\Db;
+use Piwik\Development;
+use Piwik\Option;
+use Piwik\Plugin\Manager;
+use Piwik\SettingsPiwik;
+use Piwik\Translation\Translator;
+
+/**
+ * Informatation about Matomo reports eg tracking or archiving related
+ */
+class ReportInformational implements Diagnostic
+{
+ /**
+ * @var Translator
+ */
+ private $translator;
+
+ public function __construct(Translator $translator)
+ {
+ $this->translator = $translator;
+ }
+
+ public function execute()
+ {
+ $results = [];
+
+ if (SettingsPiwik::isMatomoInstalled()) {
+ $results[] = DiagnosticResult::informationalResult('Had visits in last 1 day', $this->hadVisitsInLastDays(1));
+ $results[] = DiagnosticResult::informationalResult('Had visits in last 3 days', $this->hadVisitsInLastDays(3));
+ $results[] = DiagnosticResult::informationalResult('Had visits in last 5 days', $this->hadVisitsInLastDays(5));
+ $results[] = DiagnosticResult::informationalResult('Archive Time Last Started', Option::get(CronArchive::OPTION_ARCHIVING_STARTED_TS));
+ $results[] = DiagnosticResult::informationalResult('Archive Time Last Finished', Option::get(CronArchive::OPTION_ARCHIVING_FINISHED_TS));
+ }
+
+ return $results;
+ }
+
+ private function hadVisitsInLastDays($numDays)
+ {
+ $table = Common::prefixTable('log_visit');
+ $time = Date::now()->subDay($numDays)->getDatetime();
+
+ try {
+ $row = Db::fetchOne('SELECT idsite from ' . $table . ' where visit_last_action_time > ? LIMIT 1', $time );
+ } catch ( \Exception $e ) {
+ $row = null;
+ }
+
+ if (!empty($row)) {
+ return '1';
+ }
+ return '0';
+ }
+
+}
diff --git a/plugins/Diagnostics/Diagnostic/ServerInformational.php b/plugins/Diagnostics/Diagnostic/ServerInformational.php
new file mode 100644
index 0000000000..9a2478ab54
--- /dev/null
+++ b/plugins/Diagnostics/Diagnostic/ServerInformational.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Matomo - free/libre analytics platform
+ *
+ * @link https://matomo.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+namespace Piwik\Plugins\Diagnostics\Diagnostic;
+
+use Piwik\Translation\Translator;
+
+/**
+ * Informatation about the server.
+ */
+class ServerInformational implements Diagnostic
+{
+ /**
+ * @var Translator
+ */
+ private $translator;
+
+ public function __construct(Translator $translator)
+ {
+ $this->translator = $translator;
+ }
+
+ public function execute()
+ {
+ $results = [];
+
+ if ( ! empty( $_SERVER['SERVER_SOFTWARE'] ) ) {
+ $results[] = DiagnosticResult::informationalResult('Server Info', $_SERVER['SERVER_SOFTWARE']);
+ }
+
+ return $results;
+ }
+
+}
diff --git a/plugins/Diagnostics/Diagnostic/UserInformational.php b/plugins/Diagnostics/Diagnostic/UserInformational.php
new file mode 100644
index 0000000000..ff747d8004
--- /dev/null
+++ b/plugins/Diagnostics/Diagnostic/UserInformational.php
@@ -0,0 +1,41 @@
+<?php
+/**
+ * Matomo - free/libre analytics platform
+ *
+ * @link https://matomo.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+namespace Piwik\Plugins\Diagnostics\Diagnostic;
+
+use Piwik\Common;
+use Piwik\Translation\Translator;
+
+/**
+ * Information about the current user.
+ */
+class UserInformational implements Diagnostic
+{
+ /**
+ * @var Translator
+ */
+ private $translator;
+
+ public function __construct(Translator $translator)
+ {
+ $this->translator = $translator;
+ }
+
+ public function execute()
+ {
+ $results = [];
+
+ if (!empty($_SERVER['HTTP_USER_AGENT'])) {
+ $results[] = DiagnosticResult::informationalResult('User Agent', $_SERVER['HTTP_USER_AGENT']);
+ }
+
+ $results[] = DiagnosticResult::informationalResult('Browser Language', Common::getBrowserLanguage());
+
+ return $results;
+ }
+
+}
diff --git a/plugins/Diagnostics/DiagnosticReport.php b/plugins/Diagnostics/DiagnosticReport.php
index b9e6f8583f..fbc8fc8494 100644
--- a/plugins/Diagnostics/DiagnosticReport.php
+++ b/plugins/Diagnostics/DiagnosticReport.php
@@ -25,6 +25,11 @@ class DiagnosticReport
private $optionalDiagnosticResults;
/**
+ * @var DiagnosticResult[]
+ */
+ private $informationalResults;
+
+ /**
* @var int
*/
private $errorCount = 0;
@@ -37,11 +42,13 @@ class DiagnosticReport
/**
* @param DiagnosticResult[] $mandatoryDiagnosticResults
* @param DiagnosticResult[] $optionalDiagnosticResults
+ * @param DiagnosticResult[] $informationalResults
*/
- public function __construct(array $mandatoryDiagnosticResults, array $optionalDiagnosticResults)
+ public function __construct(array $mandatoryDiagnosticResults, array $optionalDiagnosticResults, array $informationalResults)
{
$this->mandatoryDiagnosticResults = $mandatoryDiagnosticResults;
$this->optionalDiagnosticResults = $optionalDiagnosticResults;
+ $this->informationalResults = $informationalResults;
$this->computeErrorAndWarningCount();
}
@@ -83,7 +90,7 @@ class DiagnosticReport
*/
public function getAllResults()
{
- return array_merge($this->mandatoryDiagnosticResults, $this->optionalDiagnosticResults);
+ return array_merge($this->mandatoryDiagnosticResults, $this->optionalDiagnosticResults, $this->informationalResults);
}
/**
@@ -102,6 +109,11 @@ class DiagnosticReport
return $this->optionalDiagnosticResults;
}
+ public function getInformationalResults()
+ {
+ return $this->informationalResults;
+ }
+
private function computeErrorAndWarningCount()
{
foreach ($this->getAllResults() as $result) {
diff --git a/plugins/Diagnostics/DiagnosticService.php b/plugins/Diagnostics/DiagnosticService.php
index 3f79895d19..1cc6f617c5 100644
--- a/plugins/Diagnostics/DiagnosticService.php
+++ b/plugins/Diagnostics/DiagnosticService.php
@@ -28,14 +28,20 @@ class DiagnosticService
private $optionalDiagnostics;
/**
+ * @var Diagnostic[]
+ */
+ private $informationDiagnostics;
+
+ /**
* @param Diagnostic[] $mandatoryDiagnostics
* @param Diagnostic[] $optionalDiagnostics
* @param Diagnostic[] $disabledDiagnostics
*/
- public function __construct(array $mandatoryDiagnostics, array $optionalDiagnostics, array $disabledDiagnostics)
+ public function __construct(array $mandatoryDiagnostics, array $optionalDiagnostics, array $informationDiagnostics, array $disabledDiagnostics)
{
$this->mandatoryDiagnostics = $this->removeDisabledDiagnostics($mandatoryDiagnostics, $disabledDiagnostics);
$this->optionalDiagnostics = $this->removeDisabledDiagnostics($optionalDiagnostics, $disabledDiagnostics);
+ $this->informationDiagnostics = $this->removeDisabledDiagnostics($informationDiagnostics, $disabledDiagnostics);
}
/**
@@ -45,7 +51,8 @@ class DiagnosticService
{
return new DiagnosticReport(
$this->run($this->mandatoryDiagnostics),
- $this->run($this->optionalDiagnostics)
+ $this->run($this->optionalDiagnostics),
+ $this->run($this->informationDiagnostics)
);
}
diff --git a/plugins/Diagnostics/config/config.php b/plugins/Diagnostics/config/config.php
index 3861c5c5a1..7e4c6e92b8 100644
--- a/plugins/Diagnostics/config/config.php
+++ b/plugins/Diagnostics/config/config.php
@@ -32,11 +32,20 @@ return array(
Di\get('Piwik\Plugins\Diagnostics\Diagnostic\DbMaxPacket'),
Di\get('Piwik\Plugins\Diagnostics\Diagnostic\ForceSSLCheck'),
),
+ 'diagnostics.informational' => array(
+ Di\get('Piwik\Plugins\Diagnostics\Diagnostic\MatomoInformational'),
+ Di\get('Piwik\Plugins\Diagnostics\Diagnostic\PhpInformational'),
+ Di\get('Piwik\Plugins\Diagnostics\Diagnostic\DatabaseInformational'),
+ Di\get('Piwik\Plugins\Diagnostics\Diagnostic\ConfigInformational'),
+ Di\get('Piwik\Plugins\Diagnostics\Diagnostic\ServerInformational'),
+ Di\get('Piwik\Plugins\Diagnostics\Diagnostic\ReportInformational'),
+ Di\get('Piwik\Plugins\Diagnostics\Diagnostic\UserInformational'),
+ ),
// Allows other plugins to disable diagnostics that were previously registered
'diagnostics.disabled' => array(),
'Piwik\Plugins\Diagnostics\DiagnosticService' => DI\object()
- ->constructor(DI\get('diagnostics.required'), DI\get('diagnostics.optional'), DI\get('diagnostics.disabled')),
+ ->constructor(DI\get('diagnostics.required'), DI\get('diagnostics.optional'), DI\get('diagnostics.informational'), DI\get('diagnostics.disabled')),
'Piwik\Plugins\Diagnostics\Diagnostic\MemoryLimitCheck' => DI\object()
->constructorParameter('minimumMemoryLimit', DI\get('ini.General.minimum_memory_limit')),
diff --git a/plugins/Diagnostics/tests/UI/expected-screenshots/Diagnostics_page.png b/plugins/Diagnostics/tests/UI/expected-screenshots/Diagnostics_page.png
index 8b9def895b..23ce03c696 100644
--- a/plugins/Diagnostics/tests/UI/expected-screenshots/Diagnostics_page.png
+++ b/plugins/Diagnostics/tests/UI/expected-screenshots/Diagnostics_page.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:ae828424520eb8ee480754a28cf9953aa15a1b1f113ea015dec1dbacccd5822c
-size 204592
+oid sha256:55c9f45c7f7e3ac6050a09f667a5c896dd5681f4fdd165f1ed5d1903ab73d572
+size 367395
diff --git a/plugins/Diagnostics/tests/Unit/DiagnosticReportTest.php b/plugins/Diagnostics/tests/Unit/DiagnosticReportTest.php
index e0bab192ab..008cd7a202 100644
--- a/plugins/Diagnostics/tests/Unit/DiagnosticReportTest.php
+++ b/plugins/Diagnostics/tests/Unit/DiagnosticReportTest.php
@@ -17,7 +17,8 @@ class DiagnosticReportTest extends \PHPUnit\Framework\TestCase
{
$report = new DiagnosticReport(
array(DiagnosticResult::singleResult('Error', DiagnosticResult::STATUS_ERROR, 'Comment')),
- array(DiagnosticResult::singleResult('Warning', DiagnosticResult::STATUS_WARNING, 'Comment'))
+ array(DiagnosticResult::singleResult('Warning', DiagnosticResult::STATUS_WARNING, 'Comment')),
+ array(DiagnosticResult::informationalResult('Test', 'Comment'))
);
$this->assertEquals(1, $report->getErrorCount());
@@ -25,7 +26,7 @@ class DiagnosticReportTest extends \PHPUnit\Framework\TestCase
$this->assertEquals(1, $report->getWarningCount());
$this->assertTrue($report->hasWarnings());
- $report = new DiagnosticReport(array(), array());
+ $report = new DiagnosticReport(array(), array(), array());
$this->assertEquals(0, $report->getErrorCount());
$this->assertFalse($report->hasErrors());
@@ -37,11 +38,13 @@ class DiagnosticReportTest extends \PHPUnit\Framework\TestCase
{
$report = new DiagnosticReport(
array(DiagnosticResult::singleResult('Error', DiagnosticResult::STATUS_ERROR, 'Comment')),
- array(DiagnosticResult::singleResult('Warning', DiagnosticResult::STATUS_WARNING, 'Comment'))
+ array(DiagnosticResult::singleResult('Warning', DiagnosticResult::STATUS_WARNING, 'Comment')),
+ array(DiagnosticResult::informationalResult('Test', 'Comment'))
);
$this->assertCount(1, $report->getMandatoryDiagnosticResults());
$this->assertCount(1, $report->getOptionalDiagnosticResults());
- $this->assertCount(2, $report->getAllResults());
+ $this->assertCount(1, $report->getInformationalResults());
+ $this->assertCount(3, $report->getAllResults());
}
}
diff --git a/plugins/Diagnostics/tests/Unit/DiagnosticServiceTest.php b/plugins/Diagnostics/tests/Unit/DiagnosticServiceTest.php
index 7fb979f5c3..9e8ec8e72c 100644
--- a/plugins/Diagnostics/tests/Unit/DiagnosticServiceTest.php
+++ b/plugins/Diagnostics/tests/Unit/DiagnosticServiceTest.php
@@ -25,8 +25,10 @@ class DiagnosticServiceTest extends \PHPUnit\Framework\TestCase
new DiagnosticWithWarning(),
new DiagnosticWithSuccess(),
);
+ $informationDiagnostics = array(
+ );
- $service = new DiagnosticService($mandatoryDiagnostics, $optionalDiagnostics, array());
+ $service = new DiagnosticService($mandatoryDiagnostics, $optionalDiagnostics, $informationDiagnostics, array());
$report = $service->runDiagnostics();
diff --git a/plugins/Installation/Controller.php b/plugins/Installation/Controller.php
index 2640efc26d..f6ff09a163 100644
--- a/plugins/Installation/Controller.php
+++ b/plugins/Installation/Controller.php
@@ -492,7 +492,6 @@ class Controller extends \Piwik\Plugin\ControllerAdmin
/** @var DiagnosticService $diagnosticService */
$diagnosticService = StaticContainer::get('Piwik\Plugins\Diagnostics\DiagnosticService');
$view->diagnosticReport = $diagnosticService->runDiagnostics();
-
return $view->render();
}
@@ -562,6 +561,11 @@ class Controller extends \Piwik\Plugin\ControllerAdmin
'plugins/Installation/javascripts/installation.js',
);
+ if (defined('PIWIK_TEST_MODE') && PIWIK_TEST_MODE
+ && file_exists(PIWIK_DOCUMENT_ROOT . '/tests/resources/screenshot-override/override.js')) {
+ $files[] = 'tests/resources/screenshot-override/override.js';
+ }
+
return AssetManager::compileCustomJs($files);
}
diff --git a/plugins/Installation/lang/en.json b/plugins/Installation/lang/en.json
index ffe9c33f2f..4b8e8c456e 100644
--- a/plugins/Installation/lang/en.json
+++ b/plugins/Installation/lang/en.json
@@ -22,6 +22,9 @@
"GoBackAndDefinePrefix": "Go back and define a Prefix for the Matomo Tables",
"HappyAnalysing": "Happy analysing!",
"Installation": "Installation",
+ "InformationalResults": "Informational results",
+ "CopyBelowInfoForSupport": "Copy the below info in case our support team asks you for this information",
+ "CopySystemCheck": "Copy system check",
"InstallationStatus": "Installation status",
"InsufficientPrivilegesHelp": "You can add these privileges by using a tool such as phpMyAdmin or by executing the right SQL queries. If you don't know how to do these things, please ask your sysadmin to grant these privileges for you.",
"InsufficientPrivilegesMain": "Either the Database does not exist (and could not be created), or the specified User has insufficient privileges. Database user must have the following privileges: %s",
diff --git a/plugins/Installation/templates/_systemCheckSection.twig b/plugins/Installation/templates/_systemCheckSection.twig
index 96e3fc3ae3..45ce316354 100644
--- a/plugins/Installation/templates/_systemCheckSection.twig
+++ b/plugins/Installation/templates/_systemCheckSection.twig
@@ -1,4 +1,39 @@
{% import _self as local %}
+<p>{{ 'Installation_CopyBelowInfoForSupport'|translate }}
+ <br/> <br/>
+ <a href="javascript:void(0);"
+ onclick="var textarea = document.getElementById('matomo_system_check_info');textarea.select();document.execCommand('copy');jQuery(textarea).effect('highlight', {}, 600)"
+ class='btn'>{{ 'Installation_CopySystemCheck'|translate }}</a>
+
+</p>
+{% macro diagnosticInfo(results) -%}
+{% set error = constant('Piwik\\Plugins\\Diagnostics\\Diagnostic\\DiagnosticResult::STATUS_ERROR') %}
+{% set warning = constant('Piwik\\Plugins\\Diagnostics\\Diagnostic\\DiagnosticResult::STATUS_WARNING') %}
+{% set informational = constant('Piwik\\Plugins\\Diagnostics\\Diagnostic\\DiagnosticResult::STATUS_INFORMATIONAL') %}
+{%- for result in results %}
+
+## {{ result.label -}}:
+{%- for item in result.items -%}
+{%- if item.status == error -%} &#9888; Error: {{ item.comment|anonymiseSystemInfo }}{% elseif item.status == warning %} &#9888; Warning: {{ item.comment|anonymiseSystemInfo }}{% elseif item.status == informational %} {{ item.comment|anonymiseSystemInfo }}{% else %} &#10004; {{ item.comment|anonymiseSystemInfo }}{% endif -%}
+{%- endfor %}
+
+
+{% if result.longErrorMessage -%}
+{{ result.longErrorMessage }}
+{%- endif -%}
+ {%- endfor -%}
+{%- endmacro %}
+<textarea style="width:100%;height: 200px;" readonly
+ id="matomo_system_check_info">
+# Mandatory checks
+{{ local.diagnosticInfo(diagnosticReport.getMandatoryDiagnosticResults()) }}
+
+# Optional checks
+{{ local.diagnosticInfo(diagnosticReport.getOptionalDiagnosticResults()) }}
+
+# Informational results
+{{ local.diagnosticInfo(diagnosticReport.getInformationalResults()) }}
+</textarea>
<table class="entityTable system-check" id="systemCheckRequired" piwik-content-table>
{{ local.diagnosticTable(diagnosticReport.getMandatoryDiagnosticResults()) }}
@@ -10,10 +45,17 @@
{{ local.diagnosticTable(diagnosticReport.getOptionalDiagnosticResults()) }}
</table>
+<h3>{{ 'Installation_InformationalResults'|translate }}</h3>
+
+<table class="entityTable system-check" id="systemCheckInformational" piwik-content-table>
+ {{ local.diagnosticTable(diagnosticReport.getInformationalResults()) }}
+</table>
+
{% macro diagnosticTable(results) %}
{% set error = constant('Piwik\\Plugins\\Diagnostics\\Diagnostic\\DiagnosticResult::STATUS_ERROR') %}
{% set warning = constant('Piwik\\Plugins\\Diagnostics\\Diagnostic\\DiagnosticResult::STATUS_WARNING') %}
+ {% set informational = constant('Piwik\\Plugins\\Diagnostics\\Diagnostic\\DiagnosticResult::STATUS_INFORMATIONAL') %}
{% set errorIcon %} <span class="icon-error"></span> {% endset %}
{% set warningIcon %} <span class="icon-warning"></span> {% endset %}
@@ -29,6 +71,8 @@
{{ errorIcon }} <span class="err">{{ item.comment|raw }}</span>
{% elseif item.status == warning %}
{{ warningIcon }} {{ item.comment|raw }}
+ {% elseif item.status == informational %}
+ {{ item.comment }}
{% else %}
{{ okIcon }} {{ item.comment|raw }}
{% endif %}
diff --git a/plugins/Installation/templates/systemCheckPage.twig b/plugins/Installation/templates/systemCheckPage.twig
index 86828b2de1..f4085e50a0 100644
--- a/plugins/Installation/templates/systemCheckPage.twig
+++ b/plugins/Installation/templates/systemCheckPage.twig
@@ -1,5 +1,4 @@
{% extends 'admin.twig' %}
-
{% set title %}{{ 'Installation_SystemCheck'|translate }}{% endset %}
{% block content %}
@@ -22,7 +21,7 @@
</div>
{% endif %}
- {% include "@Installation/_systemCheckSection.twig" %}
+ {% include "@Installation/_systemCheckSection.twig" %}
</div>
diff --git a/plugins/Installation/tests/UI/expected-screenshots/Installation_system_check.png b/plugins/Installation/tests/UI/expected-screenshots/Installation_system_check.png
index b1485cbc13..449d4a0cb0 100644
--- a/plugins/Installation/tests/UI/expected-screenshots/Installation_system_check.png
+++ b/plugins/Installation/tests/UI/expected-screenshots/Installation_system_check.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:448a85c4969fc1c9269cb14a5f0770088f3edf95bdcbc220e5ba1013ea81a45f
-size 186411
+oid sha256:6ab1eb67b5e67ed601d4a2de161a49b5b49c83e7b705542a5db189c386714311
+size 263125
diff --git a/plugins/Marketplace/tests/System/Api/ClientTest.php b/plugins/Marketplace/tests/System/Api/ClientTest.php
index 7d570b9d8b..788648bb3e 100644
--- a/plugins/Marketplace/tests/System/Api/ClientTest.php
+++ b/plugins/Marketplace/tests/System/Api/ClientTest.php
@@ -175,7 +175,7 @@ class ClientTest extends SystemTestCase
$this->assertLessThan(30, count($plugins));
foreach ($plugins as $plugin) {
- self::assertStringContainsString($keywords, $plugin['keywords']);
+ self::assertContains($keywords, $plugin['keywords']);
}
}
diff --git a/tests/resources/screenshot-override/override.js b/tests/resources/screenshot-override/override.js
index 5f142f3bbd..407cd23d34 100644
--- a/tests/resources/screenshot-override/override.js
+++ b/tests/resources/screenshot-override/override.js
@@ -1,4 +1,26 @@
$(document).ready(function () {
+
+ function updateSystemCheck() {
+ $('.system-check tr:contains(Time) td:nth-child(2)').text('Not showing in tests');
+ $('.system-check tr:contains(Datetime) td:nth-child(2)').text('Not showing in tests');
+ $('.system-check tr:contains(Version) td:nth-child(2)').text('Not showing in tests');
+ $('.system-check tr:contains(User Agent) td:nth-child(2)').text('Not showing in tests');
+ }
+ updateSystemCheck();
+
+ if (window.piwikHelper) {
+ var $timeout = piwikHelper.getAngularDependency('$timeout');
+ if ($timeout){
+ $timeout(function () {
+ // because of angular rendering replacing the content potentially...
+ updateSystemCheck();
+ $timeout(function () {
+ updateSystemCheck();
+ }, 100);
+ });
+ }
+ }
+
$('.ui-inline-help:contains(UTC time is)').hide();
$('[notification-id=ControllerAdmin_HttpIsUsed]').hide();