fixes #6117, wrong controller name in debug messages

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8042 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2009-02-17 23:32:15 +00:00
parent 9217a85281
commit b62202f888
2 changed files with 93 additions and 49 deletions

View file

@ -128,14 +128,12 @@ class Dispatcher extends Object {
if (!is_object($controller)) {
Router::setRequestInfo(array($this->params, array('base' => $this->base, 'webroot' => $this->webroot)));
return $this->cakeError('missingController', array(
array(
'className' => Inflector::camelize($this->params['controller']) . 'Controller',
'webroot' => $this->webroot,
'url' => $url,
'base' => $this->base
)
));
return $this->cakeError('missingController', array(array(
'className' => Inflector::camelize($this->params['controller']) . 'Controller',
'webroot' => $this->webroot,
'url' => $url,
'base' => $this->base
)));
}
$privateAction = (bool)(strpos($this->params['action'], '_', 0) === 0);
@ -155,15 +153,13 @@ class Dispatcher extends Object {
));
if ($privateAction) {
return $this->cakeError('privateAction', array(
array(
'className' => Inflector::camelize($this->params['controller'] . "Controller"),
'action' => $this->params['action'],
'webroot' => $this->webroot,
'url' => $url,
'base' => $this->base
)
));
return $this->cakeError('privateAction', array(array(
'className' => Inflector::camelize($this->params['controller'] . "Controller"),
'action' => $this->params['action'],
'webroot' => $this->webroot,
'url' => $url,
'base' => $this->base
)));
}
$controller->base = $this->base;
@ -179,15 +175,12 @@ class Dispatcher extends Object {
} else {
$controller->data = null;
}
if (array_key_exists('return', $this->params) && $this->params['return'] == 1) {
$controller->autoRender = false;
}
if (!empty($this->params['bare'])) {
$controller->autoLayout = false;
}
if (array_key_exists('layout', $this->params)) {
if (empty($this->params['layout'])) {
$controller->autoLayout = false;
@ -195,11 +188,9 @@ class Dispatcher extends Object {
$controller->layout = $this->params['layout'];
}
}
if (isset($this->params['viewPath'])) {
$controller->viewPath = $this->params['viewPath'];
}
return $this->_invoke($controller, $this->params);
}
/**
@ -225,14 +216,13 @@ class Dispatcher extends Object {
App::import('Core', 'Scaffold');
return new Scaffold($controller, $params);
}
return $this->cakeError('missingAction', array(
array(
'className' => Inflector::camelize($params['controller']."Controller"),
'action' => $params['action'],
'webroot' => $this->webroot,
'url' => $this->here,
'base' => $this->base)));
return $this->cakeError('missingAction', array(array(
'className' => Inflector::camelize($params['controller']."Controller"),
'action' => $params['action'],
'webroot' => $this->webroot,
'url' => $this->here,
'base' => $this->base
)));
}
$output = $controller->dispatchMethod($params['action'], $params['pass']);
@ -432,7 +422,7 @@ class Dispatcher extends Object {
*/
function &__getController($params = null) {
if (!is_array($params)) {
$params = $this->params;
$original = $params = $this->params;
}
$controller = false;
$ctrlClass = $this->__loadController($params);
@ -440,13 +430,14 @@ class Dispatcher extends Object {
if (!isset($params['plugin'])) {
$params = $this->_restructureParams($params);
} else {
if (empty($this->params['pass']) && $params['action'] == 'index') {
if (empty($original['pass']) && $original['action'] == 'index') {
$params['action'] = null;
}
$params = $this->_restructureParams($params, true);
}
$ctrlClass = $this->__loadController($params);
if (!$ctrlClass) {
$this->params = $original;
return $controller;
}
} else {
@ -512,11 +503,9 @@ class Dispatcher extends Object {
if ($base) {
$uri = preg_replace('/^(?:\/)?(?:' . preg_quote($base, '/') . ')?(?:url=)?/', '', $uri);
}
if (PHP_SAPI == 'isapi') {
$uri = preg_replace('/^(?:\/)?(?:\/)?(?:\?)?(?:url=)?/', '', $uri);
}
if (!empty($uri)) {
if (key($_GET) && strpos(key($_GET), '?') !== false) {
unset($_GET[key($_GET)]);
@ -530,11 +519,9 @@ class Dispatcher extends Object {
} elseif (empty($uri) && is_string(env('QUERY_STRING'))) {
$uri = env('QUERY_STRING');
}
if (strpos($uri, 'index.php') !== false) {
list(, $uri) = explode('index.php', $uri, 2);
}
if (empty($uri) || $uri == '/' || $uri == '//') {
return '';
}
@ -553,7 +540,6 @@ class Dispatcher extends Object {
if ($uri == null) {
$uri = $this->uri();
}
if ($base == null) {
$base = $this->base;
}
@ -586,7 +572,6 @@ class Dispatcher extends Object {
} else {
$url = $_GET['url'];
}
if ($url{0} == '/') {
$url = substr($url, 1);
}

View file

@ -45,7 +45,7 @@ class TestDispatcher extends Dispatcher {
function _invoke(&$controller, $params) {
restore_error_handler();
if ($result = parent::_invoke($controller, $params)) {
if ($result === 'missingAction') {
if ($result[0] === 'missingAction') {
return $result;
}
}
@ -60,8 +60,8 @@ class TestDispatcher extends Dispatcher {
* @access public
* @return void
*/
function cakeError($filename) {
return $filename;
function cakeError($filename, $params) {
return array($filename, $params);
}
/**
* _stop method
@ -1111,8 +1111,12 @@ class DispatcherTest extends CakeTestCase {
Configure::write('App.baseUrl','/index.php');
$url = 'some_controller/home/param:value/param2:value2';
$controller = $Dispatcher->dispatch($url, array('return' => 1));
$expected = 'missingController';
$expected = array('missingController', array(array(
'className' => 'SomeControllerController',
'webroot' => '/app/webroot/',
'url' => 'some_controller/home/param:value/param2:value2',
'base' => '/index.php'
)));
$this->assertEqual($expected, $controller);
}
/**
@ -1125,9 +1129,16 @@ class DispatcherTest extends CakeTestCase {
$Dispatcher =& new TestDispatcher();
Configure::write('App.baseUrl','/index.php');
$url = 'some_pages/_protected/param:value/param2:value2';
$controller = $Dispatcher->dispatch($url, array('return' => 1));
$expected = 'privateAction';
$expected = array('privateAction', array(array(
'className' => 'SomePagesController',
'action' => '_protected',
'webroot' => '/app/webroot/',
'url' => 'some_pages/_protected/param:value/param2:value2',
'base' => '/index.php'
)));
$this->assertEqual($controller, $expected);
}
/**
@ -1142,7 +1153,14 @@ class DispatcherTest extends CakeTestCase {
$url = 'some_pages/home/param:value/param2:value2';
$controller = $Dispatcher->dispatch($url, array('return'=> 1));
$expected = 'missingAction';
$expected = array('missingAction', array(array(
'className' => 'SomePagesController',
'action' => 'home',
'webroot' => '/app/webroot/',
'url' => '/index.php/some_pages/home/param:value/param2:value2',
'base' => '/index.php'
)));
$this->assertEqual($expected, $controller);
$Dispatcher =& new TestDispatcher();
@ -1150,7 +1168,14 @@ class DispatcherTest extends CakeTestCase {
$url = 'some_pages/redirect/param:value/param2:value2';
$controller = $Dispatcher->dispatch($url, array('return'=> 1));
$expected = 'missingAction';
$expected = array('missingAction', array(array(
'className' => 'SomePagesController',
'action' => 'redirect',
'webroot' => '/app/webroot/',
'url' => '/index.php/some_pages/redirect/param:value/param2:value2',
'base' => '/index.php'
)));
$this->assertEqual($expected, $controller);
}
/**
@ -1485,10 +1510,32 @@ class DispatcherTest extends CakeTestCase {
$Dispatcher =& new TestDispatcher();
$Dispatcher->base = false;
$url = 'my_plugin/not_here/param:value/param2:value2';
$controller = $Dispatcher->dispatch($url, array('return'=> 1));
$expected = array('missingAction', array(array(
'className' => 'MyPluginController',
'action' => 'not_here',
'webroot' => '/cake/repo/branches/1.2.x.x/',
'url' => '/cake/repo/branches/1.2.x.x/my_plugin/not_here/param:value/param2:value2',
'base' => '/cake/repo/branches/1.2.x.x'
)));
$this->assertIdentical($expected, $controller);
Router::reload();
$Dispatcher =& new TestDispatcher();
$Dispatcher->base = false;
$url = 'my_plugin/param:value/param2:value2';
$controller = $Dispatcher->dispatch($url, array('return'=> 1));
$expected = 'missingAction';
$expected = array('missingAction', array(array(
'className' => 'MyPluginController',
'action' => 'param:value',
'webroot' => '/cake/repo/branches/1.2.x.x/',
'url' => '/cake/repo/branches/1.2.x.x/my_plugin/param:value/param2:value2',
'base' => '/cake/repo/branches/1.2.x.x'
)));
$this->assertIdentical($expected, $controller);
}
/**
@ -1510,7 +1557,13 @@ class DispatcherTest extends CakeTestCase {
$url = 'test_dispatch_pages/admin_index/param:value/param2:value2';
$controller = $Dispatcher->dispatch($url, array('return' => 1));
$expected = 'privateAction';
$expected = array('privateAction', array(array(
'className' => 'TestDispatchPagesController',
'action' => 'admin_index',
'webroot' => '/cake/repo/branches/1.2.x.x/',
'url' => 'test_dispatch_pages/admin_index/param:value/param2:value2',
'base' => '/cake/repo/branches/1.2.x.x'
)));
$this->assertIdentical($expected, $controller);
}
/**
@ -1542,7 +1595,13 @@ class DispatcherTest extends CakeTestCase {
$url = 'some_posts/index/param:value/param2:value2';
$controller = $Dispatcher->dispatch($url, array('return' => 1));
$expected = 'missingAction';
$expected = array('missingAction', array(array(
'className' => 'SomePostsController',
'action' => 'view',
'webroot' => '/cake/repo/branches/1.2.x.x/',
'url' => '/cake/repo/branches/1.2.x.x/some_posts/index/param:value/param2:value2',
'base' => '/cake/repo/branches/1.2.x.x'
)));
$this->assertEqual($expected, $controller);
$url = 'some_posts/something_else/param:value/param2:value2';