diff options
author | diosmosis <benaka@piwik.pro> | 2015-09-11 05:44:12 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-09-15 02:39:40 +0300 |
commit | 5d75341e2c37dfbf93e2fea7c5e0bf0c74e038e2 (patch) | |
tree | 27fbfe16439b73ef7ffd96b0c72d37bb5dc303b8 /plugins/API | |
parent | c5b9769dcfe356dfd6bc754482856faa840e729a (diff) |
Fix regression, in API\API::doesSuggestedValuesCallbackNeedData() handle methods and free functions.
Diffstat (limited to 'plugins/API')
-rw-r--r-- | plugins/API/API.php | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/plugins/API/API.php b/plugins/API/API.php index 3bc1b3baef..72411c21be 100644 --- a/plugins/API/API.php +++ b/plugins/API/API.php @@ -592,9 +592,19 @@ class API extends \Piwik\Plugin\API private function doesSuggestedValuesCallbackNeedData($suggestedValuesCallback) { - $methodMetadata = new \ReflectionFunction($suggestedValuesCallback); - $parametersCount = $methodMetadata->getNumberOfParameters(); - return $parametersCount >= 3; + if (is_string($suggestedValuesCallback) + && strpos($suggestedValuesCallback, '::') !== false + ) { + $suggestedValuesCallback = explode('::', $suggestedValuesCallback); + } + + if (is_array($suggestedValuesCallback)) { + $methodMetadata = new \ReflectionMethod($suggestedValuesCallback[0], $suggestedValuesCallback[1]); + } else { + $methodMetadata = new \ReflectionFunction($suggestedValuesCallback); + } + + return $methodMetadata->getNumberOfParameters() >= 3; } } |