Skip to content
Permalink
Browse files

Don't allow overridden methods to count as actions.

Disallow overridden methods from being actions. While you could override
the signatures and disable strict warnings. I feel that's a bad practice
to enable and the defaults provided by the framework should be as safe
as possible.
  • Loading branch information...
markstory committed Aug 11, 2015
1 parent 123d0c6 commit 2a99ba90951195ce2f74d0c1565ccfd1d9079452
Showing with 14 additions and 3 deletions.
  1. +5 −3 src/Controller/Controller.php
  2. +9 −0 tests/TestCase/Controller/ControllerTest.php
@@ -28,6 +28,7 @@
use Cake\Utility\MergeVariablesTrait;
use Cake\View\ViewVarsTrait;
use LogicException;
use ReflectionClass;
use ReflectionException;
use ReflectionMethod;
use RuntimeException;
@@ -653,6 +654,10 @@ public function paginate($object = null)
*/
public function isAction($action)
{
$baseClass = new ReflectionClass('Cake\Controller\Controller');
if ($baseClass->hasMethod($action)) {
return false;
}
try {
$method = new ReflectionMethod($this, $action);
} catch (ReflectionException $e) {
@@ -661,9 +666,6 @@ public function isAction($action)
if (!$method->isPublic()) {
return false;
}
if ($method->getDeclaringClass()->name === 'Cake\Controller\Controller') {
return false;
}
return true;
}
@@ -86,6 +86,15 @@ class TestController extends ControllerTestAppController
*/
public $modelClass = 'Comments';
/**
* beforeFilter handler
*
* @param \Cake\Event\Event $event
* @retun void
*/
public function beforeFilter(Event $event) {
}
/**
* index method
*

0 comments on commit 2a99ba9

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.