Skip to content

Commit

Permalink
Merge branch '2.1' into 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Apr 18, 2012
2 parents 8639d5a + c871d85 commit 21ba5bf
Show file tree
Hide file tree
Showing 30 changed files with 420 additions and 172 deletions.
2 changes: 1 addition & 1 deletion app/View/Layouts/rss/default.ctp
Expand Up @@ -11,4 +11,4 @@ echo $this->Rss->document(
array(), $channel, $content_for_layout
)
);
?>
?>
4 changes: 0 additions & 4 deletions app/webroot/index.php
Expand Up @@ -86,10 +86,6 @@
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
}

if (isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] == '/favicon.ico') {
return;
}

App::uses('Dispatcher', 'Routing');

$Dispatcher = new Dispatcher();
Expand Down
7 changes: 2 additions & 5 deletions lib/Cake/Console/Templates/skel/View/Layouts/rss/default.ctp
@@ -1,17 +1,14 @@
<?php
echo $rss->header();

if (!isset($channel)) {
$channel = array();
}
if (!isset($channel['title'])) {
$channel['title'] = $title_for_layout;
}

echo $rss->document(
$rss->channel(
echo $this->Rss->document(
$this->Rss->channel(
array(), $channel, $content_for_layout
)
);

?>
4 changes: 0 additions & 4 deletions lib/Cake/Console/Templates/skel/webroot/index.php
Expand Up @@ -88,10 +88,6 @@
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
}

if (isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] == '/favicon.ico') {
return;
}

App::uses('Dispatcher', 'Routing');

$Dispatcher = new Dispatcher();
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Controller/CakeErrorController.php
Expand Up @@ -54,7 +54,7 @@ public function __construct($request = null, $response = null) {
$this->components[] = 'RequestHandler';
}
$this->constructClasses();
$this->Components->trigger('initialize', array(&$this));
$this->startupProcess();

$this->_set(array('cacheAction' => false, 'viewPath' => 'Errors'));
if (isset($this->RequestHandler)) {
Expand Down
43 changes: 21 additions & 22 deletions lib/Cake/Model/Behavior/TranslateBehavior.php
Expand Up @@ -471,17 +471,7 @@ public function bindTranslation(Model $model, $fields, $reset = true) {
);
}

if (array_key_exists($field, $this->settings[$model->alias])) {
unset($this->settings[$model->alias][$field]);
} elseif (in_array($field, $this->settings[$model->alias])) {
$this->settings[$model->alias] = array_merge(array_diff_assoc($this->settings[$model->alias], array($field)));
}

if (array_key_exists($field, $this->runtime[$model->alias]['fields'])) {
unset($this->runtime[$model->alias]['fields'][$field]);
} elseif (in_array($field, $this->runtime[$model->alias]['fields'])) {
$this->runtime[$model->alias]['fields'] = array_merge(array_diff_assoc($this->runtime[$model->alias]['fields'], array($field)));
}
$this->_updateSettings($model, $field);

