Skip to content
This repository
Browse code

Fixing issue in Router where generating plugin shortcut controller ro…

…utes with admin prefixes left a :controller param behind. Fixes #6252

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8235 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
commit 74fd4849ba8e37ed7974a02bf7b9b40761ea7531 1 parent 76d5855
Mark Story authored July 17, 2009
2  cake/libs/router.php
@@ -1082,7 +1082,7 @@ function __mapRoute($route, $params = array()) {
1082 1082
 			if (isset($params[$key])) {
1083 1083
 				$string = $params[$key];
1084 1084
 				unset($params[$key]);
1085  
-			} else {
  1085
+			} elseif (strpos($out, $key) != strlen($out) - strlen($key)) {
1086 1086
 				$key = $key . '/';
1087 1087
 			}
1088 1088
 			$out = str_replace(':' . $key, $string, $out);
22  cake/tests/cases/libs/router.test.php
@@ -1036,6 +1036,28 @@ function testAdminRouting() {
1036 1036
 		$result = Router::url(array('controller' => 'posts', 'action' => 'index', '0', '?' => 'var=test&var2=test2'));
1037 1037
 		$expected = '/beheer/posts/index/0?var=test&var2=test2';
1038 1038
 		$this->assertEqual($result, $expected);
  1039
+
  1040
+		Configure::write('Routing.admin', 'admin');
  1041
+		$paths = Configure::read('pluginPaths');
  1042
+		Configure::write('pluginPaths', array(
  1043
+			TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
  1044
+		));
  1045
+		Configure::write('__objects.plugin', array('test_plugin'));
  1046
+
  1047
+		Router::reload();
  1048
+		Router::setRequestInfo(array(
  1049
+			array('admin' => true, 'controller' => 'controller', 'action' => 'action', 
  1050
+				'form' => array(), 'url' => array(), 'plugin' => null),
  1051
+			array('base' => '/', 'here' => '/', 'webroot' => '/base/', 'passedArgs' => array(), 
  1052
+				'argSeparator' => ':', 'namedArgs' => array())
  1053
+		));
  1054
+		Router::parse('/');
  1055
+
  1056
+		$result = Router::url(array('plugin' => 'test_plugin', 'controller' => 'test_plugin', 'action' => 'index'));
  1057
+		$expected = '/admin/test_plugin';
  1058
+		$this->assertEqual($result, $expected);
  1059
+
  1060
+		Configure::write('pluginPaths', $paths);
1039 1061
 	}
1040 1062
 /**
1041 1063
  * testExtensionParsingSetting method

0 notes on commit 74fd484

Please sign in to comment.
Something went wrong with that request. Please try again.