diff options
author | Stefan Giehl <stefan@matomo.org> | 2022-07-25 11:52:26 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-25 11:52:26 +0300 |
commit | 064f6db3b8f8534e9aaaf881168017bac5fcb6cf (patch) | |
tree | 2a5d65ace231e95a40fef942201d818327807881 | |
parent | 914d48f4f6817175404f27414eaf1158c7123ac7 (diff) |
Fix possible notices / code improvements (#19561)
* Improve reading possibly undefined config value
* Improve reading possibly undefined config value
* remove another error suppression
-rw-r--r-- | core/Plugin/Report.php | 2 | ||||
-rw-r--r-- | core/SettingsPiwik.php | 10 | ||||
-rw-r--r-- | plugins/Actions/DataTable/Filter/Actions.php | 12 |
3 files changed, 13 insertions, 11 deletions
diff --git a/core/Plugin/Report.php b/core/Plugin/Report.php index bf77e75f62..2fb4f14f18 100644 --- a/core/Plugin/Report.php +++ b/core/Plugin/Report.php @@ -921,7 +921,7 @@ class Report $translation = $metric->getTranslatedName(); } else { $metricName = $metric; - $translation = @$translations[$metric]; + $translation = $translations[$metric] ?? null; } $metrics[$metricName] = $translation ?: $metricName; diff --git a/core/SettingsPiwik.php b/core/SettingsPiwik.php index a78f0a84c5..9edbec35cc 100644 --- a/core/SettingsPiwik.php +++ b/core/SettingsPiwik.php @@ -10,6 +10,7 @@ namespace Piwik; use Exception; use Piwik\Cache as PiwikCache; +use Piwik\Config\GeneralConfig; use Piwik\Container\StaticContainer; /** @@ -467,9 +468,8 @@ class SettingsPiwik */ public static function getPiwikInstanceId() { - // until Piwik is installed, we use hostname as instance_id - if (!self::isMatomoInstalled() - && Common::isPhpCliMode()) { + // until Matomo is installed, we use hostname as instance_id + if (!self::isMatomoInstalled() && Common::isPhpCliMode()) { // enterprise:install use case return Config::getHostname(); } @@ -479,12 +479,12 @@ class SettingsPiwik return false; } - $instanceId = @Config::getInstance()->General['instance_id']; + $instanceId = GeneralConfig::getConfigValue('instance_id'); if (!empty($instanceId)) { return $instanceId; } - // do not rewrite the path as Piwik uses the standard config.ini.php file + // do not rewrite the path as Matomo uses the standard config.ini.php file return false; } diff --git a/plugins/Actions/DataTable/Filter/Actions.php b/plugins/Actions/DataTable/Filter/Actions.php index fe0130b276..c2196bae27 100644 --- a/plugins/Actions/DataTable/Filter/Actions.php +++ b/plugins/Actions/DataTable/Filter/Actions.php @@ -1,4 +1,5 @@ <?php + /** * Matomo - free/libre analytics platform * @@ -6,10 +7,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later * */ + namespace Piwik\Plugins\Actions\DataTable\Filter; use Piwik\Common; -use Piwik\Config; +use Piwik\Config\GeneralConfig; use Piwik\DataTable\BaseFilter; use Piwik\DataTable; use Piwik\Plugins\Actions\ArchivingHelper; @@ -41,17 +43,17 @@ class Actions extends BaseFilter $site = $dataTable->getMetadata('site'); $urlPrefix = $site ? $site->getMainUrl() : null; - $defaultActionName = Config::getInstance()->General['action_default_name']; + $defaultActionName = GeneralConfig::getConfigValue('action_default_name'); $isPageTitleType = $this->actionType == Action::TYPE_PAGE_TITLE; // for BC, we read the old style delimiter first (see #1067) - $actionDelimiter = @Config::getInstance()->General['action_category_delimiter']; + $actionDelimiter = GeneralConfig::getConfigValue('action_category_delimiter'); if (empty($actionDelimiter)) { if ($isPageTitleType) { - $actionDelimiter = Config::getInstance()->General['action_title_category_delimiter']; + $actionDelimiter = GeneralConfig::getConfigValue('action_title_category_delimiter'); } else { - $actionDelimiter = Config::getInstance()->General['action_url_category_delimiter']; + $actionDelimiter = GeneralConfig::getConfigValue('action_url_category_delimiter'); } } |