Skip to content

Commit

Permalink
Merge branch 'master' into 2.6
Browse files Browse the repository at this point in the history
Conflicts:
	lib/Cake/VERSION.txt
  • Loading branch information
markstory committed May 17, 2014
2 parents 2d46be6 + 153141a commit 2e4d6eb
Show file tree
Hide file tree
Showing 26 changed files with 212 additions and 48 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -5,6 +5,7 @@ php:
- 5.3
- 5.4
- 5.5
- 5.6

env:
- DB=mysql
Expand Down
Empty file modified lib/Cake/Cache/Engine/MemcachedEngine.php 100755 → 100644
Empty file.
8 changes: 6 additions & 2 deletions lib/Cake/Cache/Engine/RedisEngine.php
Expand Up @@ -38,6 +38,7 @@ class RedisEngine extends CacheEngine {
* - port = integer port number to the Redis server (default: 6379)
* - timeout = float timeout in seconds (default: 0)
* - persistent = boolean Connects to the Redis server with a persistent connection (default: true)
* - unix_socket = path to the unix socket file (default: false)
*
* @var array
*/
Expand All @@ -64,7 +65,8 @@ public function init($settings = array()) {
'port' => 6379,
'password' => false,
'timeout' => 0,
'persistent' => true
'persistent' => true,
'unix_socket' => false
), $settings)
);

