From 6adf55495f00b75fc88bbcac3d4cae687e1039d1 Mon Sep 17 00:00:00 2001
From: Matthieu Aubry <mattab@users.noreply.github.com>
Date: Tue, 27 Dec 2016 16:18:11 +1300
Subject: [PATCH] fix WARNING:
 /home/piwik/htdocs/plugins/Referrers/Controller.php(422) Warning - Invalid
 argument supplied for foreach() (#11098)

Reported in https://forum.piwik.org/t/warning-message-plugins-referrers-controller-php-422-warning/22314
---
 plugins/Referrers/Controller.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/Referrers/Controller.php b/plugins/Referrers/Controller.php
index 4554acd35a..7f3d2079cb 100644
--- a/plugins/Referrers/Controller.php
+++ b/plugins/Referrers/Controller.php
@@ -410,7 +410,7 @@ function DisplayTopKeywords($url = "")
             $api = $api . "&url=" . urlencode($url);
             $keywords = @json_decode(file_get_contents($api), $assoc = true);
             Common::sendHeader('Content-Type: text/html; charset=utf-8', true);
-            if ($keywords === false || isset($keywords["result"])) {
+            if ($keywords === false || isset($keywords["result"]) || !is_array($keywords)) {
                 // DEBUG ONLY: uncomment for troubleshooting an empty output (the URL output reveals the token_auth)
                 //echo "Error while fetching the <a href=\'".$api."\'>Top Keywords from Piwik</a>";
                 return;
-- 
GitLab