Permalink
Browse files

Merge branch 'master' into 2.3

Conflicts:
	lib/Cake/Console/Command/ConsoleShell.php
	lib/Cake/Network/CakeSocket.php
	lib/Cake/Network/Http/HttpResponse.php
	lib/Cake/Utility/Folder.php
	lib/Cake/View/MediaView.php
	lib/Cake/basics.php
  • Loading branch information...
2 parents 165035f + 587c707 commit 27d7e2865e27122d0cc567a8e292caed5c9da618 @markstory markstory committed Nov 21, 2012
Showing with 156 additions and 53 deletions.
  1. +3 −3 build.xml
  2. +11 −1 lib/Cake/Console/Command/ConsoleShell.php
  3. +0 −1 lib/Cake/Console/Command/Task/TemplateTask.php
  4. +1 −0 lib/Cake/Console/ConsoleOptionParser.php
  5. +2 −0 lib/Cake/Console/Shell.php
  6. +1 −1 lib/Cake/Controller/Controller.php
  7. +8 −0 lib/Cake/Error/exceptions.php
  8. +0 −1 lib/Cake/I18n/Multibyte.php
  9. +0 −1 lib/Cake/Model/Behavior/TreeBehavior.php
  10. +0 −1 lib/Cake/Model/BehaviorCollection.php
  11. +0 −1 lib/Cake/Model/Datasource/DataSource.php
  12. +3 −1 lib/Cake/Model/Datasource/Database/Sqlite.php
  13. +2 −0 lib/Cake/Network/CakeResponse.php
  14. +2 −0 lib/Cake/Network/Email/MailTransport.php
  15. +0 −3 lib/Cake/Network/Http/HttpSocket.php
  16. +6 −2 lib/Cake/Test/Case/BasicsTest.php
  17. +2 −0 lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php
  18. +20 −1 lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php
  19. +6 −2 lib/Cake/Test/Case/Core/ConfigureTest.php
  20. +10 −4 lib/Cake/Test/Case/Error/ErrorHandlerTest.php
  21. +1 −1 lib/Cake/Test/Case/Log/CakeLogTest.php
  22. +0 −1 lib/Cake/Test/Case/Model/ModelReadTest.php
  23. +5 −5 lib/Cake/Test/Case/Network/CakeResponseTest.php
  24. +0 −1 lib/Cake/Test/Case/Network/Http/HttpSocketTest.php
  25. +0 −1 lib/Cake/Test/Case/Routing/RouterTest.php
  26. +3 −0 lib/Cake/Test/Case/Utility/SetTest.php
  27. +1 −0 lib/Cake/Test/Case/Utility/XmlTest.php
  28. +5 −1 lib/Cake/Test/Case/View/Helper/JsHelperTest.php
  29. +3 −3 lib/Cake/Test/Case/View/ScaffoldViewTest.php
  30. +3 −1 lib/Cake/Test/Case/View/ViewTest.php
  31. +1 −1 lib/Cake/TestSuite/CakeTestCase.php
  32. +2 −0 lib/Cake/TestSuite/CakeTestSuiteCommand.php
  33. +4 −4 lib/Cake/TestSuite/ControllerTestCase.php
  34. +4 −1 lib/Cake/Utility/Debugger.php
  35. +12 −0 lib/Cake/Utility/Folder.php
  36. +1 −1 lib/Cake/Utility/ObjectCollection.php
  37. +0 −1 lib/Cake/Utility/Security.php
  38. +1 −1 lib/Cake/Utility/Set.php
  39. +10 −3 lib/Cake/Utility/Xml.php
  40. +6 −3 lib/Cake/View/Helper.php
  41. +3 −1 lib/Cake/View/View.php
  42. +14 −0 lib/Cake/basics.php
