Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@googlemail.com>2014-09-07 21:16:08 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-09-07 21:16:08 +0400
commit5461654806b9a6fe99d21f22b2da075e286f8e20 (patch)
treea984b365abf944858de66e1a09bb71c0ef85c0ee /core/Plugin/Menu.php
parenta514151cec2613408412c6bbe0030df2c56b8277 (diff)
fixes #6153 check whether the defined module and action actually exists if development mode is enabled
Diffstat (limited to 'core/Plugin/Menu.php')
-rw-r--r--core/Plugin/Menu.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/core/Plugin/Menu.php b/core/Plugin/Menu.php
index b6892a79f2..6d2bdefccd 100644
--- a/core/Plugin/Menu.php
+++ b/core/Plugin/Menu.php
@@ -8,6 +8,7 @@
*/
namespace Piwik\Plugin;
+use Piwik\Development;
use Piwik\Menu\MenuAdmin;
use Piwik\Menu\MenuReporting;
use Piwik\Menu\MenuTop;
@@ -86,6 +87,8 @@ class Menu
*/
protected function urlForAction($controllerAction, $additionalParams = array())
{
+ $this->checkisValidCallable($this->module, $controllerAction);
+
$params = (array) $additionalParams;
$params['action'] = $controllerAction;
$params['module'] = $this->module;
@@ -110,6 +113,8 @@ class Menu
*/
protected function urlForModuleAction($module, $controllerAction, $additionalParams = array())
{
+ $this->checkisValidCallable($module, $controllerAction);
+
$pluginManager = PluginManager::getInstance();
if (!$pluginManager->isPluginLoaded($module) ||
@@ -156,4 +161,32 @@ class Menu
{
}
+ private function checkisValidCallable($module, $action)
+ {
+ if (!Development::isEnabled()) {
+ return;
+ }
+
+ $prefix = 'Menu item added in ' . get_class($this) . ' will fail when being selected. ';
+
+ if (!is_string($action)) {
+ Development::error($prefix . 'No valid action is specified. Make sure the defined action that should be executed is a string.');
+ }
+
+ $reportAction = lcfirst(substr($action, 4));
+ if (Report::factory($module, $reportAction)) {
+ return;
+ }
+
+ $controllerClass = '\\Piwik\\Plugins\\' . $module . '\\Controller';
+
+ if (!Development::methodExists($controllerClass, $action)) {
+ Development::error($prefix . 'The defined action "' . $action . '" does not exist in ' . $controllerClass . '". Make sure to define such a method.');
+ }
+
+ if (!Development::isCallableMethod($controllerClass, $action)) {
+ Development::error($prefix . 'The defined action "' . $action . '" is not callable on "' . $controllerClass . '". Make sure the method is public.');
+ }
+ }
+
}