Merge branch 'master' into 2.5

Conflicts:
	lib/Cake/Model/Datasource/DboSource.php
This commit is contained in:
mark_story 2014-02-16 14:24:19 -05:00
commit 2c5d96e916
21 changed files with 67 additions and 45 deletions

View file

@ -328,7 +328,7 @@ class ConsoleShell extends AppShell {
$command = str_replace($this->badCommandChars, "", $command);
// Do we have a valid model?
list($modelToCheck, $tmp) = explode('->', $command);
list($modelToCheck) = explode('->', $command);
if ($this->_isValidModel($modelToCheck)) {
$findCommand = "\$data = \$this->$command;";
@ -389,7 +389,7 @@ class ConsoleShell extends AppShell {
// Validate the model we're trying to save here
$command = strip_tags($command);
$command = str_replace($this->badCommandChars, "", $command);
list($modelToSave, $tmp) = explode("->", $command);
list($modelToSave) = explode("->", $command);
if ($this->_isValidModel($modelToSave)) {
// Extract the array of data we are trying to build

View file

@ -279,7 +279,13 @@ class TranslateBehavior extends ModelBehavior {
*/
public function afterFind(Model $Model, $results, $primary = false) {
$Model->virtualFields = $this->runtime[$Model->alias]['virtualFields'];
$this->runtime[$Model->alias]['virtualFields'] = $this->runtime[$Model->alias]['fields'] = array();
if (!empty($this->runtime[$Model->alias]['restoreFields'])) {
$this->runtime[$Model->alias]['fields'] = $this->runtime[$Model->alias]['restoreFields'];
unset($this->runtime[$Model->alias]['restoreFields']);
}
$locale = $this->_getLocale($Model);
if (empty($locale) || empty($results) || empty($this->runtime[$Model->alias]['beforeFind'])) {
@ -577,7 +583,10 @@ class TranslateBehavior extends ModelBehavior {
}
$associations = array();
$RuntimeModel = $this->translateModel($Model);
$default = array('className' => $RuntimeModel->alias, 'foreignKey' => 'foreign_key');
$default = array(
'className' => $RuntimeModel->alias,
'foreignKey' => 'foreign_key'
);
foreach ($fields as $key => $value) {
if (is_numeric($key)) {
@ -592,7 +601,6 @@ class TranslateBehavior extends ModelBehavior {
__d('cake_dev', 'You cannot bind a translation named "name".')
);
}
$this->_removeField($Model, $field);
if ($association === null) {
@ -604,6 +612,7 @@ class TranslateBehavior extends ModelBehavior {
} else {
if ($reset) {
$this->runtime[$Model->alias]['fields'][$field] = $association;
$this->runtime[$Model->alias]['restoreFields'][] = $field;
} else {
$this->settings[$Model->alias][$field] = $association;
}

View file

@ -142,7 +142,6 @@ class CakeSession {
*/
public static function init($base = null) {
self::$time = time();
$checkAgent = Configure::read('Session.checkAgent');
if (env('HTTP_USER_AGENT')) {
self::$_userAgent = md5(env('HTTP_USER_AGENT') . Configure::read('Security.salt'));

View file

@ -671,7 +671,6 @@ class Postgres extends DboSource {
}
$col = str_replace(')', '', $real);
$limit = null;
if (strpos($col, '(') !== false) {
list($col, $limit) = explode('(', $col);

View file

@ -252,9 +252,8 @@ class Sqlite extends DboSource {
}
$col = strtolower(str_replace(')', '', $real));
$limit = null;
if (strpos($col, '(') !== false) {
list($col, $limit) = explode('(', $col);
list($col) = explode('(', $col);
}
$standard = array(

View file

@ -2926,7 +2926,7 @@ class DboSource extends DataSource {
$key = '(' . $this->_quoteFields($Model->getVirtualField($key)) . ')';
}
list($alias, ) = pluginSplit($key);
list($alias) = pluginSplit($key);
if ($alias !== $Model->alias && is_object($Model->{$alias}) && $Model->{$alias}->isVirtualField($key)) {
$key = '(' . $this->_quoteFields($Model->{$alias}->getVirtualField($key)) . ')';
@ -3037,7 +3037,7 @@ class DboSource extends DataSource {
'int' => 1, 'tinyint' => 1, 'smallint' => 1, 'mediumint' => 1, 'integer' => 1, 'bigint' => 1
);
list($real, $type, $length, $offset, $sign, $zerofill) = $result;
list($real, $type, $length, $offset, $sign) = $result;
$typeArr = $type;
$type = $type[0];
$length = $length[0];
@ -3449,13 +3449,12 @@ class DboSource extends DataSource {
}
$isAllFloat = $isAllInt = true;
$containsFloat = $containsInt = $containsString = false;
$containsInt = $containsString = false;
foreach ($value as $valElement) {
$valElement = trim($valElement);
if (!is_float($valElement) && !preg_match('/^[\d]+\.[\d]+$/', $valElement)) {
$isAllFloat = false;
} else {
$containsFloat = true;
continue;
}
if (!is_int($valElement) && !preg_match('/^[\d]+$/', $valElement)) {

View file

@ -196,9 +196,9 @@ class FileEngineTest extends CakeTestCase {
Cache::config('file_test', array('engine' => 'File', 'duration' => 1));
$data = 'this is a test of the emergency broadcasting system';
$write = Cache::write('serialize_test1', $data, 'file_test');
$write = Cache::write('serialize_test2', $data, 'file_test');
$write = Cache::write('serialize_test3', $data, 'file_test');
Cache::write('serialize_test1', $data, 'file_test');
Cache::write('serialize_test2', $data, 'file_test');
Cache::write('serialize_test3', $data, 'file_test');
$this->assertTrue(file_exists(CACHE . 'cake_serialize_test1'));
$this->assertTrue(file_exists(CACHE . 'cake_serialize_test2'));
$this->assertTrue(file_exists(CACHE . 'cake_serialize_test3'));
@ -210,9 +210,9 @@ class FileEngineTest extends CakeTestCase {
$this->assertFalse(file_exists(CACHE . 'cake_serialize_test3'));
$data = 'this is a test of the emergency broadcasting system';
$write = Cache::write('serialize_test1', $data, 'file_test');
$write = Cache::write('serialize_test2', $data, 'file_test');
$write = Cache::write('serialize_test3', $data, 'file_test');
Cache::write('serialize_test1', $data, 'file_test');
Cache::write('serialize_test2', $data, 'file_test');
Cache::write('serialize_test3', $data, 'file_test');
$this->assertTrue(file_exists(CACHE . 'cake_serialize_test1'));
$this->assertTrue(file_exists(CACHE . 'cake_serialize_test2'));
$this->assertTrue(file_exists(CACHE . 'cake_serialize_test3'));
@ -413,7 +413,7 @@ class FileEngineTest extends CakeTestCase {
Cache::drop('mask_test');
Cache::config('mask_test', array('engine' => 'File', 'mask' => 0666, 'path' => TMP . 'tests'));
$write = Cache::write('masking_test', $data, 'mask_test');
Cache::write('masking_test', $data, 'mask_test');
$result = substr(sprintf('%o', fileperms(TMP . 'tests' . DS . 'cake_masking_test')), -4);
$expected = '0666';
$this->assertEquals($expected, $result);
@ -421,7 +421,7 @@ class FileEngineTest extends CakeTestCase {
Cache::drop('mask_test');
Cache::config('mask_test', array('engine' => 'File', 'mask' => 0644, 'path' => TMP . 'tests'));
$write = Cache::write('masking_test', $data, 'mask_test');
Cache::write('masking_test', $data, 'mask_test');
$result = substr(sprintf('%o', fileperms(TMP . 'tests' . DS . 'cake_masking_test')), -4);
$expected = '0644';
$this->assertEquals($expected, $result);
@ -429,7 +429,7 @@ class FileEngineTest extends CakeTestCase {
Cache::drop('mask_test');
Cache::config('mask_test', array('engine' => 'File', 'mask' => 0640, 'path' => TMP . 'tests'));
$write = Cache::write('masking_test', $data, 'mask_test');
Cache::write('masking_test', $data, 'mask_test');
$result = substr(sprintf('%o', fileperms(TMP . 'tests' . DS . 'cake_masking_test')), -4);
$expected = '0640';
$this->assertEquals($expected, $result);

View file

@ -550,7 +550,7 @@ class SchemaShellTest extends CakeTestCase {
$this->Shell->expects($this->any())
->method('in')
->will($this->returnValue('y'));
$r = $this->Shell->expects($this->once())
$this->Shell->expects($this->once())
->method('_run')
->with($this->arrayHasKey('newone'), 'update', $this->isInstanceOf('CakeSchema'));

View file

@ -427,9 +427,8 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->expects($this->at(1))->method('createFile')
->with($filename, $this->stringContains('<?php'));
$result = $this->Task->generateFixtureFile('Article', array());
$result = $this->Task->generateFixtureFile('Article', array());
$this->Task->generateFixtureFile('Article', array());
$this->Task->generateFixtureFile('Article', array());
}
/**

View file

@ -609,8 +609,8 @@ class PaginatorComponentTest extends CakeTestCase {
$this->assertEmpty($result['order']);
$Controller->PaginatorControllerPost->order = 'PaginatorControllerPost.id';
$results = $Controller->Paginator->validateSort($Controller->PaginatorControllerPost, array());
$this->assertEmpty($result['order']);
$result = $Controller->Paginator->validateSort($Controller->PaginatorControllerPost, array());
$this->assertArrayNotHasKey('order', $result);
$Controller->PaginatorControllerPost->order = array(
'PaginatorControllerPost.id',
@ -1124,26 +1124,26 @@ class PaginatorComponentTest extends CakeTestCase {
$Controller->request->params['named'] = array(
'contain' => array('ControllerComment'), 'limit' => '1000'
);
$result = $Controller->paginate('PaginatorControllerPost');
$Controller->paginate('PaginatorControllerPost');
$this->assertEquals(100, $Controller->params['paging']['PaginatorControllerPost']['options']['limit']);
$Controller->request->params['named'] = array(
'contain' => array('ControllerComment'), 'limit' => '1000', 'maxLimit' => 1000
);
$result = $Controller->paginate('PaginatorControllerPost');
$Controller->paginate('PaginatorControllerPost');
$this->assertEquals(100, $Controller->params['paging']['PaginatorControllerPost']['options']['limit']);
$Controller->request->params['named'] = array('contain' => array('ControllerComment'), 'limit' => '10');
$result = $Controller->paginate('PaginatorControllerPost');
$Controller->paginate('PaginatorControllerPost');
$this->assertEquals(10, $Controller->params['paging']['PaginatorControllerPost']['options']['limit']);
$Controller->request->params['named'] = array('contain' => array('ControllerComment'), 'limit' => '1000');
$Controller->paginate = array('maxLimit' => 2000, 'paramType' => 'named');
$result = $Controller->paginate('PaginatorControllerPost');
$Controller->paginate('PaginatorControllerPost');
$this->assertEquals(1000, $Controller->params['paging']['PaginatorControllerPost']['options']['limit']);
$Controller->request->params['named'] = array('contain' => array('ControllerComment'), 'limit' => '5000');
$result = $Controller->paginate('PaginatorControllerPost');
$Controller->paginate('PaginatorControllerPost');
$this->assertEquals(2000, $Controller->params['paging']['PaginatorControllerPost']['options']['limit']);
}

View file

@ -607,7 +607,7 @@ class SecurityComponentTest extends CakeTestCase {
$fields = '69f493434187b867ea14b901fdf58b55d27c935d%3A';
$unlocked = '';
$this->Controller->request->data = $data = array(
$this->Controller->request->data = array(
'Model' => array('username' => '', 'password' => ''),
'_Token' => compact('key', 'fields', 'unlocked')
);

View file

@ -243,7 +243,6 @@ class ControllerMergeVarsTest extends CakeTestCase {
public function testMergeVarsModelClass() {
$Controller = new MergeVariablescontroller();
$Controller->uses = array('Test', 'TestAlias');
$lastModel = end($Controller->uses);
$Controller->constructClasses();
$this->assertEquals($Controller->uses[0], $Controller->modelClass);
}

View file

@ -1057,6 +1057,29 @@ class TranslateBehaviorTest extends CakeTestCase {
$this->assertFalse(empty($result));
}
/**
* test restoring fields after temporary binds method
*
* @return void
*/
public function testFieldsRestoreAfterBind() {
$this->loadFixtures('Translate', 'TranslatedItem');
$TestModel = new TranslatedItem();
$translations = array('title' => 'Title');
$TestModel->bindTranslation($translations);
$result = $TestModel->find('first');
$this->assertArrayHasKey('Title', $result);
$this->assertArrayHasKey('content', $result['Title'][0]);
$this->assertArrayNotHasKey('title', $result);
$result = $TestModel->find('first');
$this->assertArrayNotHasKey('Title', $result);
$this->assertEquals('Title #1', $result['TranslatedItem']['title']);
}
/**
* testAttachDetach method
*

View file

@ -2294,14 +2294,12 @@ class RouterTest extends CakeTestCase {
$this->assertEquals(array_merge($url, array('plugin' => null)), $route->defaults);
// test that the first route is matched
$newUrl = array('controller' => 'products', 'action' => 'display', 6);
Router::connect('/government', $url);
Router::parse('/government');
$route = Router::requestRoute();
$this->assertEquals(array_merge($url, array('plugin' => null)), $route->defaults);
// test that an unmatched route does not change the current route
$newUrl = array('controller' => 'products', 'action' => 'display', 6);
Router::connect('/actor', $url);
Router::parse('/government');
$route = Router::requestRoute();

View file

@ -2386,9 +2386,11 @@ class ValidationTest extends CakeTestCase {
public function testUploadError() {
$this->assertTrue(Validation::uploadError(0));
$this->assertTrue(Validation::uploadError(array('error' => 0)));
$this->assertTrue(Validation::uploadError(array('error' => '0')));
$this->assertFalse(Validation::uploadError(2));
$this->assertFalse(Validation::uploadError(array('error' => 2)));
$this->assertFalse(Validation::uploadError(array('error' => '2')));
}
/**

View file

@ -201,7 +201,7 @@ HTML;
*/
public function coverageHeader($filename, $percent) {
$filename = basename($filename);
list($file, $ext) = explode('.', $filename);
list($file) = explode('.', $filename);
$display = in_array($file, $this->_testNames) ? 'block' : 'none';
$primary = $display === 'block' ? 'primary' : '';
return <<<HTML

View file

@ -150,13 +150,10 @@ class CakeTextReporter extends CakeBaseReporter {
$plugin = $this->params['plugin'];
$buffer = "Core Test Cases:\n";
$urlExtra = '';
if ($app) {
$buffer = "App Test Cases:\n";
$urlExtra = '&app=true';
} elseif ($plugin) {
$buffer = Inflector::humanize($plugin) . " Test Cases:\n";
$urlExtra = '&plugin=' . $plugin;
}
if (count($testCases) < 1) {

View file

@ -537,9 +537,8 @@ class Debugger {
$var = $replace + $var;
$out = "array(";
$n = $break = $end = null;
$break = $end = null;
if (!empty($var)) {
$n = "\n";
$break = "\n" . str_repeat("\t", $indent);
$end = "\n" . str_repeat("\t", $indent - 1);
}

View file

@ -558,7 +558,7 @@ class File {
if (!$finfo) {
return false;
}
list($type, $charset) = explode(';', $finfo);
list($type) = explode(';', $finfo);
return $type;
}
if (function_exists('mime_content_type')) {

View file

@ -85,7 +85,7 @@ class Security {
* you ensuring that each hashed password will have a *unique* salt.
* - Comparing Hashes: Simply pass the originally hashed password as the salt.
* The salt is prepended to the hash and php handles the parsing automagically.
* For convenience the BlowfishAuthenticate adapter is available for use with
* For convenience the `BlowfishPasswordHasher` class is available for use with
* the AuthComponent.
* - Do NOT use a constant salt for blowfish!
*

View file

@ -979,7 +979,7 @@ class Validation {
$check = $check['error'];
}
return $check === UPLOAD_ERR_OK;
return (int)$check === UPLOAD_ERR_OK;
}
/**