View
@@ -197,7 +197,7 @@
<!--
Upload to pirum pear channel.
-->
- <target name="distribute" depends="prepare">
+ <target name="distribute" depends="prepare" description="Upload pear packages to pear.cakephp.org">
<echo msg="Uploading tgz file to cakephp.org" />
<exec command="scp ${dist.dir}/${pear.package}.tgz cakephp@cakephp.org:${pirum.dir}" dir="." checkreturn="true" />
@@ -208,7 +208,7 @@
<!--
Top level easy to type targets
-->
- <target name="build" depends="generate-package" />
- <target name="release" depends="release-commit,build,distribute" />
+ <target name="build" depends="generate-package" description="Generate a pear package" />
+ <target name="release" depends="release-commit,build,distribute" description="Release a new version of CakePHP" />
</project>
@@ -238,7 +238,9 @@ public function main($command = null) {
if ($this->_isValidModel($modelToCheck)) {
$findCommand = "\$data = \$this->$command;";
+ //@codingStandardsIgnoreStart
@eval($findCommand);
+ //@codingStandardsIgnoreEnd
if (is_array($data)) {
foreach ($data as $idx => $results) {
@@ -294,7 +296,9 @@ public function main($command = null) {
list($foo, $data) = explode("->save", $command);
$data = preg_replace('/^\(*(array)?\(*(.+?)\)*$/i', '\\2', $data);
$saveCommand = "\$this->{$modelToSave}->save(array('{$modelToSave}' => array({$data})));";
+ //@codingStandardsIgnoreStart
@eval($saveCommand);
+ //@codingStandardsIgnoreEnd
$this->out(__d('cake_console', 'Saved record for %s', $modelToSave));
}
break;
@@ -304,7 +308,9 @@ public function main($command = null) {
if ($this->_isValidModel($modelToCheck)) {
// Get the column info for this model
$fieldsCommand = "\$data = \$this->{$modelToCheck}->getColumnTypes();";
+ //@codingStandardsIgnoreStart
@eval($fieldsCommand);
+ //@codingStandardsIgnoreEnd
if (is_array($data)) {
foreach ($data as $field => $type) {
@@ -325,8 +331,10 @@ public function main($command = null) {
case preg_match("/^routes\s+show/i", $command, $tmp):
$this->out(print_r(Hash::combine(Router::$routes, '{n}.template', '{n}.defaults'), true));
break;
- case preg_match("/^route\s+(\(.*\))$/i", $command, $tmp):
+ case (preg_match("/^route\s+(\(.*\))$/i", $command, $tmp) == true):
+ //@codingStandardsIgnoreStart
if ($url = eval('return array' . $tmp[1] . ';')) {
+ //@codingStandardsIgnoreEnd
$this->out(Router::url($url));
}
break;
@@ -362,7 +370,9 @@ protected function _loadRoutes() {
Router::reload();
extract(Router::getNamedExpressions());
+ //@codingStandardsIgnoreStart
if (!@include APP . 'Config' . DS . 'routes.php') {
+ //@codingStandardsIgnoreEnd
return false;
}
CakePlugin::routes();
@@ -78,7 +78,6 @@ protected function _findThemes() {
$paths[] = $core;
- // TEMPORARY TODO remove when all paths are DS terminated
foreach ($paths as $i => $path) {
$paths[$i] = rtrim($path, DS) . DS;
}
@@ -345,6 +345,7 @@ public function addArgument($name, $params = array()) {
$arg = new ConsoleInputArgument($options);
}
$this->_args[$index] = $arg;
+ ksort($this->_args);
return $this;
}
@@ -686,7 +686,9 @@ public function createFile($path, $contents) {
protected function _checkUnitTest() {
if (class_exists('PHPUnit_Framework_TestCase')) {
return true;
+ //@codingStandardsIgnoreStart
} elseif (@include 'PHPUnit' . DS . 'Autoload.php') {
+ //@codingStandardsIgnoreEnd
return true;
} elseif (App::import('Vendor', 'phpunit', array('file' => 'PHPUnit' . DS . 'Autoload.php'))) {
return true;
@@ -755,7 +755,7 @@ public function redirect($url, $status = null, $exit = true) {
extract($status, EXTR_OVERWRITE);
}
$event = new CakeEvent('Controller.beforeRedirect', $this, array($url, $status, $exit));
- //TODO: Remove the following line when the events are fully migrated to the CakeEventManager
+
list($event->break, $event->breakOn, $event->collectReturn) = array(true, false, true);
$this->getEventManager()->dispatch($event);
@@ -261,9 +261,11 @@ class MissingControllerException extends CakeException {
protected $_messageTemplate = 'Controller class %s could not be found.';
+//@codingStandardsIgnoreStart
public function __construct($message, $code = 404) {
parent::__construct($message, $code);
}
+//@codingStandardsIgnoreEnd
}
@@ -277,9 +279,11 @@ class MissingActionException extends CakeException {
protected $_messageTemplate = 'Action %s::%s() could not be found.';
+//@codingStandardsIgnoreStart
public function __construct($message, $code = 404) {
parent::__construct($message, $code);
}
+//@codingStandardsIgnoreEnd
}
@@ -293,9 +297,11 @@ class PrivateActionException extends CakeException {
protected $_messageTemplate = 'Private Action %s::%s() is not directly accessible.';
+//@codingStandardsIgnoreStart
public function __construct($message, $code = 404, Exception $previous = null) {
parent::__construct($message, $code, $previous);
}
+//@codingStandardsIgnoreEnd
}
@@ -609,8 +615,10 @@ class NotImplementedException extends CakeException {
protected $_messageTemplate = '%s is not implemented.';
+//@codingStandardsIgnoreStart
public function __construct($message, $code = 501) {
parent::__construct($message, $code);
}
+//@codingStandardsIgnoreEnd
}
@@ -732,7 +732,6 @@ public static function substr($string, $start, $length = null) {
* @param string $charset charset to use for encoding. defaults to UTF-8
* @param string $newline
* @return string
- * @TODO: add support for 'Q'('Quoted Printable') encoding
*/
public static function mimeEncode($string, $charset = null, $newline = "\r\n") {
if (!Multibyte::checkMultibyte($string) && strlen($string) < 75) {
@@ -588,7 +588,6 @@ public function moveUp(Model $Model, $id = null, $number = 1) {
* 'parent' the values of the parent_id field will be used to populate the left and right fields. The missingParentAction
* parameter only applies to "parent" mode and determines what to do if the parent field contains an id that is not present.
*
- * @todo Could be written to be faster, *maybe*. Ideally using a subquery and putting all the logic burden on the DB.
* @param Model $Model Model instance
* @param string $mode parent or tree
* @param string|integer $missingParentAction 'return' to do nothing and return, 'delete' to
@@ -55,7 +55,6 @@ class BehaviorCollection extends ObjectCollection implements CakeEventListener {
/**
* Attaches a model object and loads a list of behaviors
*
- * @todo Make this method a constructor instead..
* @param string $modelName
* @param array $behaviors
* @return void
@@ -322,7 +322,6 @@ protected function _cacheDescription($object, $data = null) {
* @param Model $linkModel Instance of model to replace $__cakeForeignKey__$
* @param array $stack
* @return string String of query data with placeholders replaced.
- * @todo Remove and refactor $assocData, ensure uses of the method have the param removed too.
*/
public function insertQueryData($query, $data, $association, $assocData, Model $model, Model $linkModel, $stack) {
$keys = array('{$__cakeID__$}', '{$__cakeForeignKey__$}');
@@ -250,7 +250,9 @@ public function column($real) {
$col = strtolower(str_replace(')', '', $real));
$limit = null;
- @list($col, $limit) = explode('(', $col);
+ if (strpos($col, '(') !== false) {
+ list($col, $limit) = explode('(', $col);
+ }
$standard = array(
'text',
@@ -446,6 +446,8 @@ protected function _setContentType() {
}
if (strpos($this->_contentType, 'text/') === 0) {
$this->header('Content-Type', "{$this->_contentType}; charset={$this->_charset}");
+ } elseif ($this->_contentType === 'application/json') {
+ $this->header('Content-Type', "{$this->_contentType}; charset=UTF-8");
} else {
$this->header('Content-Type', "{$this->_contentType}");
}
@@ -63,9 +63,11 @@ public function send(CakeEmail $email) {
* @return void
*/
protected function _mail($to, $subject, $message, $headers, $params = null) {
+ //@codingStandardsIgnoreStart
if (!@mail($to, $subject, $message, $headers, $params)) {
throw new SocketException(__d('cake_dev', 'Could not send email.'));
}
+ //@codingStandardsIgnoreEnd
}
}
@@ -935,7 +935,6 @@ protected function _buildHeader($header, $mode = 'standard') {
*
* @param array $cookies Array of cookies to send with the request.
* @return string Cookie header string to be sent with the request.
- * @todo Refactor token escape mechanism to be configurable
*/
public function buildCookies($cookies) {
$header = array();
@@ -951,7 +950,6 @@ public function buildCookies($cookies) {
* @param string $token Token to escape
* @param array $chars
* @return string Escaped token
- * @todo Test $chars parameter
*/
protected function _escapeToken($token, $chars = null) {
$regex = '/([' . implode('', $this->_tokenEscapeChars(true, $chars)) . '])/';
@@ -965,7 +963,6 @@ protected function _escapeToken($token, $chars = null) {
* @param boolean $hex true to get them as HEX values, false otherwise
* @param array $chars
* @return array Escape chars
- * @todo Test $chars parameter
*/
protected function _tokenEscapeChars($hex = true, $chars = null) {
if (!empty($chars)) {
@@ -282,7 +282,9 @@ public function testCache() {
$result = cache('basics_test');
$this->assertEquals('simple cache write', $result);
- @unlink(CACHE . 'basics_test');
+ if (file_exists(CACHE . 'basics_test')) {
+ unlink(CACHE . 'basics_test');
+ }
cache('basics_test', 'expired', '+1 second');
sleep(2);
@@ -603,7 +605,9 @@ public function testTranslateDomainCategoryPlural() {
* @return void
*/
public function testLogError() {
- @unlink(LOGS . 'error.log');
+ if (file_exists(LOGS . 'error.log')) {
+ unlink(LOGS . 'error.log');
+ }
// disable stderr output for this test
if (CakeLog::stream('stderr')) {
@@ -111,9 +111,11 @@ public function testMultipleServers() {
foreach ($servers as $server) {
list($host, $port) = explode(':', $server);
+ //@codingStandardsIgnoreStart
if (!@$Memcache->connect($host, $port)) {
$available = false;
}
+ //@codingStandardsIgnoreEnd
}
$this->skipIf(!$available, 'Need memcache servers at ' . implode(', ', $servers) . ' to run this test.');
@@ -314,11 +314,30 @@ public function testAddArgumentObject() {
$parser = new ConsoleOptionParser('test', false);
$parser->addArgument(new ConsoleInputArgument('test'));
$result = $parser->arguments();
- $this->assertEquals(1, count($result));
+ $this->assertCount(1, $result);
$this->assertEquals('test', $result[0]->name());
}
/**
+ * Test adding arguments out of order.
+ *
+ * @return void
+ */
+ public function testAddArgumentOutOfOrder() {
+ $parser = new ConsoleOptionParser('test', false);
+ $parser->addArgument('name', array('index' => 1, 'help' => 'first argument'))
+ ->addArgument('bag', array('index' => 2, 'help' => 'second argument'))
+ ->addArgument('other', array('index' => 0, 'help' => 'Zeroth argument'));
+
+ $result = $parser->arguments();
+ $this->assertCount(3, $result);
+ $this->assertEquals('other', $result[0]->name());
+ $this->assertEquals('name', $result[1]->name());
+ $this->assertEquals('bag', $result[2]->name());
+ $this->assertSame(array(0, 1, 2), array_keys($result));
+ }
+
+/**
* test overwriting positional arguments.
*
* @return void
@@ -437,7 +437,9 @@ public function testDump() {
$result = file_get_contents(TMP . 'config_test.php');
$this->assertContains('<?php', $result);
$this->assertContains('$config = ', $result);
- @unlink(TMP . 'config_test.php');
+ if (file_exists(TMP . 'config_test.php')) {
+ unlink(TMP . 'config_test.php');
+ }
}
/**
@@ -456,7 +458,9 @@ public function testDumpPartial() {
$this->assertContains('Error', $result);
$this->assertNotContains('debug', $result);
- @unlink(TMP . 'config_test.php');
+ if (file_exists(TMP . 'config_test.php')) {
+ unlink(TMP . 'config_test.php');
+ }
}
}
@@ -124,7 +124,9 @@ public function testErrorSuppressed() {
$this->_restoreError = true;
ob_start();
+ //@codingStandardsIgnoreStart
@include 'invalid.file';
+ //@codingStandardsIgnoreEnd
$result = ob_get_clean();
$this->assertTrue(empty($result));
}
@@ -138,7 +140,7 @@ public function testHandleErrorDebugOff() {
Configure::write('debug', 0);
Configure::write('Error.trace', false);
if (file_exists(LOGS . 'debug.log')) {
- @unlink(LOGS . 'debug.log');
+ unlink(LOGS . 'debug.log');
}
set_error_handler('ErrorHandler::handleError');
@@ -152,7 +154,9 @@ public function testHandleErrorDebugOff() {
'/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} (Notice|Debug): Notice \(8\): Undefined variable:\s+out in \[.+ line \d+\]$/',
$result[0]
);
- @unlink(LOGS . 'debug.log');
+ if (file_exists(LOGS . 'debug.log')) {
+ unlink(LOGS . 'debug.log');
+ }
}
/**
@@ -164,7 +168,7 @@ public function testHandleErrorLoggingTrace() {
Configure::write('debug', 0);
Configure::write('Error.trace', true);
if (file_exists(LOGS . 'debug.log')) {
- @unlink(LOGS . 'debug.log');
+ unlink(LOGS . 'debug.log');
}
set_error_handler('ErrorHandler::handleError');
@@ -179,7 +183,9 @@ public function testHandleErrorLoggingTrace() {
);
$this->assertRegExp('/^Trace:/', $result[1]);
$this->assertRegExp('/^ErrorHandlerTest\:\:testHandleErrorLoggingTrace\(\)/', $result[2]);
- @unlink(LOGS . 'debug.log');
+ if (file_exists(LOGS . 'debug.log')) {
+ unlink(LOGS . 'debug.log');
+ }
}
/**
@@ -150,7 +150,7 @@ public function testConfig() {
$this->assertEquals(array('file'), $result);
if (file_exists(LOGS . 'error.log')) {
- @unlink(LOGS . 'error.log');
+ unlink(LOGS . 'error.log');
}
CakeLog::write(LOG_WARNING, 'Test warning');
$this->assertTrue(file_exists(LOGS . 'error.log'));
@@ -4054,7 +4054,6 @@ public function testSaveEmpty() {
/**
* testFindAllWithConditionInChildQuery
*
- * @todo external conditions like this are going to need to be revisited at some point
* @return void
*/
public function testFindAllWithConditionInChildQuery() {
Oops, something went wrong.

0 comments on commit 27d7e28

Please sign in to comment.