diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index 9e04158b5..108443cce 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -747,7 +747,7 @@ class CakeSession { * @return void */ public static function renew() { - if (!session_id()) { + if (session_id() === '') { return; } if (isset($_COOKIE[session_name()])) { diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index b1e382995..d98c2b71f 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -3566,6 +3566,7 @@ class DboSource extends DataSource { if ($this->_methodCacheChange) { Cache::write('method_cache', self::$methodCache, '_cake_core_'); } + parent::__destruct(); } } \ No newline at end of file diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 21a516d59..06e454cd5 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -731,7 +731,7 @@ class CakeRequest implements ArrayAccess { */ public static function header($name) { $name = 'HTTP_' . strtoupper(str_replace('-', '_', $name)); - if (!empty($_SERVER[$name])) { + if (isset($_SERVER[$name])) { return $_SERVER[$name]; } return false; diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index f9d8c5842..81a534831 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -1131,12 +1131,14 @@ class CakeRequestTest extends CakeTestCase { * @return void */ public function testHeader() { + $_SERVER['HTTP_X_THING'] = ''; $_SERVER['HTTP_HOST'] = 'localhost'; $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-ca) AppleWebKit/534.8+ (KHTML, like Gecko) Version/5.0 Safari/533.16'; $request = new CakeRequest('/', false); $this->assertEquals($_SERVER['HTTP_HOST'], $request->header('host')); $this->assertEquals($_SERVER['HTTP_USER_AGENT'], $request->header('User-Agent')); + $this->assertSame('', $request->header('X-thing')); } /** diff --git a/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php b/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php index cfe012813..bade7e034 100644 --- a/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php +++ b/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php @@ -311,6 +311,18 @@ class ControllerTestCaseTest extends CakeTestCase { $this->assertInternalType('array', $this->Case->controller->viewVars); } +/** + * Test that file responses don't trigger errors. + * + * @return void + */ + public function testActionWithFile() { + $Controller = $this->Case->generate('TestsApps'); + $this->Case->testAction('/tests_apps/file'); + $this->assertArrayHasKey('Content-Disposition', $Controller->response->header()); + $this->assertArrayHasKey('Content-Length', $Controller->response->header()); + } + /** * Make sure testAction() can hit plugin controllers. * diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index 5580315cd..43f40e5d6 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -239,6 +239,19 @@ class HashTest extends CakeTestCase { Hash::get(array('one' => 'two'), true); } +/** + * Test testGetNullPath() + * + * @return void + */ + public function testGetNullPath() { + $result = Hash::get(array('one' => 'two'), null, '-'); + $this->assertEquals('-', $result); + + $result = Hash::get(array('one' => 'two'), '', '-'); + $this->assertEquals('-', $result); + } + /** * Test dimensions. * @@ -275,6 +288,14 @@ class HashTest extends CakeTestCase { * @return void */ public function testMaxDimensions() { + $data = array(); + $result = Hash::maxDimensions($data); + $this->assertEquals(0, $result); + + $data = array('a', 'b'); + $result = Hash::maxDimensions($data); + $this->assertEquals(1, $result); + $data = array('1' => '1.1', '2', '3' => array('3.1' => '3.1.1')); $result = Hash::maxDimensions($data); $this->assertEquals($result, 2); diff --git a/lib/Cake/Test/Case/Utility/InflectorTest.php b/lib/Cake/Test/Case/Utility/InflectorTest.php index f600ae757..caf085ad1 100644 --- a/lib/Cake/Test/Case/Utility/InflectorTest.php +++ b/lib/Cake/Test/Case/Utility/InflectorTest.php @@ -177,6 +177,7 @@ class InflectorTest extends CakeTestCase { $this->assertEquals(Inflector::singularize('body_curves'), 'body_curve'); $this->assertEquals(Inflector::singularize('metadata'), 'metadata'); $this->assertEquals(Inflector::singularize('files_metadata'), 'files_metadata'); + $this->assertEquals(Inflector::singularize('sieves'), 'sieve'); $this->assertEquals(Inflector::singularize(''), ''); } @@ -248,6 +249,7 @@ class InflectorTest extends CakeTestCase { $this->assertEquals(Inflector::pluralize('metadata'), 'metadata'); $this->assertEquals(Inflector::pluralize('files_metadata'), 'files_metadata'); $this->assertEquals(Inflector::pluralize('stadia'), 'stadia'); + $this->assertEquals(Inflector::pluralize('sieve'), 'sieves'); $this->assertEquals(Inflector::pluralize(''), ''); } diff --git a/lib/Cake/Test/test_app/Controller/TestsAppsController.php b/lib/Cake/Test/test_app/Controller/TestsAppsController.php index 8cd847c5d..35783548d 100644 --- a/lib/Cake/Test/test_app/Controller/TestsAppsController.php +++ b/lib/Cake/Test/test_app/Controller/TestsAppsController.php @@ -44,6 +44,10 @@ class TestsAppsController extends AppController { $this->render('index'); } + public function file() { + $this->response->file(__FILE__); + } + public function redirect_to() { return $this->redirect('http://cakephp.org'); } diff --git a/lib/Cake/TestSuite/ControllerTestCase.php b/lib/Cake/TestSuite/ControllerTestCase.php index 1edd40fdd..17620ae08 100644 --- a/lib/Cake/TestSuite/ControllerTestCase.php +++ b/lib/Cake/TestSuite/ControllerTestCase.php @@ -275,7 +275,7 @@ abstract class ControllerTestCase extends CakeTestCase { $params['requested'] = 1; } $Dispatch->testController = $this->controller; - $Dispatch->response = $this->getMock('CakeResponse', array('send')); + $Dispatch->response = $this->getMock('CakeResponse', array('send', '_clearBuffer')); $this->result = $Dispatch->dispatch($request, $Dispatch->response, $params); $this->controller = $Dispatch->testController; $this->vars = $this->controller->viewVars; diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index cdafd13a4..897ab64c6 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -43,7 +43,7 @@ class Hash { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::get */ public static function get(array $data, $path, $default = null) { - if (empty($data)) { + if (empty($data) || $path === '' || $path === null) { return $default; } if (is_string($path) || is_numeric($path)) { @@ -55,7 +55,6 @@ class Hash { $path )); } - $parts = $path; } @@ -250,7 +249,7 @@ class Hash { * * @param array $data The data to insert into. * @param string $path The path to insert at. - * @param array $values The values to insert. + * @param mixed $values The values to insert. * @return array The data with $values inserted. * @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::insert */ @@ -763,10 +762,14 @@ class Hash { $depth = array(); if (is_array($data) && reset($data) !== false) { foreach ($data as $value) { - $depth[] = self::dimensions((array)$value) + 1; + if (is_array($value)) { + $depth[] = self::dimensions($value) + 1; + } else { + $depth[] = 1; + } } } - return max($depth); + return empty($depth) ? 0 : max($depth); } /** diff --git a/lib/Cake/Utility/Inflector.php b/lib/Cake/Utility/Inflector.php index 6e7b4d493..33e4ecf1c 100644 --- a/lib/Cake/Utility/Inflector.php +++ b/lib/Cake/Utility/Inflector.php @@ -107,7 +107,8 @@ class Inflector { 'hero' => 'heroes', 'tooth' => 'teeth', 'goose' => 'geese', - 'foot' => 'feet' + 'foot' => 'feet', + 'sieve' => 'sieves' ) );