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>2019-07-23 02:21:00 +0300
committerGitHub <noreply@github.com>2019-07-23 02:21:00 +0300
commita50080b1814d0620978499e5421fffe5313433f6 (patch)
tree16e59dc9be45fd11778379df45314f0af751f602 /plugins/Diagnostics
parent7faea0438eee8085fc15aa118fa166fa8ab60bab (diff)
start working on db reader support (#14681)
Diffstat (limited to 'plugins/Diagnostics')
-rw-r--r--plugins/Diagnostics/ConfigReader.php2
-rw-r--r--plugins/Diagnostics/Diagnostic/DbReaderCheck.php56
-rw-r--r--plugins/Diagnostics/config/config.php1
-rw-r--r--plugins/Diagnostics/lang/en.json1
4 files changed, 59 insertions, 1 deletions
diff --git a/plugins/Diagnostics/ConfigReader.php b/plugins/Diagnostics/ConfigReader.php
index cc96b560b9..9f98ab94cb 100644
--- a/plugins/Diagnostics/ConfigReader.php
+++ b/plugins/Diagnostics/ConfigReader.php
@@ -88,7 +88,7 @@ class ConfigReader
private function shouldSkipCategory($category)
{
$category = strtolower($category);
- if ($category === 'database') {
+ if ($category === 'database' || $category === 'database_reader') {
return true;
}
diff --git a/plugins/Diagnostics/Diagnostic/DbReaderCheck.php b/plugins/Diagnostics/Diagnostic/DbReaderCheck.php
new file mode 100644
index 0000000000..faffb662ba
--- /dev/null
+++ b/plugins/Diagnostics/Diagnostic/DbReaderCheck.php
@@ -0,0 +1,56 @@
+<?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\Piwik;
+use Piwik\Translation\Translator;
+
+/**
+ * Check if Piwik can use LOAD DATA INFILE.
+ */
+class DbReaderCheck implements Diagnostic
+{
+ /**
+ * @var Translator
+ */
+ private $translator;
+
+ public function __construct(Translator $translator)
+ {
+ $this->translator = $translator;
+ }
+
+ public function execute()
+ {
+ $isPiwikInstalling = !Config::getInstance()->existsLocalConfig();
+ if ($isPiwikInstalling) {
+ // Skip the diagnostic if Piwik is being installed
+ return array();
+ }
+
+ if (!Db::hasReaderConfigured()) {
+ // only show an entry when reader is actually configured
+ return array();
+ }
+
+ $label = $this->translator->translate('Diagnostics_DatabaseReaderConnection');
+
+ try {
+ Db::getReader();
+ return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK, ''));
+ } catch (\Exception $e) {
+
+ }
+
+ $comment = Piwik::translate('Installation_CannotConnectToDb');
+ return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
+ }
+}
diff --git a/plugins/Diagnostics/config/config.php b/plugins/Diagnostics/config/config.php
index b450de958a..3bf076e014 100644
--- a/plugins/Diagnostics/config/config.php
+++ b/plugins/Diagnostics/config/config.php
@@ -7,6 +7,7 @@ return array(
'diagnostics.required' => array(
DI\get('Piwik\Plugins\Diagnostics\Diagnostic\PhpVersionCheck'),
DI\get('Piwik\Plugins\Diagnostics\Diagnostic\DbAdapterCheck'),
+ DI\get('Piwik\Plugins\Diagnostics\Diagnostic\DbReaderCheck'),
DI\get('Piwik\Plugins\Diagnostics\Diagnostic\PhpExtensionsCheck'),
DI\get('Piwik\Plugins\Diagnostics\Diagnostic\PhpFunctionsCheck'),
DI\get('Piwik\Plugins\Diagnostics\Diagnostic\PhpSettingsCheck'),
diff --git a/plugins/Diagnostics/lang/en.json b/plugins/Diagnostics/lang/en.json
index bd553c2515..c3638dfcb7 100644
--- a/plugins/Diagnostics/lang/en.json
+++ b/plugins/Diagnostics/lang/en.json
@@ -6,6 +6,7 @@
"ConfigFileIntroduction": "Here you can view the Matomo configuration. If you are running Matomo in a load balanced environment, the page might be different depending on from which server this page is loaded. Rows with a different background color are changed config values that are specified for example in the %1$s file.",
"HideUnchanged": "If you want to see only changed values you can %1$shide all unchanged values%2$s.",
"Sections": "Sections",
+ "DatabaseReaderConnection": "Database Reader Connection",
"CronArchivingLastRunCheck": "Last Successful Archiving Completion",
"CronArchivingHasNotRun": "Archiving has not yet run successfully.",
"CronArchivingHasNotRunInAWhile": "Archiving last ran successfully on %1$s which is %2$s ago.",