Expand All @@ -80,7 +82,9 @@ protected function _connect() {
$return = false;
try {
$this->_Redis = new Redis();
if (empty($this->settings['persistent'])) {
if (!empty($this->settings['unix_socket'])) {
$return = $this->_Redis->connect($this->settings['unix_socket']);
} elseif (empty($this->settings['persistent'])) {
$return = $this->_Redis->connect($this->settings['server'], $this->settings['port'], $this->settings['timeout']);
} else {
$persistentId = $this->settings['port'] . $this->settings['timeout'] . $this->settings['database'];
Expand Down
5 changes: 3 additions & 2 deletions lib/Cake/Console/Command/UpgradeShell.php
Expand Up @@ -839,8 +839,9 @@ public function getOptionParser() {
);

$parser->description(
__d('cake_console', "A shell to help automate upgrading from CakePHP 1.3 to 2.0. \n" .
"Be sure to have a backup of your application before running these commands."
__d('cake_console', "A tool to help automate upgrading an application or plugin " .
"from CakePHP 1.3 to 2.0. Be sure to have a backup of your application before " .
"running these commands."
))->addSubcommand('all', array(
'help' => __d('cake_console', 'Run all upgrade commands.'),
'parser' => $subcommandParser
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Templates/default/views/form.ctp
Expand Up @@ -46,7 +46,7 @@
<ul>

<?php if (strpos($action, 'add') === false): ?>
<li><?php echo "<?php echo \$this->Form->postLink(__('Delete'), array('action' => 'delete', \$this->Form->value('{$modelClass}.{$primaryKey}')), null, __('Are you sure you want to delete # %s?', \$this->Form->value('{$modelClass}.{$primaryKey}'))); ?>"; ?></li>
<li><?php echo "<?php echo \$this->Form->postLink(__('Delete'), array('action' => 'delete', \$this->Form->value('{$modelClass}.{$primaryKey}')), array(), __('Are you sure you want to delete # %s?', \$this->Form->value('{$modelClass}.{$primaryKey}'))); ?>"; ?></li>
<?php endif; ?>
<li><?php echo "<?php echo \$this->Html->link(__('List " . $pluralHumanName . "'), array('action' => 'index')); ?>"; ?></li>
<?php
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Console/Templates/default/views/view.ctp
Expand Up @@ -45,7 +45,7 @@ foreach ($fields as $field) {
<ul>
<?php
echo "\t\t<li><?php echo \$this->Html->link(__('Edit " . $singularHumanName ."'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
echo "\t\t<li><?php echo \$this->Form->postLink(__('Delete " . $singularHumanName . "'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
echo "\t\t<li><?php echo \$this->Form->postLink(__('Delete " . $singularHumanName . "'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), array(), __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
echo "\t\t<li><?php echo \$this->Html->link(__('List " . $pluralHumanName . "'), array('action' => 'index')); ?> </li>\n";
echo "\t\t<li><?php echo \$this->Html->link(__('New " . $singularHumanName . "'), array('action' => 'add')); ?> </li>\n";

Expand Down Expand Up @@ -119,7 +119,7 @@ echo "\t<?php foreach (\${$singularVar}['{$alias}'] as \${$otherSingularVar}): ?
echo "\t\t\t<td class=\"actions\">\n";
echo "\t\t\t\t<?php echo \$this->Html->link(__('View'), array('controller' => '{$details['controller']}', 'action' => 'view', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t\t<?php echo \$this->Html->link(__('Edit'), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t\t<?php echo \$this->Form->postLink(__('Delete'), array('controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']), null, __('Are you sure you want to delete # %s?', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t\t<?php echo \$this->Form->postLink(__('Delete'), array('controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']), array(), __('Are you sure you want to delete # %s?', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t</td>\n";
echo "\t\t</tr>\n";

Expand Down
2 changes: 2 additions & 0 deletions lib/Cake/Controller/Component/PaginatorComponent.php
Expand Up @@ -202,6 +202,8 @@ public function paginate($object = null, $scope = array(), $whitelist = array())
$count = 0;
} elseif ($object->hasMethod('paginateCount')) {
$count = $object->paginateCount($conditions, $recursive, $extra);
} elseif ($page === 1 && count($results) < $limit) {
$count = count($results);
} else {
$parameters = compact('conditions');
if ($recursive != $object->recursive) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Controller/Controller.php
Expand Up @@ -970,7 +970,7 @@ public function referer($default = null, $local = false) {

$referer = $this->request->referer($local);
if ($referer === '/' && $default) {
return Router::url($default, true);
return Router::url($default, !$local);
}
return $referer;
}
Expand Down
1 change: 1 addition & 0 deletions lib/Cake/Model/Datasource/DboSource.php
Expand Up @@ -1140,6 +1140,7 @@ public function read(Model $Model, $queryData = array(), $recursive = null) {
$stack['_joined'] = $joined;

$db->queryAssociation($Model, $LinkModel, $type, $assoc, $assocData, $array, true, $resultSet, $Model->recursive - 1, $stack);
unset($db);

if ($type === 'hasMany' || $type === 'hasAndBelongsToMany') {
$filtered[] = $assoc;
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Model.php
Expand Up @@ -2108,7 +2108,7 @@ public function updateCounterCache($keys = array(), $created = false) {
protected function _prepareUpdateFields($data) {
$foreignKeys = array();
foreach ($this->belongsTo as $assoc => $info) {
if ($info['counterCache']) {
if (isset($info['counterCache']) && $info['counterCache']) {
$foreignKeys[$assoc] = $info['foreignKey'];
}
}
Expand Down
13 changes: 8 additions & 5 deletions lib/Cake/Network/Email/CakeEmail.php
Expand Up @@ -756,8 +756,10 @@ public function getHeaders($include = array()) {
}

$headers['MIME-Version'] = '1.0';
if (!empty($this->_attachments) || $this->_emailFormat === 'both') {
if (!empty($this->_attachments)) {
$headers['Content-Type'] = 'multipart/mixed; boundary="' . $this->_boundary . '"';
} elseif ($this->_emailFormat === 'both') {
$headers['Content-Type'] = 'multipart/alternative; boundary="' . $this->_boundary . '"';
} elseif ($this->_emailFormat === 'text') {
$headers['Content-Type'] = 'text/plain; charset=' . $this->_getContentTypeCharset();
} elseif ($this->_emailFormat === 'html') {
Expand Down Expand Up @@ -1521,6 +1523,7 @@ protected function _render($content) {
$hasInlineAttachments = count($contentIds) > 0;
$hasAttachments = !empty($this->_attachments);
$hasMultipleTypes = count($rendered) > 1;
$multiPart = ($hasAttachments || $hasMultipleTypes);

$boundary = $relBoundary = $textBoundary = $this->_boundary;

Expand All @@ -1531,15 +1534,15 @@ protected function _render($content) {
$relBoundary = $textBoundary = 'rel-' . $boundary;
}

if ($hasMultipleTypes) {
if ($hasMultipleTypes && $hasAttachments) {
$msg[] = '--' . $relBoundary;
$msg[] = 'Content-Type: multipart/alternative; boundary="alt-' . $boundary . '"';
$msg[] = '';
$textBoundary = 'alt-' . $boundary;
}

if (isset($rendered['text'])) {
if ($textBoundary !== $boundary || $hasAttachments) {
if ($multiPart) {
$msg[] = '--' . $textBoundary;
$msg[] = 'Content-Type: text/plain; charset=' . $this->_getContentTypeCharset();
$msg[] = 'Content-Transfer-Encoding: ' . $this->_getContentTransferEncoding();
Expand All @@ -1552,7 +1555,7 @@ protected function _render($content) {
}

if (isset($rendered['html'])) {
if ($textBoundary !== $boundary || $hasAttachments) {
if ($multiPart) {
$msg[] = '--' . $textBoundary;
$msg[] = 'Content-Type: text/html; charset=' . $this->_getContentTypeCharset();
$msg[] = 'Content-Transfer-Encoding: ' . $this->_getContentTransferEncoding();
Expand All @@ -1564,7 +1567,7 @@ protected function _render($content) {
$msg[] = '';
}

if ($hasMultipleTypes) {
if ($textBoundary !== $relBoundary) {
$msg[] = '--' . $textBoundary . '--';
$msg[] = '';
}
Expand Down
Empty file modified lib/Cake/Test/Case/Cache/Engine/MemcachedEngineTest.php 100755 → 100644
Empty file.
10 changes: 7 additions & 3 deletions lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php
Expand Up @@ -1052,8 +1052,8 @@ public function testExecuteIntoAll() {
$this->Task->args = array('all');
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));

$this->Task->Fixture->expects($this->exactly(5))->method('bake');
$this->Task->Test->expects($this->exactly(5))->method('bake');
$this->Task->Fixture->expects($this->exactly(6))->method('bake');
$this->Task->Test->expects($this->exactly(6))->method('bake');

$filename = '/my/path/BakeArticle.php';
$this->Task->expects($this->at(1))->method('createFile')
Expand Down Expand Up @@ -1083,6 +1083,10 @@ public function testExecuteIntoAll() {
$this->Task->expects($this->at(5))->method('createFile')
->with($filename, $this->stringContains('class CategoryThread'));

$filename = '/my/path/NumberTree.php';
$this->Task->expects($this->at(6))->method('createFile')
->with($filename, $this->stringContains('class NumberTree'));

$this->Task->execute();

$this->assertEquals(count(ClassRegistry::keys()), 0);
Expand Down Expand Up @@ -1216,7 +1220,7 @@ public function testSkipTablesAndAll() {
$this->Task->path = '/my/path/';
$this->Task->args = array('all');
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
$this->Task->skipTables = array('bake_tags');
$this->Task->skipTables = array('bake_tags', 'number_trees');

$this->Task->Fixture->expects($this->exactly(4))->method('bake');
$this->Task->Test->expects($this->exactly(4))->method('bake');
Expand Down
Expand Up @@ -959,7 +959,7 @@ public function testDefaultToLoginRedirect() {
array($CakeRequest, $CakeResponse)
);

$expected = Router::url($this->Auth->loginRedirect, true);
$expected = Router::url($this->Auth->loginRedirect);
$Controller->expects($this->once())
->method('redirect')
->with($this->equalTo($expected));
Expand Down
Expand Up @@ -272,20 +272,17 @@ public function testTemplates() {
$this->assertTextEquals($expected, DebugCompTransport::$lastEmail);

$this->Controller->EmailTest->sendAs = 'both';
$expected = str_replace('{CONTENTTYPE}', 'multipart/mixed; boundary="{boundary}"', $header);
$expected = str_replace('{CONTENTTYPE}', 'multipart/alternative; boundary="{boundary}"', $header);
$expected .= "--{boundary}\n" .
'Content-Type: multipart/alternative; boundary="alt-{boundary}"' . "\n\n" .
'--alt-{boundary}' . "\n" .
'Content-Type: text/plain; charset=UTF-8' . "\n" .
'Content-Transfer-Encoding: 8bit' . "\n\n" .
$text .
"\n\n" .
'--alt-{boundary}' . "\n" .
'--{boundary}' . "\n" .
'Content-Type: text/html; charset=UTF-8' . "\n" .
'Content-Transfer-Encoding: 8bit' . "\n\n" .
$html .
"\n\n" .
'--alt-{boundary}--' . "\n\n\n" .
"\n\n\n" .
'--{boundary}--' . "\n";

$expected = '<pre>' . $expected . '</pre>';
Expand Down
Expand Up @@ -185,8 +185,8 @@ class PaginatorAuthor extends CakeTestModel {
* @var string
*/
public $virtualFields = array(
'joined_offset' => 'PaginatorAuthor.id + 1'
);
'joined_offset' => 'PaginatorAuthor.id + 1'
);

}

Expand Down Expand Up @@ -358,7 +358,7 @@ public function testPaginate() {
$this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']);
$this->assertEquals(array(3, 2, 1), $results);

$Controller->request->params['named'] = array('sort' => 'NotExisting.field', 'direction' => 'desc');
$Controller->request->params['named'] = array('sort' => 'NotExisting.field', 'direction' => 'desc', 'limit' => 2);
$Controller->Paginator->paginate('PaginatorControllerPost');
$this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']);
$this->assertEquals(array(), $Controller->PaginatorControllerPost->lastQueries[1]['order'][0], 'no order should be set.');
Expand All @@ -367,7 +367,7 @@ public function testPaginate() {
'sort' => 'PaginatorControllerPost.author_id', 'direction' => 'allYourBase'
);
$results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
$this->assertEquals(array('PaginatorControllerPost.author_id' => 'asc'), $Controller->PaginatorControllerPost->lastQueries[1]['order'][0]);
$this->assertEquals(array('PaginatorControllerPost.author_id' => 'asc'), $Controller->PaginatorControllerPost->lastQueries[0]['order'][0]);
$this->assertEquals(array(1, 3, 2), $results);

$Controller->request->params['named'] = array();
Expand Down Expand Up @@ -466,7 +466,7 @@ public function testPaginateExtraParams() {
$result = $Controller->Paginator->paginate('PaginatorControllerPost');
$this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']);
$this->assertEquals(array(1, 2, 3), Hash::extract($result, '{n}.PaginatorControllerPost.id'));
$this->assertTrue(isset($Controller->PaginatorControllerPost->lastQueries[1]['contain']));
$this->assertTrue(isset($Controller->PaginatorControllerPost->lastQueries[0]['contain']));

$Controller->Paginator->settings = array(
'PaginatorControllerPost' => array(
Expand All @@ -475,14 +475,14 @@ public function testPaginateExtraParams() {
);
$result = $Controller->Paginator->paginate('PaginatorControllerPost');
$this->assertEquals(array(2, 3), Hash::extract($result, '{n}.PaginatorControllerPost.id'));
$this->assertEquals(array('PaginatorControllerPost.id > ' => '1'), $Controller->PaginatorControllerPost->lastQueries[1]['conditions']);
$this->assertEquals(array('PaginatorControllerPost.id > ' => '1'), $Controller->PaginatorControllerPost->lastQueries[0]['conditions']);

$Controller->request->params['named'] = array('limit' => 12);
$Controller->Paginator->settings = array('limit' => 30, 'maxLimit' => 100, 'paramType' => 'named');
$result = $Controller->Paginator->paginate('PaginatorControllerPost');
$paging = $Controller->params['paging']['PaginatorControllerPost'];

$this->assertEquals(12, $Controller->PaginatorControllerPost->lastQueries[1]['limit']);
$this->assertEquals(12, $Controller->PaginatorControllerPost->lastQueries[0]['limit']);
$this->assertEquals(12, $paging['options']['limit']);

$Controller = new PaginatorTestController($this->request);
Expand Down Expand Up @@ -551,7 +551,7 @@ public function testPaginateSpecialType() {

$this->assertEquals(array(2, 3), Hash::extract($result, '{n}.PaginatorControllerPost.id'));
$this->assertEquals(
$Controller->PaginatorControllerPost->lastQueries[1]['conditions'],
$Controller->PaginatorControllerPost->lastQueries[0]['conditions'],
array('PaginatorControllerPost.id > ' => '1')
);
$this->assertFalse(isset($Controller->params['paging']['PaginatorControllerPost']['options'][0]));
Expand Down

0 comments on commit 2e4d6eb

Please sign in to comment.