From 56225bcca3aca9959d072641aef7639390f119af Mon Sep 17 00:00:00 2001 From: Ceeram Date: Wed, 14 Nov 2012 10:00:15 +0100 Subject: [PATCH 01/11] fix all warnings except TODO warnings --- lib/Cake/Console/Command/ConsoleShell.php | 10 ++++++++++ lib/Cake/Console/Shell.php | 2 ++ lib/Cake/Error/exceptions.php | 8 ++++++++ lib/Cake/Model/Datasource/Database/Sqlite.php | 4 +++- lib/Cake/Network/CakeSocket.php | 2 ++ lib/Cake/Network/Email/MailTransport.php | 2 ++ lib/Cake/Test/Case/BasicsTest.php | 8 ++++++-- .../Test/Case/Cache/Engine/MemcacheEngineTest.php | 2 ++ lib/Cake/Test/Case/Core/ConfigureTest.php | 8 ++++++-- lib/Cake/Test/Case/Error/ErrorHandlerTest.php | 14 ++++++++++---- lib/Cake/Test/Case/Log/CakeLogTest.php | 2 +- lib/Cake/Test/Case/View/Helper/JsHelperTest.php | 6 +++++- lib/Cake/Test/Case/View/ViewTest.php | 4 +++- lib/Cake/TestSuite/CakeTestSuiteCommand.php | 2 ++ lib/Cake/TestSuite/ControllerTestCase.php | 8 ++++---- lib/Cake/Utility/Debugger.php | 5 ++++- lib/Cake/Utility/Folder.php | 12 ++++++++++++ lib/Cake/View/Helper.php | 6 ++++++ lib/Cake/View/MediaView.php | 6 ++++++ lib/Cake/View/View.php | 2 ++ lib/Cake/basics.php | 14 ++++++++++++++ 21 files changed, 110 insertions(+), 17 deletions(-) diff --git a/lib/Cake/Console/Command/ConsoleShell.php b/lib/Cake/Console/Command/ConsoleShell.php index d8c79c933..31736bbdd 100644 --- a/lib/Cake/Console/Command/ConsoleShell.php +++ b/lib/Cake/Console/Command/ConsoleShell.php @@ -238,7 +238,9 @@ class ConsoleShell extends AppShell { 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 @@ class ConsoleShell extends AppShell { 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 @@ class ConsoleShell extends AppShell { 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) { @@ -326,7 +332,9 @@ class ConsoleShell extends AppShell { $this->out(print_r(Hash::combine(Router::$routes, '{n}.template', '{n}.defaults'), true)); break; 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 @@ class ConsoleShell extends AppShell { Router::reload(); extract(Router::getNamedExpressions()); + //@codingStandardsIgnoreStart if (!@include APP . 'Config' . DS . 'routes.php') { + //@codingStandardsIgnoreEnd return false; } CakePlugin::routes(); diff --git a/lib/Cake/Console/Shell.php b/lib/Cake/Console/Shell.php index 74e5e033b..bf4f18877 100644 --- a/lib/Cake/Console/Shell.php +++ b/lib/Cake/Console/Shell.php @@ -686,7 +686,9 @@ class Shell extends Object { 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; diff --git a/lib/Cake/Error/exceptions.php b/lib/Cake/Error/exceptions.php index 94952f12e..4f0fe9843 100644 --- a/lib/Cake/Error/exceptions.php +++ b/lib/Cake/Error/exceptions.php @@ -224,9 +224,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 } @@ -240,9 +242,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 } @@ -256,9 +260,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 } @@ -572,8 +578,10 @@ class NotImplementedException extends CakeException { protected $_messageTemplate = '%s is not implemented.'; +//@codingStandardsIgnoreStart public function __construct($message, $code = 501) { parent::__construct($message, $code); } +//@codingStandardsIgnoreEnd } diff --git a/lib/Cake/Model/Datasource/Database/Sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php index d30cc67df..0990e4a3c 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlite.php +++ b/lib/Cake/Model/Datasource/Database/Sqlite.php @@ -249,7 +249,9 @@ class Sqlite extends DboSource { $col = strtolower(str_replace(')', '', $real)); $limit = null; - @list($col, $limit) = explode('(', $col); + if (strpos($col, '(') !== false) { + list($col, $limit) = explode('(', $col); + } if (in_array($col, array('text', 'integer', 'float', 'boolean', 'timestamp', 'date', 'datetime', 'time'))) { return $col; diff --git a/lib/Cake/Network/CakeSocket.php b/lib/Cake/Network/CakeSocket.php index aa0eb4fbd..37fc02e50 100644 --- a/lib/Cake/Network/CakeSocket.php +++ b/lib/Cake/Network/CakeSocket.php @@ -105,11 +105,13 @@ class CakeSocket { $scheme = 'ssl://'; } + //@codingStandardsIgnoreStart if ($this->config['persistent'] == true) { $this->connection = @pfsockopen($scheme . $this->config['host'], $this->config['port'], $errNum, $errStr, $this->config['timeout']); } else { $this->connection = @fsockopen($scheme . $this->config['host'], $this->config['port'], $errNum, $errStr, $this->config['timeout']); } + //@codingStandardsIgnoreEnd if (!empty($errNum) || !empty($errStr)) { $this->setLastError($errNum, $errStr); diff --git a/lib/Cake/Network/Email/MailTransport.php b/lib/Cake/Network/Email/MailTransport.php index 2b849772a..a037e3418 100644 --- a/lib/Cake/Network/Email/MailTransport.php +++ b/lib/Cake/Network/Email/MailTransport.php @@ -63,9 +63,11 @@ class MailTransport extends AbstractTransport { * @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 } } diff --git a/lib/Cake/Test/Case/BasicsTest.php b/lib/Cake/Test/Case/BasicsTest.php index 0998dfa77..10dd24cf4 100644 --- a/lib/Cake/Test/Case/BasicsTest.php +++ b/lib/Cake/Test/Case/BasicsTest.php @@ -282,7 +282,9 @@ class BasicsTest extends CakeTestCase { $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 @@ class BasicsTest extends CakeTestCase { * @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')) { diff --git a/lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php index 54c225c72..27453d84e 100644 --- a/lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php @@ -111,9 +111,11 @@ class MemcacheEngineTest extends CakeTestCase { 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.'); diff --git a/lib/Cake/Test/Case/Core/ConfigureTest.php b/lib/Cake/Test/Case/Core/ConfigureTest.php index 7351f83f1..224e7b5e9 100644 --- a/lib/Cake/Test/Case/Core/ConfigureTest.php +++ b/lib/Cake/Test/Case/Core/ConfigureTest.php @@ -383,7 +383,9 @@ class ConfigureTest extends CakeTestCase { $result = file_get_contents(TMP . 'config_test.php'); $this->assertContains('assertContains('$config = ', $result); - @unlink(TMP . 'config_test.php'); + if (file_exists(TMP . 'config_test.php')) { + unlink(TMP . 'config_test.php'); + } } /** @@ -402,7 +404,9 @@ class ConfigureTest extends CakeTestCase { $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'); + } } } diff --git a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php index e4bd57902..4945533ff 100644 --- a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php +++ b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php @@ -124,7 +124,9 @@ class ErrorHandlerTest extends CakeTestCase { $this->_restoreError = true; ob_start(); + //@codingStandardsIgnoreStart @include 'invalid.file'; + //@codingStandardsIgnoreEnd $result = ob_get_clean(); $this->assertTrue(empty($result)); } @@ -138,7 +140,7 @@ class ErrorHandlerTest extends CakeTestCase { 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 @@ class ErrorHandlerTest extends CakeTestCase { '/^\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 @@ class ErrorHandlerTest extends CakeTestCase { 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 @@ class ErrorHandlerTest extends CakeTestCase { ); $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'); + } } /** diff --git a/lib/Cake/Test/Case/Log/CakeLogTest.php b/lib/Cake/Test/Case/Log/CakeLogTest.php index 1226dde7e..13d90989f 100644 --- a/lib/Cake/Test/Case/Log/CakeLogTest.php +++ b/lib/Cake/Test/Case/Log/CakeLogTest.php @@ -150,7 +150,7 @@ class CakeLogTest extends CakeTestCase { $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')); diff --git a/lib/Cake/Test/Case/View/Helper/JsHelperTest.php b/lib/Cake/Test/Case/View/Helper/JsHelperTest.php index 47833e085..53b8cce97 100644 --- a/lib/Cake/Test/Case/View/Helper/JsHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/JsHelperTest.php @@ -29,7 +29,9 @@ class JsEncodingObject { protected $_title = 'Old thing'; + //@codingStandardsIgnoreStart private $__noshow = 'Never ever'; + //@codingStandardsIgnoreEnd } @@ -366,7 +368,9 @@ class JsHelperTest extends CakeTestCase { $this->assertTrue(file_exists(WWW_ROOT . $filename[1])); $contents = file_get_contents(WWW_ROOT . $filename[1]); $this->assertRegExp('/one\s=\s1;\ntwo\s=\s2;/', $contents); - @unlink(WWW_ROOT . $filename[1]); + if (file_exists(WWW_ROOT . $filename[1])) { + unlink(WWW_ROOT . $filename[1]); + } Configure::write('Cache.disable', true); $this->Js->buffer('one = 1;'); diff --git a/lib/Cake/Test/Case/View/ViewTest.php b/lib/Cake/Test/Case/View/ViewTest.php index 75875349d..ffcbb3ef9 100644 --- a/lib/Cake/Test/Case/View/ViewTest.php +++ b/lib/Cake/Test/Case/View/ViewTest.php @@ -1101,7 +1101,9 @@ class ViewTest extends CakeTestCase { $this->assertRegExp('/^some cacheText/', $result); - @unlink($path); + if (file_exists($path)) { + unlink($path); + } } /** diff --git a/lib/Cake/TestSuite/CakeTestSuiteCommand.php b/lib/Cake/TestSuite/CakeTestSuiteCommand.php index 6d410ec79..f655c7fda 100644 --- a/lib/Cake/TestSuite/CakeTestSuiteCommand.php +++ b/lib/Cake/TestSuite/CakeTestSuiteCommand.php @@ -82,7 +82,9 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { $result = $skeleton->generate(true); if (!$result['incomplete']) { + //@codingStandardsIgnoreStart eval(str_replace(array(''), '', $result['code'])); + //@codingStandardsIgnoreEnd $suite = new PHPUnit_Framework_TestSuite( $this->arguments['test'] . 'Test' ); diff --git a/lib/Cake/TestSuite/ControllerTestCase.php b/lib/Cake/TestSuite/ControllerTestCase.php index d989553f7..fd44b8cb5 100644 --- a/lib/Cake/TestSuite/ControllerTestCase.php +++ b/lib/Cake/TestSuite/ControllerTestCase.php @@ -173,7 +173,7 @@ abstract class ControllerTestCase extends CakeTestCase { * * @var boolean */ - private $__dirtyController = false; + protected $_dirtyController = false; /** * Used to enable calling ControllerTestCase::testAction() without the testing @@ -252,7 +252,7 @@ abstract class ControllerTestCase extends CakeTestCase { $this->headers = Router::currentRoute()->response->header(); return; } - if ($this->__dirtyController) { + if ($this->_dirtyController) { $this->controller = null; } @@ -275,7 +275,7 @@ abstract class ControllerTestCase extends CakeTestCase { if (isset($this->controller->View)) { $this->view = $this->controller->View->fetch('__view_no_layout__'); } - $this->__dirtyController = true; + $this->_dirtyController = true; $this->headers = $Dispatch->response->header(); $_GET = $restore['get']; @@ -371,7 +371,7 @@ abstract class ControllerTestCase extends CakeTestCase { } $_controller->constructClasses(); - $this->__dirtyController = false; + $this->_dirtyController = false; $this->controller = $_controller; return $this->controller; diff --git a/lib/Cake/Utility/Debugger.php b/lib/Cake/Utility/Debugger.php index 7c6b2ba12..0fe8a384b 100644 --- a/lib/Cake/Utility/Debugger.php +++ b/lib/Cake/Utility/Debugger.php @@ -395,7 +395,10 @@ class Debugger { if (!file_exists($file)) { return array(); } - $data = @explode("\n", file_get_contents($file)); + $data = file_get_contents($file); + if (!empty($data) && strpos($data, "\n") !== false) { + $data = explode("\n", $data); + } if (empty($data) || !isset($data[$line])) { return; diff --git a/lib/Cake/Utility/Folder.php b/lib/Cake/Utility/Folder.php index bda485869..c673177ab 100644 --- a/lib/Cake/Utility/Folder.php +++ b/lib/Cake/Utility/Folder.php @@ -354,7 +354,9 @@ class Folder { } if ($recursive === false && is_dir($path)) { + //@codingStandardsIgnoreStart if (@chmod($path, intval($mode, 8))) { + //@codingStandardsIgnoreEnd $this->_messages[] = __d('cake_dev', '%s changed to %s', $path, $mode); return true; } @@ -375,7 +377,9 @@ class Folder { continue; } + //@codingStandardsIgnoreStart if (@chmod($fullpath, intval($mode, 8))) { + //@codingStandardsIgnoreEnd $this->_messages[] = __d('cake_dev', '%s changed to %s', $fullpath, $mode); } else { $this->_errors[] = __d('cake_dev', '%s NOT changed to %s', $fullpath, $mode); @@ -559,13 +563,17 @@ class Folder { foreach ($iterator as $item) { $filePath = $item->getPathname(); if ($item->isFile() || $item->isLink()) { + //@codingStandardsIgnoreStart if (@unlink($filePath)) { + //@codingStandardsIgnoreEnd $this->_messages[] = __d('cake_dev', '%s removed', $filePath); } else { $this->_errors[] = __d('cake_dev', '%s NOT removed', $filePath); } } elseif ($item->isDir() && !$item->isDot()) { + //@codingStandardsIgnoreStart if (@rmdir($filePath)) { + //@codingStandardsIgnoreEnd $this->_messages[] = __d('cake_dev', '%s removed', $filePath); } else { $this->_errors[] = __d('cake_dev', '%s NOT removed', $filePath); @@ -575,7 +583,9 @@ class Folder { } $path = rtrim($path, DS); + //@codingStandardsIgnoreStart if (@rmdir($path)) { + //@codingStandardsIgnoreEnd $this->_messages[] = __d('cake_dev', '%s removed', $path); } else { $this->_errors[] = __d('cake_dev', '%s NOT removed', $path); @@ -629,7 +639,9 @@ class Folder { } $exceptions = array_merge(array('.', '..', '.svn'), $options['skip']); + //@codingStandardsIgnoreStart if ($handle = @opendir($fromDir)) { + //@codingStandardsIgnoreEnd while (false !== ($item = readdir($handle))) { if (!in_array($item, $exceptions)) { $from = Folder::addPathElement($fromDir, $item); diff --git a/lib/Cake/View/Helper.php b/lib/Cake/View/Helper.php index bb16ec6d5..1ab88dad6 100644 --- a/lib/Cake/View/Helper.php +++ b/lib/Cake/View/Helper.php @@ -340,20 +340,26 @@ class Helper extends Object { $filepath = preg_replace('/^' . preg_quote($this->request->webroot, '/') . '/', '', $path); $webrootPath = WWW_ROOT . str_replace('/', DS, $filepath); if (file_exists($webrootPath)) { + //@codingStandardsIgnoreStart return $path . '?' . @filemtime($webrootPath); + //@codingStandardsIgnoreEnd } $segments = explode('/', ltrim($filepath, '/')); if ($segments[0] === 'theme') { $theme = $segments[1]; unset($segments[0], $segments[1]); $themePath = App::themePath($theme) . 'webroot' . DS . implode(DS, $segments); + //@codingStandardsIgnoreStart return $path . '?' . @filemtime($themePath); + //@codingStandardsIgnoreEnd } else { $plugin = Inflector::camelize($segments[0]); if (CakePlugin::loaded($plugin)) { unset($segments[0]); $pluginPath = CakePlugin::path($plugin) . 'webroot' . DS . implode(DS, $segments); + //@codingStandardsIgnoreStart return $path . '?' . @filemtime($pluginPath); + //@codingStandardsIgnoreEnd } } } diff --git a/lib/Cake/View/MediaView.php b/lib/Cake/View/MediaView.php index 9dec162f0..8ed331837 100644 --- a/lib/Cake/View/MediaView.php +++ b/lib/Cake/View/MediaView.php @@ -101,7 +101,9 @@ class MediaView extends View { if ($this->_isActive()) { $extension = strtolower($extension); + //@codingStandardsIgnoreStart $fileSize = @filesize($path); + //@codingStandardsIgnoreEnd $handle = fopen($path, 'rb'); if ($handle === false) { @@ -220,7 +222,9 @@ class MediaView extends View { * @return boolean */ protected function _clearBuffer() { + //@codingStandardsIgnoreStart return @ob_end_clean(); + //@codingStandardsIgnoreEnd } /** @@ -229,8 +233,10 @@ class MediaView extends View { * @return void */ protected function _flushBuffer() { + //@codingStandardsIgnoreStart @flush(); @ob_flush(); + //@codingStandardsIgnoreEnd } } diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index aedddd90f..881f2485b 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -562,7 +562,9 @@ class View extends Object { if (preg_match('/^/', $out, $match)) { if (time() >= $match['1']) { + //@codingStandardsIgnoreStart @unlink($filename); + //@codingStandardsIgnoreEnd unset ($out); return false; } else { diff --git a/lib/Cake/basics.php b/lib/Cake/basics.php index 1dc81245e..4f7c945f6 100644 --- a/lib/Cake/basics.php +++ b/lib/Cake/basics.php @@ -397,19 +397,27 @@ function cache($path, $data = null, $expires = '+1 day', $target = 'cache') { $filetime = false; if (file_exists($filename)) { + //@codingStandardsIgnoreStart $filetime = @filemtime($filename); + //@codingStandardsIgnoreEnd } if ($data === null) { if (file_exists($filename) && $filetime !== false) { if ($filetime + $timediff < $now) { + //@codingStandardsIgnoreStart @unlink($filename); + //@codingStandardsIgnoreEnd } else { + //@codingStandardsIgnoreStart $data = @file_get_contents($filename); + //@codingStandardsIgnoreEnd } } } elseif (is_writable(dirname($filename))) { + //@codingStandardsIgnoreStart @file_put_contents($filename, $data, LOCK_EX); + //@codingStandardsIgnoreEnd } return $data; } @@ -430,7 +438,9 @@ function clearCache($params = null, $type = 'views', $ext = '.php') { $cache = CACHE . $type . DS . $params; if (is_file($cache . $ext)) { + //@codingStandardsIgnoreStart @unlink($cache . $ext); + //@codingStandardsIgnoreEnd return true; } elseif (is_dir($cache)) { $files = glob($cache . '*'); @@ -441,7 +451,9 @@ function clearCache($params = null, $type = 'views', $ext = '.php') { foreach ($files as $file) { if (is_file($file) && strrpos($file, DS . 'empty') !== strlen($file) - 6) { + //@codingStandardsIgnoreStart @unlink($file); + //@codingStandardsIgnoreEnd } } return true; @@ -462,7 +474,9 @@ function clearCache($params = null, $type = 'views', $ext = '.php') { } foreach ($files as $file) { if (is_file($file) && strrpos($file, DS . 'empty') !== strlen($file) - 6) { + //@codingStandardsIgnoreStart @unlink($file); + //@codingStandardsIgnoreEnd } } return true; From e02eab05d5e598bc2af3489a4e4cba61a2419d36 Mon Sep 17 00:00:00 2001 From: Ceeram Date: Wed, 14 Nov 2012 13:16:08 +0100 Subject: [PATCH 02/11] Remove all todo from core, create tickets for them --- lib/Cake/Console/Command/Task/TemplateTask.php | 1 - lib/Cake/Controller/Controller.php | 2 +- lib/Cake/I18n/Multibyte.php | 1 - lib/Cake/Model/Behavior/TreeBehavior.php | 1 - lib/Cake/Model/BehaviorCollection.php | 1 - lib/Cake/Model/Datasource/DataSource.php | 1 - lib/Cake/Network/Http/HttpResponse.php | 10 ---------- lib/Cake/Network/Http/HttpSocket.php | 3 --- lib/Cake/Test/Case/Model/ModelReadTest.php | 1 - lib/Cake/Test/Case/Network/Http/HttpSocketTest.php | 1 - lib/Cake/Test/Case/Routing/RouterTest.php | 1 - lib/Cake/Test/Case/View/ScaffoldViewTest.php | 6 +++--- lib/Cake/TestSuite/CakeTestCase.php | 2 +- lib/Cake/Utility/ObjectCollection.php | 2 +- lib/Cake/Utility/Security.php | 1 - lib/Cake/View/Helper.php | 3 --- lib/Cake/View/View.php | 2 +- 17 files changed, 7 insertions(+), 32 deletions(-) diff --git a/lib/Cake/Console/Command/Task/TemplateTask.php b/lib/Cake/Console/Command/Task/TemplateTask.php index 69b4cdd39..6efa8bbc6 100644 --- a/lib/Cake/Console/Command/Task/TemplateTask.php +++ b/lib/Cake/Console/Command/Task/TemplateTask.php @@ -78,7 +78,6 @@ class TemplateTask extends AppShell { $paths[] = $core; - // TEMPORARY TODO remove when all paths are DS terminated foreach ($paths as $i => $path) { $paths[$i] = rtrim($path, DS) . DS; } diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index 8b3098998..d489927f5 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -755,7 +755,7 @@ class Controller extends Object implements CakeEventListener { 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); diff --git a/lib/Cake/I18n/Multibyte.php b/lib/Cake/I18n/Multibyte.php index eb4847aa4..5dc47f223 100644 --- a/lib/Cake/I18n/Multibyte.php +++ b/lib/Cake/I18n/Multibyte.php @@ -987,7 +987,6 @@ class Multibyte { * @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) { diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index 6895fe9d0..37e952b60 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -588,7 +588,6 @@ class TreeBehavior extends ModelBehavior { * '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 diff --git a/lib/Cake/Model/BehaviorCollection.php b/lib/Cake/Model/BehaviorCollection.php index fff3e7d5b..56be23eac 100644 --- a/lib/Cake/Model/BehaviorCollection.php +++ b/lib/Cake/Model/BehaviorCollection.php @@ -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 diff --git a/lib/Cake/Model/Datasource/DataSource.php b/lib/Cake/Model/Datasource/DataSource.php index af65276ce..c04e6771a 100644 --- a/lib/Cake/Model/Datasource/DataSource.php +++ b/lib/Cake/Model/Datasource/DataSource.php @@ -322,7 +322,6 @@ class DataSource extends Object { * @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__$}'); diff --git a/lib/Cake/Network/Http/HttpResponse.php b/lib/Cake/Network/Http/HttpResponse.php index dec507041..90c622588 100644 --- a/lib/Cake/Network/Http/HttpResponse.php +++ b/lib/Cake/Network/Http/HttpResponse.php @@ -219,7 +219,6 @@ class HttpResponse implements ArrayAccess { $chunkSize = 0; $hexLength = 0; - $chunkExtensionName = ''; $chunkExtensionValue = ''; if (isset($match[0])) { $chunkSize = $match[0]; @@ -227,9 +226,6 @@ class HttpResponse implements ArrayAccess { if (isset($match[1])) { $hexLength = $match[1]; } - if (isset($match[2])) { - $chunkExtensionName = $match[2]; - } if (isset($match[3])) { $chunkExtensionValue = $match[3]; } @@ -237,9 +233,6 @@ class HttpResponse implements ArrayAccess { $body = substr($body, strlen($chunkSize)); $chunkLength = hexdec($hexLength); $chunk = substr($body, 0, $chunkLength); - if (!empty($chunkExtensionName)) { - // @todo See if there are popular chunk extensions we should implement - } $decodedBody .= $chunk; if ($chunkLength !== 0) { $body = substr($body, $chunkLength + strlen("\r\n")); @@ -291,7 +284,6 @@ class HttpResponse implements ArrayAccess { * * @param array $header Header array containing one ore more 'Set-Cookie' headers. * @return mixed Either false on no cookies, or an array of cookies received. - * @todo Make this 100% RFC 2965 confirm */ public function parseCookies($header) { $cookieHeader = $this->getHeader('Set-Cookie', $header); @@ -334,7 +326,6 @@ class HttpResponse implements ArrayAccess { * @param string $token Token to unescape * @param array $chars * @return string Unescaped token - * @todo Test $chars parameter */ protected function _unescapeToken($token, $chars = null) { $regex = '/"([' . implode('', $this->_tokenEscapeChars(true, $chars)) . '])"/'; @@ -348,7 +339,6 @@ class HttpResponse implements ArrayAccess { * @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)) { diff --git a/lib/Cake/Network/Http/HttpSocket.php b/lib/Cake/Network/Http/HttpSocket.php index bda8ec4c7..44960cd50 100644 --- a/lib/Cake/Network/Http/HttpSocket.php +++ b/lib/Cake/Network/Http/HttpSocket.php @@ -901,7 +901,6 @@ class HttpSocket extends CakeSocket { * * @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(); @@ -917,7 +916,6 @@ class HttpSocket extends CakeSocket { * @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)) . '])/'; @@ -931,7 +929,6 @@ class HttpSocket extends CakeSocket { * @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)) { diff --git a/lib/Cake/Test/Case/Model/ModelReadTest.php b/lib/Cake/Test/Case/Model/ModelReadTest.php index fe3780345..6d4b29c24 100644 --- a/lib/Cake/Test/Case/Model/ModelReadTest.php +++ b/lib/Cake/Test/Case/Model/ModelReadTest.php @@ -4054,7 +4054,6 @@ class ModelReadTest extends BaseModelTest { /** * testFindAllWithConditionInChildQuery * - * @todo external conditions like this are going to need to be revisited at some point * @return void */ public function testFindAllWithConditionInChildQuery() { diff --git a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php index 3fc70d742..a742adbed 100644 --- a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php +++ b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php @@ -1551,7 +1551,6 @@ class HttpSocketTest extends CakeTestCase { * testBuildCookies method * * @return void - * @todo Test more scenarios */ public function testBuildCookies() { $cookies = array( diff --git a/lib/Cake/Test/Case/Routing/RouterTest.php b/lib/Cake/Test/Case/Routing/RouterTest.php index 65e1ed7a9..dd12924ce 100644 --- a/lib/Cake/Test/Case/Routing/RouterTest.php +++ b/lib/Cake/Test/Case/Routing/RouterTest.php @@ -1538,7 +1538,6 @@ class RouterTest extends CakeTestCase { * test url generation with legacy (1.2) style prefix routes. * * @return void - * @todo Remove tests related to legacy style routes. * @see testUrlGenerationWithAutoPrefixes */ public function testUrlGenerationWithLegacyPrefixes() { diff --git a/lib/Cake/Test/Case/View/ScaffoldViewTest.php b/lib/Cake/Test/Case/View/ScaffoldViewTest.php index a5f2d85c0..87bf9bd9a 100644 --- a/lib/Cake/Test/Case/View/ScaffoldViewTest.php +++ b/lib/Cake/Test/Case/View/ScaffoldViewTest.php @@ -279,7 +279,7 @@ class ScaffoldViewTest extends CakeTestCase { $this->assertRegExp('/

View Scaffold Mock<\/h2>/', $result); $this->assertRegExp('/
/', $result); - //TODO: add specific tests for fields. + $this->assertRegExp('/1<\/a>/', $result); //belongsTo links $this->assertRegExp('/
  • Edit Scaffold Mock<\/a>\s<\/li>/', $result); $this->assertRegExp('//', $result); - //TODO: add testing for table generation + $this->assertRegExp('/
  • New Scaffold Mock<\/a><\/li>/', $result); Configure::write('Routing.prefixes', $_backAdmin); @@ -454,7 +454,7 @@ class ScaffoldViewTest extends CakeTestCase { $this->assertRegExp('/

    Scaffold Mock<\/h2>/', $result); $this->assertRegExp('//', $result); - //TODO: add testing for table generation + $this->assertRegExp('/
  • New Scaffold Mock<\/a><\/li>/', $result); Configure::write('Routing.prefixes', $_backAdmin); diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index 350924389..d624ced70 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -674,6 +674,6 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase { } return $condition; } - // @codingStandardsIgnoreStop + // @codingStandardsIgnoreEnd } diff --git a/lib/Cake/Utility/ObjectCollection.php b/lib/Cake/Utility/ObjectCollection.php index 96ec3d555..00db12539 100644 --- a/lib/Cake/Utility/ObjectCollection.php +++ b/lib/Cake/Utility/ObjectCollection.php @@ -103,7 +103,7 @@ abstract class ObjectCollection { if (empty($event->omitSubject)) { $subject = $event->subject(); } - //TODO: Temporary BC check, while we move all the triggers system into the CakeEventManager + foreach (array('break', 'breakOn', 'collectReturn', 'modParams') as $opt) { if (isset($event->{$opt})) { $options[$opt] = $event->{$opt}; diff --git a/lib/Cake/Utility/Security.php b/lib/Cake/Utility/Security.php index 857415c9a..766be8ae5 100644 --- a/lib/Cake/Utility/Security.php +++ b/lib/Cake/Utility/Security.php @@ -64,7 +64,6 @@ class Security { * * @param string $authKey Authorization hash * @return boolean Success - * @todo Complete implementation */ public static function validateAuthKey($authKey) { return true; diff --git a/lib/Cake/View/Helper.php b/lib/Cake/View/Helper.php index 1ab88dad6..645ad5acd 100644 --- a/lib/Cake/View/Helper.php +++ b/lib/Cake/View/Helper.php @@ -599,7 +599,6 @@ class Helper extends Object { * @param string $id The name of the 'id' attribute. * @return mixed If $options was an array, an array will be returned with $id set. If a string * was supplied, a string will be returned. - * @todo Refactor this method to not have as many input/output options. */ public function domId($options = null, $id = 'id') { if (is_array($options) && array_key_exists($id, $options) && $options[$id] === null) { @@ -632,7 +631,6 @@ class Helper extends Object { * @param string $key The name of the attribute to be set, defaults to 'name' * @return mixed If an array was given for $options, an array with $key set will be returned. * If a string was supplied a string will be returned. - * @todo Refactor this method to not have as many input/output options. */ protected function _name($options = array(), $field = null, $key = 'name') { if ($options === null) { @@ -676,7 +674,6 @@ class Helper extends Object { * @param string $key The name of the attribute to be set, defaults to 'value' * @return mixed If an array was given for $options, an array with $key set will be returned. * If a string was supplied a string will be returned. - * @todo Refactor this method to not have as many input/output options. */ public function value($options = array(), $field = null, $key = 'value') { if ($options === null) { diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index 881f2485b..408212584 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -885,7 +885,7 @@ class View extends Object { $this->getEventManager()->dispatch(new CakeEvent('View.beforeRenderFile', $this, array($viewFile))); $content = $this->_evaluate($viewFile, $data); $afterEvent = new CakeEvent('View.afterRenderFile', $this, array($viewFile, $content)); - //TODO: For BC puporses, set extra info in the event object. Remove when appropriate + $afterEvent->modParams = 1; $this->getEventManager()->dispatch($afterEvent); $content = $afterEvent->data[1]; From 6d0e32e642055d356e9b5676d4289ba74bf977ea Mon Sep 17 00:00:00 2001 From: Ceeram Date: Thu, 15 Nov 2012 12:09:14 +0100 Subject: [PATCH 03/11] fix coding standards, remove break after return/continue --- lib/Cake/Model/Permission.php | 1 - .../Case/Model/BehaviorCollectionTest.php | 20 ------------------- lib/Cake/basics.php | 4 ---- 3 files changed, 25 deletions(-) diff --git a/lib/Cake/Model/Permission.php b/lib/Cake/Model/Permission.php index b7c92d1a7..8d00f23ac 100644 --- a/lib/Cake/Model/Permission.php +++ b/lib/Cake/Model/Permission.php @@ -146,7 +146,6 @@ class Permission extends AppModel { return false; case 0: continue; - break; case 1: return true; } diff --git a/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php b/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php index 21104eda5..d2df347aa 100644 --- a/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php +++ b/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php @@ -66,15 +66,12 @@ class TestBehavior extends ModelBehavior { switch ($settings['beforeFind']) { case 'on': return false; - break; case 'test': return null; - break; case 'modify': $query['fields'] = array($model->alias . '.id', $model->alias . '.name', $model->alias . '.mytime'); $query['recursive'] = -1; return $query; - break; } } @@ -94,16 +91,12 @@ class TestBehavior extends ModelBehavior { switch ($settings['afterFind']) { case 'on': return array(); - break; case 'test': return true; - break; case 'test2': return null; - break; case 'modify': return Hash::extract($results, "{n}.{$model->alias}"); - break; } } @@ -121,14 +114,11 @@ class TestBehavior extends ModelBehavior { switch ($settings['beforeSave']) { case 'on': return false; - break; case 'test': return true; - break; case 'modify': $model->data[$model->alias]['name'] .= ' modified before'; return true; - break; } } @@ -157,7 +147,6 @@ class TestBehavior extends ModelBehavior { break; case 'test2': return false; - break; case 'modify': $model->data[$model->alias]['name'] .= ' ' . $string; break; @@ -179,18 +168,14 @@ class TestBehavior extends ModelBehavior { case 'on': $model->invalidate('name'); return true; - break; case 'test': return null; - break; case 'whitelist': $this->_addToWhitelist($model, array('name')); return true; - break; case 'stop': $model->invalidate('name'); return false; - break; } } @@ -209,11 +194,9 @@ class TestBehavior extends ModelBehavior { switch ($settings['afterValidate']) { case 'on': return false; - break; case 'test': $model->data = array('foo'); return true; - break; } } @@ -232,17 +215,14 @@ class TestBehavior extends ModelBehavior { switch ($settings['beforeDelete']) { case 'on': return false; - break; case 'test': return null; - break; case 'test2': echo 'beforeDelete success'; if ($cascade) { echo ' (cascading) '; } return true; - break; } } diff --git a/lib/Cake/basics.php b/lib/Cake/basics.php index 4f7c945f6..790852526 100644 --- a/lib/Cake/basics.php +++ b/lib/Cake/basics.php @@ -311,13 +311,10 @@ function env($key) { $offset = 4; } return substr($filename, 0, -(strlen($name) + $offset)); - break; case 'PHP_SELF': return str_replace(env('DOCUMENT_ROOT'), '', env('SCRIPT_FILENAME')); - break; case 'CGI_MODE': return (PHP_SAPI === 'cgi'); - break; case 'HTTP_BASE': $host = env('HTTP_HOST'); $parts = explode('.', $host); @@ -357,7 +354,6 @@ function env($key) { } array_shift($parts); return '.' . implode('.', $parts); - break; } return null; } From 4ebe754076e26f02c7f0bfa4393b9088d4b0b601 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 15 Nov 2012 22:52:25 -0500 Subject: [PATCH 04/11] Add descriptions to top level tasks. --- build.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.xml b/build.xml index fca6ec4ae..9759aec9b 100644 --- a/build.xml +++ b/build.xml @@ -197,7 +197,7 @@ - + @@ -208,7 +208,7 @@ - - + + From ac0b9b285d33b1ebc86567894d813443c00f5f0c Mon Sep 17 00:00:00 2001 From: frederikweber Date: Sun, 18 Nov 2012 11:39:17 +0100 Subject: [PATCH 05/11] Send charset in Content-Type when Content is JSON. --- lib/Cake/Network/CakeResponse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index 79be981ac..e3cb8a921 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -409,7 +409,7 @@ class CakeResponse { if (in_array($this->_status, array(304, 204))) { return; } - if (strpos($this->_contentType, 'text/') === 0) { + if (strpos($this->_contentType, 'text/') === 0 || $this->_contentType === 'application/json') { $this->header('Content-Type', "{$this->_contentType}; charset={$this->_charset}"); } else { $this->header('Content-Type', "{$this->_contentType}"); From 9b479958f613e2ce1d290f26d246e76313e821f2 Mon Sep 17 00:00:00 2001 From: frederikweber Date: Sun, 18 Nov 2012 12:25:45 +0100 Subject: [PATCH 06/11] Send charset=UTF-8 if Content-Type is JSON. --- lib/Cake/Network/CakeResponse.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index e3cb8a921..67b9c90da 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -409,8 +409,10 @@ class CakeResponse { if (in_array($this->_status, array(304, 204))) { return; } - if (strpos($this->_contentType, 'text/') === 0 || $this->_contentType === 'application/json') { + if (strpos($this->_contentType, 'text/') === 0) { $this->header('Content-Type', "{$this->_contentType}; charset={$this->_charset}"); + } else if ($this->_contentType === 'application/json') { + $this->header('Content-Type', "{$this->_contentType}; charset=UTF-8"); } else { $this->header('Content-Type', "{$this->_contentType}"); } From 374dd55270115965b349045aa3b3727db8fe79e9 Mon Sep 17 00:00:00 2001 From: frederikweber Date: Sun, 18 Nov 2012 14:06:46 +0100 Subject: [PATCH 07/11] Changed else if to elseif. --- lib/Cake/Network/CakeResponse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index 67b9c90da..33be2d0f5 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -411,7 +411,7 @@ class CakeResponse { } if (strpos($this->_contentType, 'text/') === 0) { $this->header('Content-Type', "{$this->_contentType}; charset={$this->_charset}"); - } else if ($this->_contentType === 'application/json') { + } elseif ($this->_contentType === 'application/json') { $this->header('Content-Type', "{$this->_contentType}; charset=UTF-8"); } else { $this->header('Content-Type', "{$this->_contentType}"); From 58df515a6dca61ea7f50d2a36372393831e89868 Mon Sep 17 00:00:00 2001 From: frederikweber Date: Sun, 18 Nov 2012 23:44:37 +0100 Subject: [PATCH 08/11] Add test for Content-Type JSON and charset. --- lib/Cake/Test/Case/Network/CakeResponseTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Test/Case/Network/CakeResponseTest.php b/lib/Cake/Test/Case/Network/CakeResponseTest.php index 9f601b1b4..989ce62fa 100644 --- a/lib/Cake/Test/Case/Network/CakeResponseTest.php +++ b/lib/Cake/Test/Case/Network/CakeResponseTest.php @@ -199,7 +199,7 @@ class CakeResponseTest extends CakeTestCase { * Tests the send method and changing the content type * */ - public function testSendChangingContentYype() { + public function testSendChangingContentType() { $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent', '_setCookies')); $response->type('mp3'); $response->body('the response body'); @@ -215,12 +215,12 @@ class CakeResponseTest extends CakeTestCase { } /** - * Tests the send method and changing the content type + * Tests the send method and changing the content type to JSON * */ - public function testSendChangingContentType() { + public function testSendChangingContentTypeJSON() { $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent', '_setCookies')); - $response->type('mp3'); + $response->type('json'); $response->body('the response body'); $response->expects($this->once())->method('_sendContent')->with('the response body'); $response->expects($this->at(0))->method('_setCookies'); @@ -229,7 +229,7 @@ class CakeResponseTest extends CakeTestCase { $response->expects($this->at(2)) ->method('_sendHeader')->with('Content-Length', 17); $response->expects($this->at(3)) - ->method('_sendHeader')->with('Content-Type', 'audio/mpeg'); + ->method('_sendHeader')->with('Content-Type', 'application/json; charset=UTF-8'); $response->send(); } From 6b4afb989e4257d47e022377297c0e453d49ddec Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 19 Nov 2012 14:03:03 -0500 Subject: [PATCH 09/11] Fix Set::merge() failing to merge correctly. When merging 3 values, and the 2nd was empty, the resulting merge was incorrect. Fixes #3384 --- lib/Cake/Test/Case/Utility/SetTest.php | 3 +++ lib/Cake/Utility/Set.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Utility/SetTest.php b/lib/Cake/Test/Case/Utility/SetTest.php index c49ec3278..a8ccfef3e 100644 --- a/lib/Cake/Test/Case/Utility/SetTest.php +++ b/lib/Cake/Test/Case/Utility/SetTest.php @@ -152,6 +152,9 @@ class SetTest extends CakeTestCase { $r = Set::merge('foo', 'bar'); $this->assertEquals(array('foo', 'bar'), $r); + $r = Set::merge(array('foo'), array(), array('bar')); + $this->assertEquals(array('foo', 'bar'), $r); + $r = Set::merge('foo', array('user' => 'bob', 'no-bar'), 'bar'); $this->assertEquals(array('foo', 'user' => 'bob', 'no-bar', 'bar'), $r); diff --git a/lib/Cake/Utility/Set.php b/lib/Cake/Utility/Set.php index 7ac63cfbe..f80dde8ea 100644 --- a/lib/Cake/Utility/Set.php +++ b/lib/Cake/Utility/Set.php @@ -45,7 +45,7 @@ class Set { */ public static function merge($data, $merge = null) { $args = func_get_args(); - if (empty($args[1])) { + if (empty($args[1]) && count($args) <= 2) { return (array)$args[0]; } if (!is_array($args[0])) { From fb275c5fa257c98f85883115ae12dbf5671094e1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 19 Nov 2012 14:46:45 -0500 Subject: [PATCH 10/11] Fix warnings from file_get_contents() in Xml::build() Use HttpSocket to get proper exceptions when trying to load XML from remote servers. Fixes #3379 --- lib/Cake/Test/Case/Utility/XmlTest.php | 1 + lib/Cake/Utility/Xml.php | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/XmlTest.php b/lib/Cake/Test/Case/Utility/XmlTest.php index 7108d75a7..e90217d93 100644 --- a/lib/Cake/Test/Case/Utility/XmlTest.php +++ b/lib/Cake/Test/Case/Utility/XmlTest.php @@ -177,6 +177,7 @@ class XmlTest extends CakeTestCase { array(null), array(false), array(''), + array('http://localhost/notthere.xml'), ); } diff --git a/lib/Cake/Utility/Xml.php b/lib/Cake/Utility/Xml.php index f8662b282..cf257b494 100644 --- a/lib/Cake/Utility/Xml.php +++ b/lib/Cake/Utility/Xml.php @@ -18,6 +18,7 @@ * @since CakePHP v .0.10.3.1400 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('HttpSocket', 'Network/Http'); /** * XML handling for Cake. @@ -97,9 +98,15 @@ class Xml { return self::fromArray((array)$input, $options); } elseif (strpos($input, '<') !== false) { return self::_loadXml($input, $options); - } elseif (file_exists($input) || strpos($input, 'http://') === 0 || strpos($input, 'https://') === 0) { - $input = file_get_contents($input); - return self::_loadXml($input, $options); + } elseif (file_exists($input)) { + return self::_loadXml(file_get_contents($input), $options); + } elseif (strpos($input, 'http://') === 0 || strpos($input, 'https://') === 0) { + $socket = new HttpSocket(); + $response = $socket->get($input); + if (!$response->isOk()) { + throw new XmlException(__d('cake_dev', 'XML cannot be read.')); + } + return self::_loadXml($response->body, $options); } elseif (!is_string($input)) { throw new XmlException(__d('cake_dev', 'Invalid input.')); } From 587c7071b4448fab8f185110993e035b5a6c38a3 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 20 Nov 2012 22:42:44 -0500 Subject: [PATCH 11/11] Fix incorrect order of arguments when added out of sequence. Fixes #3385 --- lib/Cake/Console/ConsoleOptionParser.php | 1 + .../Case/Console/ConsoleOptionParserTest.php | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Console/ConsoleOptionParser.php b/lib/Cake/Console/ConsoleOptionParser.php index 1983e22ce..16371165a 100644 --- a/lib/Cake/Console/ConsoleOptionParser.php +++ b/lib/Cake/Console/ConsoleOptionParser.php @@ -345,6 +345,7 @@ class ConsoleOptionParser { $arg = new ConsoleInputArgument($options); } $this->_args[$index] = $arg; + ksort($this->_args); return $this; } diff --git a/lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php b/lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php index 0677b09c4..2cf265995 100644 --- a/lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php +++ b/lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php @@ -314,10 +314,29 @@ class ConsoleOptionParserTest extends CakeTestCase { $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. *