if (is_null($association)) {
if ($reset) {
Expand Down Expand Up @@ -518,6 +508,25 @@ public function bindTranslation(Model $model, $fields, $reset = true) {
return true;
}

/**
* Update runtime setting for a given field.
*
* @param string $field The field to update.
*/
protected function _updateSettings(Model $model, $field) {
if (array_key_exists($field, $this->settings[$model->alias])) {
unset($this->settings[$model->alias][$field]);
} elseif (in_array($field, $this->settings[$model->alias])) {
$this->settings[$model->alias] = array_merge(array_diff_assoc($this->settings[$model->alias], array($field)));
}

if (array_key_exists($field, $this->runtime[$model->alias]['fields'])) {
unset($this->runtime[$model->alias]['fields'][$field]);
} elseif (in_array($field, $this->runtime[$model->alias]['fields'])) {
$this->runtime[$model->alias]['fields'] = array_merge(array_diff_assoc($this->runtime[$model->alias]['fields'], array($field)));
}
}

/**
* Unbind translation for fields, optionally unbinds hasMany association for
* fake field
Expand Down Expand Up @@ -550,17 +559,7 @@ public function unbindTranslation(Model $model, $fields = null) {
$association = $value;
}

if (array_key_exists($field, $this->settings[$model->alias])) {
unset($this->settings[$model->alias][$field]);
} elseif (in_array($field, $this->settings[$model->alias])) {
$this->settings[$model->alias] = array_merge(array_diff_assoc($this->settings[$model->alias], array($field)));
}

if (array_key_exists($field, $this->runtime[$model->alias]['fields'])) {
unset($this->runtime[$model->alias]['fields'][$field]);
} elseif (in_array($field, $this->runtime[$model->alias]['fields'])) {
$this->runtime[$model->alias]['fields'] = array_merge(array_diff_assoc($this->runtime[$model->alias]['fields'], array($field)));
}
$this->_updateSettings($model, $field);

if (!is_null($association) && (isset($model->hasMany[$association]) || isset($model->__backAssociation['hasMany'][$association]))) {
$associations[] = $association;
Expand Down
2 changes: 2 additions & 0 deletions lib/Cake/Model/Datasource/CakeSession.php
Expand Up @@ -602,6 +602,8 @@ protected static function _startSession() {
$_SESSION = array();
}
} else {
// For IE<=8
session_cache_limiter("must-revalidate");
session_start();
}
return true;
Expand Down
22 changes: 16 additions & 6 deletions lib/Cake/Model/Model.php
Expand Up @@ -1319,7 +1319,9 @@ public function getColumnType($column) {
$cols = $this->schema();
$model = null;

$column = str_replace(array($db->startQuote, $db->endQuote), '', $column);
$startQuote = isset($db->startQuote) ? $db->startQuote : null;
$endQuote = isset($db->endQuote) ? $db->endQuote : null;
$column = str_replace(array($startQuote, $endQuote), '', $column);

if (strpos($column, '.')) {
list($model, $column) = explode('.', $column);
Expand Down Expand Up @@ -2034,6 +2036,9 @@ public function saveMany($data = null, $options = array()) {

if (empty($data) && $options['validate'] !== false) {
$result = $this->save($data, $options);
if (!$options['atomic']) {
return array(!empty($result));
}
return !empty($result);
}

Expand All @@ -2042,7 +2047,7 @@ public function saveMany($data = null, $options = array()) {
if ((!$validates && $options['atomic']) || (!$options['atomic'] && in_array(false, $validates, true))) {
return $validates;
}
$options['validate'] = true;
$options['validate'] = false;
}

if ($options['atomic']) {
Expand Down Expand Up @@ -2165,6 +2170,9 @@ public function saveAssociated($data = null, $options = array()) {

if (empty($data) && $options['validate'] !== false) {
$result = $this->save($data, $options);
if (!$options['atomic']) {
return array(!empty($result));
}
return !empty($result);
}

Expand All @@ -2173,7 +2181,7 @@ public function saveAssociated($data = null, $options = array()) {
if ((!$validates && $options['atomic']) || (!$options['atomic'] && in_array(false, $validates, true))) {
return $validates;
}
$options['validate'] = true;
$options['validate'] = false;
}
if ($options['atomic']) {
$db = $this->getDataSource();
Expand All @@ -2183,7 +2191,8 @@ public function saveAssociated($data = null, $options = array()) {
$return = array();
$validates = true;
foreach ($data as $association => $values) {
if (isset($associations[$association]) && $associations[$association] === 'belongsTo') {
$notEmpty = !empty($values[$association]) || (!isset($values[$association]) && !empty($values));
if (isset($associations[$association]) && $associations[$association] === 'belongsTo' && $notEmpty) {
$validates = $this->{$association}->create(null) !== null;
$saved = false;
if ($validates) {
Expand Down Expand Up @@ -2217,7 +2226,8 @@ public function saveAssociated($data = null, $options = array()) {
if (!$validates) {
break;
}
if (isset($associations[$association])) {
$notEmpty = !empty($values[$association]) || (!isset($values[$association]) && !empty($values));
if (isset($associations[$association]) && $notEmpty) {
$type = $associations[$association];
$key = $this->{$type}[$association]['foreignKey'];
switch ($type) {
Expand Down Expand Up @@ -3369,7 +3379,7 @@ public function getAffectedRows() {
* Sets the DataSource to which this model is bound.
*
* @param string $dataSource The name of the DataSource, as defined in app/Config/database.php
* @return boolean True on success
* @return void
* @throws MissingConnectionException
*/
public function setDataSource($dataSource = null) {
Expand Down
2 changes: 2 additions & 0 deletions lib/Cake/Network/CakeRequest.php
Expand Up @@ -39,6 +39,8 @@ class CakeRequest implements ArrayAccess {
'plugin' => null,
'controller' => null,
'action' => null,
'named' => array(),
'pass' => array(),
);

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Console/Command/SchemaShellTest.php
Expand Up @@ -114,7 +114,7 @@ public function setUp() {
}

/**
* endTest method
* tearDown method
*
* @return void
*/
Expand Down
Expand Up @@ -49,7 +49,7 @@ public function setUp() {
}

/**
* endTest method
* tearDown method
*
* @return void
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php
Expand Up @@ -239,7 +239,7 @@ public function setUp() {
}

/**
* endTest method
* tearDown method
*
* @return void
*/
Expand Down
83 changes: 4 additions & 79 deletions lib/Cake/Test/Case/Console/ShellTest.php
Expand Up @@ -525,7 +525,7 @@ public function testShortPath() {
* @return void
*/
public function testCreateFileNonInteractive() {
$this->skipIf(DIRECTORY_SEPARATOR === '\\', 'Not supported on Windows.');
$eol = PHP_EOL;

$path = TMP . 'shell_test';
$file = $path . DS . 'file1.php';
Expand All @@ -534,7 +534,7 @@ public function testCreateFileNonInteractive() {

$this->Shell->interactive = false;

$contents = "<?php\necho 'test';\n\$te = 'st';\n";
$contents = "<?php{$eol}echo 'test';${eol}\$te = 'st';{$eol}";
$result = $this->Shell->createFile($file, $contents);
$this->assertTrue($result);
$this->assertTrue(file_exists($file));
Expand All @@ -553,7 +553,7 @@ public function testCreateFileNonInteractive() {
* @return void
*/
public function testCreateFileInteractive() {
$this->skipIf(DIRECTORY_SEPARATOR === '\\', 'Not supported on Windows.');
$eol = PHP_EOL;

$path = TMP . 'shell_test';
$file = $path . DS . 'file1.php';
Expand All @@ -569,7 +569,7 @@ public function testCreateFileInteractive() {
->method('read')
->will($this->returnValue('y'));

$contents = "<?php\necho 'yet another test';\n\$te = 'st';\n";
$contents = "<?php{$eol}echo 'yet another test';{$eol}\$te = 'st';{$eol}";
$result = $this->Shell->createFile($file, $contents);
$this->assertTrue($result);
$this->assertTrue(file_exists($file));
Expand Down Expand Up @@ -609,81 +609,6 @@ public function testCreateFileNoPermissions() {
rmdir($path);
}

/**
* testCreateFileWindows method
*
* @return void
*/
public function testCreateFileWindowsNonInteractive() {
$this->skipIf(DIRECTORY_SEPARATOR === '/', 'testCreateFileWindowsNonInteractive supported on Windows only.');

$path = TMP . 'shell_test';
$file = $path . DS . 'file1.php';

$Folder = new Folder($path, true);

$this->Shell->interactive = false;

$contents = "<?php\r\necho 'test';\r\n\$te = 'st';\r\n";
$result = $this->Shell->createFile($file, $contents);
$this->assertTrue($result);
$this->assertTrue(file_exists($file));
$this->assertEquals(file_get_contents($file), $contents);

$contents = "<?php\r\necho 'another test';\r\n\$te = 'st';\r\n";
$result = $this->Shell->createFile($file, $contents);
$this->assertTrue($result);
$this->assertTrue(file_exists($file));
$this->assertEquals(file_get_contents($file), $contents);

$Folder = new Folder($path);
$Folder->delete();
}

/**
* test createFile on windows with interactive on.
*
* @return void
*/
public function testCreateFileWindowsInteractive() {
$this->skipIf(DIRECTORY_SEPARATOR === '/', 'testCreateFileWindowsInteractive supported on Windows only.');
$path = TMP . 'shell_test';
$file = $path . DS . 'file1.php';
$Folder = new Folder($path, true);

$this->Shell->interactive = true;

$this->Shell->stdin->expects($this->at(0))
->method('read')
->will($this->returnValue('n'));

$this->Shell->stdin->expects($this->at(1))
->method('read')
->will($this->returnValue('y'));

$contents = "<?php\r\necho 'yet another test';\r\n\$te = 'st';\r\n";
$result = $this->Shell->createFile($file, $contents);
$this->assertTrue($result);
$this->assertTrue(file_exists($file));
$this->assertEquals(file_get_contents($file), $contents);

// no overwrite
$contents = 'new contents';
$result = $this->Shell->createFile($file, $contents);
$this->assertFalse($result);
$this->assertTrue(file_exists($file));
$this->assertNotEquals($contents, file_get_contents($file));

// overwrite
$contents = 'more new contents';
$result = $this->Shell->createFile($file, $contents);
$this->assertTrue($result);
$this->assertTrue(file_exists($file));
$this->assertEquals($contents, file_get_contents($file));

$Folder->delete();
}

/**
* test hasTask method
*
Expand Down
Expand Up @@ -117,7 +117,7 @@ protected function _init() {
}

/**
* endTest method
* tearDown method
*
* @return void
*/
Expand Down

0 comments on commit 21ba5bf

Please sign in to comment.