diff options
-rw-r--r-- | core/Period/Factory.php | 2 | ||||
-rw-r--r-- | plugins/API/API.php | 4 | ||||
-rw-r--r-- | plugins/ExampleAPI/API.php | 4 | ||||
-rw-r--r-- | plugins/ImageGraph/API.php | 2 |
4 files changed, 11 insertions, 1 deletions
diff --git a/core/Period/Factory.php b/core/Period/Factory.php index ee6fd3b7c9..5f7836dee0 100644 --- a/core/Period/Factory.php +++ b/core/Period/Factory.php @@ -80,7 +80,7 @@ abstract class Factory } $dateObject = Date::factory($date); - } else if (!empty($date)) { + } else if ($date instanceof Date) { $dateObject = $date; } else { throw new \Exception("Invalid date supplied to Period\Factory::build(): " . gettype($date)); diff --git a/plugins/API/API.php b/plugins/API/API.php index fa913d887f..6f968a3efe 100644 --- a/plugins/API/API.php +++ b/plugins/API/API.php @@ -449,6 +449,10 @@ class API extends \Piwik\Plugin\API */ public function getRowEvolution($idSite, $period, $date, $apiModule, $apiAction, $label = false, $segment = false, $column = false, $language = false, $idGoal = false, $legendAppendMetric = true, $labelUseAbsoluteUrl = true, $idDimension = false) { + // check if site exists + $idSite = (int) $idSite; + $site = new Site($idSite); + Piwik::checkUserHasViewAccess($idSite); $apiParameters = array(); diff --git a/plugins/ExampleAPI/API.php b/plugins/ExampleAPI/API.php index d508011d3f..6435de7e9a 100644 --- a/plugins/ExampleAPI/API.php +++ b/plugins/ExampleAPI/API.php @@ -76,6 +76,10 @@ class API extends \Piwik\Plugin\API */ public function getSum($a = 0, $b = 0) { + if (!is_numeric($a) || !is_numeric($b)) { + throw new \Exception('Given parameters need to be numeric'); + } + return (float)($a + $b); } diff --git a/plugins/ImageGraph/API.php b/plugins/ImageGraph/API.php index fc7f818fc4..0f14e93e97 100644 --- a/plugins/ImageGraph/API.php +++ b/plugins/ImageGraph/API.php @@ -126,6 +126,8 @@ class API extends \Piwik\Plugin\API $idDimension = false ) { + $idSite = (int) $idSite; + Piwik::checkUserHasViewAccess($idSite); // Health check - should we also test for GD2 only? |