Merge branch 'master' into 2.5

This commit is contained in:
ADmad 2014-01-26 17:39:50 +05:30
commit c093804b35
8 changed files with 95 additions and 17 deletions

View file

@ -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';

View file

@ -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;

View file

@ -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) {

View file

@ -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);

View file

@ -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);

View file

@ -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
*

View file

@ -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()
),
),
);
}

View file

@ -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()