Skip to content

Commit

Permalink
Fix a couple a possible warning in PHP 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Aug 10, 2021
1 parent 1c287f1 commit 74a6b6c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function reloadAccess(Auth $auth = null)
$forceApiSessionGet = Common::getRequestVar('force_api_session', 0, 'int', $_GET);
$isApiRequest = Piwik::getModule() === 'API' && (Piwik::getAction() === 'index' || !Piwik::getAction());
$apiMethod = Request::getMethodIfApiRequest(null);
$isGetApiRequest = 1 === substr_count($apiMethod, '.') && strpos($apiMethod, '.get') > 0;
$isGetApiRequest = !empty($apiMethod) && 1 === substr_count($apiMethod, '.') && strpos($apiMethod, '.get') > 0;

if (($forceApiSessionPost && $isApiRequest) || ($forceApiSessionGet && $isApiRequest && $isGetApiRequest)) {
$request = ($forceApiSessionGet && $isApiRequest && $isGetApiRequest) ? $_GET : $_POST;
Expand Down
2 changes: 1 addition & 1 deletion core/AssetManager/UIAssetCacheBuster.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function piwikVersionBasedCacheBuster($pluginNames = false)
if (empty($cachedCacheBuster) || $pluginNames !== false) {

$masterFile = PIWIK_INCLUDE_PATH . '/.git/refs/heads/master';
$currentGitHash = file_exists($masterFile) ? @file_get_contents($masterFile) : null;
$currentGitHash = file_exists($masterFile) ? @file_get_contents($masterFile) : '';
$manager = Manager::getInstance();

$plugins = !$pluginNames ? $manager->getActivatedPlugins() : $pluginNames;
Expand Down
2 changes: 1 addition & 1 deletion plugins/GeoIp2/LocationProvider/GeoIp2/Php.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ protected function setCityResults($lookupResult, &$result)
if (is_array($lookupResult->subdivisions) && count($lookupResult->subdivisions) > 0) {
$subdivisions = $lookupResult->subdivisions;
$subdivision = $this->determinSubdivision($subdivisions, $result[self::COUNTRY_CODE_KEY]);
$result[self::REGION_CODE_KEY] = strtoupper($subdivision->isoCode) ?: $this->determineRegionIsoCodeByNameAndCountryCode($subdivision->name, $result[self::COUNTRY_CODE_KEY]);
$result[self::REGION_CODE_KEY] = $subdivision->isoCode ? strtoupper($subdivision->isoCode) : $this->determineRegionIsoCodeByNameAndCountryCode($subdivision->name, $result[self::COUNTRY_CODE_KEY]);
$result[self::REGION_NAME_KEY] = $subdivision->name;
}
}
Expand Down
6 changes: 3 additions & 3 deletions plugins/Referrers/Columns/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ protected function detectReferrerSocialNetwork()
protected function detectCampaignFromString($string)
{
foreach ($this->campaignNames as $campaignNameParameter) {
$campaignName = trim(urldecode(UrlHelper::getParameterFromQueryString($string, $campaignNameParameter)));
$campaignName = trim(urldecode(UrlHelper::getParameterFromQueryString($string, $campaignNameParameter) ?? ''));
if (!empty($campaignName)) {
break;
}
Expand Down Expand Up @@ -496,7 +496,7 @@ protected function detectReferrerCampaign(Request $request, Visitor $visitor)
$referrerNameAnalayzed = mb_strtolower($this->nameReferrerAnalyzed);
$referrerNameAnalayzed = $this->truncateReferrerName($referrerNameAnalayzed);

$isCurrentVisitACampaignWithSameName = mb_strtolower($visitor->getVisitorColumn('referer_name')) == $referrerNameAnalayzed;
$isCurrentVisitACampaignWithSameName = mb_strtolower($visitor->getVisitorColumn('referer_name') ?? '') == $referrerNameAnalayzed;
$isCurrentVisitACampaignWithSameName = $isCurrentVisitACampaignWithSameName && $visitor->getVisitorColumn('referer_type') == Common::REFERRER_TYPE_CAMPAIGN;

// if we detected a campaign but there is still no keyword set, we set the keyword to the Referrer host
Expand Down Expand Up @@ -632,7 +632,7 @@ protected function isReferrerInformationNew(Visitor $visitor, $information)

protected function hasReferrerColumnChanged(Visitor $visitor, $information, $infoName)
{
$existing = mb_strtolower($visitor->getVisitorColumn($infoName));
$existing = mb_strtolower($visitor->getVisitorColumn($infoName) ?? '');
$new = mb_strtolower($information[$infoName]);

$result = $existing != $new;
Expand Down
2 changes: 1 addition & 1 deletion plugins/Referrers/SearchEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public function extractInformationFromUrl($referrerUrl)
} else {
// search for keywords now &vname=keyword
$key = UrlHelper::getParameterFromQueryString($query, $variableName);
$key = trim(urldecode($key));
$key = trim(urldecode($key ?? ''));

// Special cases: empty keywords
if (empty($key)
Expand Down

0 comments on commit 74a6b6c

Please sign in to comment.