diff --git a/lib/Cake/Console/Command/SchemaShell.php b/lib/Cake/Console/Command/SchemaShell.php index 92dd9aeee..6df8a32ea 100644 --- a/lib/Cake/Console/Command/SchemaShell.php +++ b/lib/Cake/Console/Command/SchemaShell.php @@ -282,7 +282,11 @@ class SchemaShell extends AppShell { $this->out(__d('cake_console', 'Performing a dry run.')); } - $options = array('name' => $name, 'plugin' => $plugin); + $options = array( + 'name' => $name, + 'plugin' => $plugin, + 'connection' => $this->params['connection'], + ); if (!empty($this->params['snapshot'])) { $fileName = rtrim($this->Schema->file, '.php'); $options['file'] = $fileName . '_' . $this->params['snapshot'] . '.php'; diff --git a/lib/Cake/Model/Behavior/TranslateBehavior.php b/lib/Cake/Model/Behavior/TranslateBehavior.php index 9eceb725a..82800818a 100644 --- a/lib/Cake/Model/Behavior/TranslateBehavior.php +++ b/lib/Cake/Model/Behavior/TranslateBehavior.php @@ -305,7 +305,7 @@ class TranslateBehavior extends ModelBehavior { } } else { $value = ''; - if (is_numeric($row[$Model->alias][$aliasVirtual]) || !empty($row[$Model->alias][$aliasVirtual])) { + if (isset($row[$Model->alias][$aliasVirtual])) { $value = $row[$Model->alias][$aliasVirtual]; } $row[$Model->alias][$aliasField] = $value; diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 66e907996..aa8714f9a 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -2028,7 +2028,9 @@ class Model extends Object implements CakeEventListener { * @return void */ public function updateCounterCache($keys = array(), $created = false) { - $keys = empty($keys) ? $this->data[$this->alias] : $keys; + if (empty($keys) && isset($this->data[$this->alias])) { + $keys = $this->data[$this->alias]; + } $keys['old'] = isset($keys['old']) ? $keys['old'] : array(); foreach ($this->belongsTo as $parent => $assoc) { diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index d165e8929..27055662f 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -207,7 +207,7 @@ class CakeRequest implements ArrayAccess { $query = $_GET; } - unset($query['/' . str_replace('.', '_', urldecode($this->url))]); + unset($query[$this->base . '/' . str_replace('.', '_', urldecode($this->url))]); if (strpos($this->url, '?') !== false) { list(, $querystr) = explode('?', $this->url); parse_str($querystr, $queryArgs); diff --git a/lib/Cake/Routing/Route/CakeRoute.php b/lib/Cake/Routing/Route/CakeRoute.php index 88d094f66..bab5c23a5 100644 --- a/lib/Cake/Routing/Route/CakeRoute.php +++ b/lib/Cake/Routing/Route/CakeRoute.php @@ -233,12 +233,6 @@ class CakeRoute { $route[$key] = $value; } - foreach ($this->keys as $key) { - if (isset($route[$key])) { - $route[$key] = rawurldecode($route[$key]); - } - } - if (isset($route['_args_'])) { list($pass, $named) = $this->_parseArgs($route['_args_'], $route); $route['pass'] = array_merge($route['pass'], $pass); @@ -247,7 +241,7 @@ class CakeRoute { } if (isset($route['_trailing_'])) { - $route['pass'][] = rawurldecode($route['_trailing_']); + $route['pass'][] = $route['_trailing_']; unset($route['_trailing_']); } @@ -297,12 +291,10 @@ class CakeRoute { $separatorIsPresent = strpos($param, $namedConfig['separator']) !== false; if ((!isset($this->options['named']) || !empty($this->options['named'])) && $separatorIsPresent) { list($key, $val) = explode($namedConfig['separator'], $param, 2); - $key = rawurldecode($key); - $val = rawurldecode($val); $hasRule = isset($rules[$key]); $passIt = (!$hasRule && !$greedy) || ($hasRule && !$this->_matchNamed($val, $rules[$key], $context)); if ($passIt) { - $pass[] = rawurldecode($param); + $pass[] = $param; } else { if (preg_match_all('/\[([A-Za-z0-9_-]+)?\]/', $key, $matches, PREG_SET_ORDER)) { $matches = array_reverse($matches); @@ -323,7 +315,7 @@ class CakeRoute { $named = array_merge_recursive($named, array($key => $val)); } } else { - $pass[] = rawurldecode($param); + $pass[] = $param; } } return array($pass, $named); diff --git a/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php b/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php index 44eba0881..626376017 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php @@ -275,6 +275,40 @@ class TranslateBehaviorTest extends CakeTestCase { $this->assertEquals($expected, $result); } +/** + * testLocaleSingleCountWithConditions method + * + * @return void + */ + public function testLocaleSingleCountWithConditions() { + $this->loadFixtures('Translate', 'TranslatedItem'); + + $TestModel = new TranslatedItem(); + $TestModel->locale = 'eng'; + $result = $TestModel->find('all', array( + 'conditions' => array('slug' => 'first_translated') + )); + $expected = array( + array( + 'TranslatedItem' => array( + 'id' => 1, + 'slug' => 'first_translated', + 'locale' => 'eng', + 'title' => 'Title #1', + 'content' => 'Content #1', + 'translated_article_id' => 1, + ) + ) + ); + $this->assertEquals($expected, $result); + + $result = $TestModel->find('count', array( + 'conditions' => array('slug' => 'first_translated') + )); + $expected = 1; + $this->assertEquals($expected, $result); + } + /** * testLocaleSingleAssociations method * diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index 6b0499488..4882b66d7 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -1491,10 +1491,18 @@ class CakeRequestTest extends CakeTestCase { public function testGetParamsWithDot() { $_GET = array(); $_GET['/posts/index/add_add'] = ''; + $_SERVER['PHP_SELF'] = '/app/webroot/index.php'; + $_SERVER['REQUEST_URI'] = '/posts/index/add.add'; + $request = new CakeRequest(); + $this->assertEquals('', $request->base); + $this->assertEquals(array(), $request->query); + + $_GET = array(); + $_GET['/cake_dev/posts/index/add_add'] = ''; $_SERVER['PHP_SELF'] = '/cake_dev/app/webroot/index.php'; $_SERVER['REQUEST_URI'] = '/cake_dev/posts/index/add.add'; - $request = new CakeRequest(); + $this->assertEquals('/cake_dev', $request->base); $this->assertEquals(array(), $request->query); } @@ -1506,10 +1514,18 @@ class CakeRequestTest extends CakeTestCase { public function testGetParamWithUrlencodedElement() { $_GET = array(); $_GET['/posts/add/∂∂'] = ''; + $_SERVER['PHP_SELF'] = '/app/webroot/index.php'; + $_SERVER['REQUEST_URI'] = '/posts/add/%E2%88%82%E2%88%82'; + $request = new CakeRequest(); + $this->assertEquals('', $request->base); + $this->assertEquals(array(), $request->query); + + $_GET = array(); + $_GET['/cake_dev/posts/add/∂∂'] = ''; $_SERVER['PHP_SELF'] = '/cake_dev/app/webroot/index.php'; $_SERVER['REQUEST_URI'] = '/cake_dev/posts/add/%E2%88%82%E2%88%82'; - $request = new CakeRequest(); + $this->assertEquals('/cake_dev', $request->base); $this->assertEquals(array(), $request->query); } @@ -1884,6 +1900,34 @@ class CakeRequestTest extends CakeTestCase { 'urlParams' => array() ), ), + array( + 'Nginx - w/rewrite, document root set above top level cake dir, request root, no PATH_INFO, base parameter set', + array( + 'App' => array( + 'base' => false, + 'baseUrl' => false, + 'dir' => 'app', + 'webroot' => 'webroot' + ), + 'GET' => array('/site/posts/add' => ''), + 'SERVER' => array( + 'SERVER_NAME' => 'localhost', + 'DOCUMENT_ROOT' => '/Library/WebServer/Documents', + 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', + 'SCRIPT_NAME' => '/site/app/webroot/index.php', + 'QUERY_STRING' => '/site/posts/add&', + 'PHP_SELF' => '/site/app/webroot/index.php', + 'PATH_INFO' => null, + 'REQUEST_URI' => '/site/posts/add', + ), + ), + array( + 'url' => 'posts/add', + 'base' => '/site', + 'webroot' => '/site/', + 'urlParams' => array() + ), + ), ); } diff --git a/lib/Cake/View/Helper/PaginatorHelper.php b/lib/Cake/View/Helper/PaginatorHelper.php index ca255431b..2d7c2eebd 100644 --- a/lib/Cake/View/Helper/PaginatorHelper.php +++ b/lib/Cake/View/Helper/PaginatorHelper.php @@ -264,6 +264,7 @@ class PaginatorHelper extends AppHelper { * * ### Options: * + * - `url` Allows sending routing parameters such as controllers, actions or passed arguments. * - `tag` The tag wrapping tag you want to use, defaults to 'span'. Set this to false to disable this option * - `escape` Whether you want the contents html entity encoded, defaults to true * - `model` The model to use, defaults to PaginatorHelper::defaultModel() @@ -289,6 +290,7 @@ class PaginatorHelper extends AppHelper { * * ### Options: * + * - `url` Allows sending routing parameters such as controllers, actions or passed arguments. * - `tag` The tag wrapping tag you want to use, defaults to 'span'. Set this to false to disable this option * - `escape` Whether you want the contents html entity encoded, defaults to true * - `model` The model to use, defaults to PaginatorHelper::defaultModel()