From fe6d3e36d5719645ef2744bc98dbcae1bca48727 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 18 Nov 2014 23:06:24 -0500 Subject: [PATCH 001/336] Bump version number to 2.7.0-dev Open a branch for any development on 2.7.x which will be a 2.x API compatible release. --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index f3d3acb3e3c..ccba2066f2e 100644 --- a/lib/Cake/VERSION.txt +++ b/lib/Cake/VERSION.txt @@ -17,4 +17,4 @@ // @license http://www.opensource.org/licenses/mit-license.php MIT License // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -2.6.0-RC1 +2.7.0-dev From 88bfa70cadd2f5d13cc49ebe1d3eb50c842f0f35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Thu, 20 Nov 2014 20:37:16 +0100 Subject: [PATCH 002/336] Refactoring the detector code for CakeRequest::is() and adding default detectors for JSON and XML. --- lib/Cake/Network/CakeRequest.php | 82 ++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 14 deletions(-) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index ca50ae47c10..b26dfcf721a 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -111,7 +111,9 @@ class CakeRequest implements ArrayAccess { 'portalmmm', 'Plucker', 'ReqwirelessWeb', 'SonyEricsson', 'Symbian', 'UP\\.Browser', 'webOS', 'Windows CE', 'Windows Phone OS', 'Xiino' )), - 'requested' => array('param' => 'requested', 'value' => 1) + 'requested' => array('param' => 'requested', 'value' => 1), + 'json' => array('header' => array('application/json'), 'param' => 'ext', 'value' => 'json'), + 'xml' => array('header' => array('application/xml', 'text/xml'), 'param' => 'ext', 'value' => 'xml'), ); /** @@ -498,6 +500,71 @@ public function is($type) { return false; } $detect = $this->_detectors[$type]; + if (isset($detect['env'])) { + if ($this->_environmentDetector($detect)) { + return true; + } + } + if (isset($detect['header'])) { + if ($this->_environmentDetector($detect)) { + return true; + } + } + if (isset($detect['param'])) { + if ($this->_paramDetector($detect)) { + return true; + } + } + if (isset($detect['callback']) && is_callable($detect['callback'])) { + return call_user_func($detect['callback'], $this); + } + return false; + } + +/** + * Detects if a specific header is present + * + * @param $detect Detector options array. + * @return bool Whether or not the request is the type you are checking. + */ + protected function _headerDetector($detect) { + $headers = getallheaders(); + if (isset($headers['Accept'])) { + $headers = explode(',', $headers['Accept']); + foreach ($detect['header'] as $header) { + if (in_array($header, $headers)) { + return true; + } + } + } + return false; + } + +/** + * Detects if a specific header is present + * + * @param $detect Detector options array. + * @return bool Whether or not the request is the type you are checking. + */ + protected function _paramDetector($detect) { + $key = $detect['param']; + if (isset($detect['value'])) { + $value = $detect['value']; + return isset($this->params[$key]) ? $this->params[$key] == $value : false; + } + if (isset($detect['options'])) { + return isset($this->params[$key]) ? in_array($this->params[$key], $detect['options']) : false; + } + return false; + } + +/** + * Detects if a specific header is present + * + * @param $detect Detector options array. + * @return bool Whether or not the request is the type you are checking. + */ + protected function _environmentDetector($detect) { if (isset($detect['env'])) { if (isset($detect['value'])) { return env($detect['env']) == $detect['value']; @@ -510,19 +577,6 @@ public function is($type) { return (bool)preg_match($pattern, env($detect['env'])); } } - if (isset($detect['param'])) { - $key = $detect['param']; - if (isset($detect['value'])) { - $value = $detect['value']; - return isset($this->params[$key]) ? $this->params[$key] == $value : false; - } - if (isset($detect['options'])) { - return isset($this->params[$key]) ? in_array($this->params[$key], $detect['options']) : false; - } - } - if (isset($detect['callback']) && is_callable($detect['callback'])) { - return call_user_func($detect['callback'], $this); - } return false; } From 728764c5432e44fa3f168711250e732b6635b79b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Thu, 20 Nov 2014 21:07:25 +0100 Subject: [PATCH 003/336] Adding a test for the refactored CakeRequest code. --- lib/Cake/Network/CakeRequest.php | 31 ++++++++++++++----- .../Test/Case/Network/CakeRequestTest.php | 26 ++++++++++++++++ 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index b26dfcf721a..e2f41200db2 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -522,19 +522,34 @@ public function is($type) { } /** - * Detects if a specific header is present + * Gets the accept header from the current request. + * + * @return bool Returns an array of accept header values. + */ + public function getAcceptHeaders() { + $headers = array(); + if (function_exists('getallheaders')) { + $headers = getallheaders(); + $headers = explode(',', $headers['Accept']); + } else { + if (isset($_SERVER['HTTP_ACCEPT'])) { + $headers = explode(',', $_SERVER['HTTP_ACCEPT']); + } + } + return $headers; + } + +/** + * Detects if a specific header is present. * * @param $detect Detector options array. * @return bool Whether or not the request is the type you are checking. */ protected function _headerDetector($detect) { - $headers = getallheaders(); - if (isset($headers['Accept'])) { - $headers = explode(',', $headers['Accept']); - foreach ($detect['header'] as $header) { - if (in_array($header, $headers)) { - return true; - } + $headers = $this->getAcceptHeaders(); + foreach ($detect['header'] as $header) { + if (in_array($header, $headers)) { + return true; } } return false; diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index 8216d5e2bbe..137d9950c7d 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -52,6 +52,15 @@ public function reConstruct($url = 'some/path', $parseEnvironment = true) { $this->here = $this->base . '/' . $this->url; } +/** + * Detects if a specific header is present. + * + * @param $detect Detector options array. + * @return bool Whether or not the request is the type you are checking. + */ + public function headerDetector($detect) { + return $this->_headerDetector($detect); + } } /** @@ -89,6 +98,23 @@ public function tearDown() { Configure::write('App', $this->_app); } +/** + * Test the header detector. + * + * @return void + */ + public function testHeaderDetector() { + $request = $this->getMock('TestCakeRequest', array('getAcceptHeaders')); + $_SERVER['HTTP_ACCEPT'] = 'application/json'; + $detector = array('header' => array('application/json'), 'param' => 'ext', 'value' => 'json'); + $request->expects($this->once()) + ->method('getAcceptHeaders') + ->will($this->returnValue(array( + 'application/json' + ))); + $this->assertTrue($request->headerDetector($detector)); + } + /** * Test that the autoparse = false constructor works. * From 3f5f8cbc15f80d9b1b3ff010f012e02d4020ed4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Thu, 20 Nov 2014 22:16:36 +0100 Subject: [PATCH 004/336] phpcs fixes in Cake/Network/CakeRequest.php --- lib/Cake/Network/CakeRequest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index e2f41200db2..f98379eb553 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -542,7 +542,7 @@ public function getAcceptHeaders() { /** * Detects if a specific header is present. * - * @param $detect Detector options array. + * @param array $detect Detector options array. * @return bool Whether or not the request is the type you are checking. */ protected function _headerDetector($detect) { @@ -558,7 +558,7 @@ protected function _headerDetector($detect) { /** * Detects if a specific header is present * - * @param $detect Detector options array. + * @param array $detect Detector options array. * @return bool Whether or not the request is the type you are checking. */ protected function _paramDetector($detect) { @@ -576,7 +576,7 @@ protected function _paramDetector($detect) { /** * Detects if a specific header is present * - * @param $detect Detector options array. + * @param array $detect Detector options array. * @return bool Whether or not the request is the type you are checking. */ protected function _environmentDetector($detect) { From 24c4cab4f324c726e31fd1598e70fee1a48738f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Thu, 20 Nov 2014 22:50:12 +0100 Subject: [PATCH 005/336] phpcs fix in Cake/Test/Case/Network/CakeRequestTest.php --- lib/Cake/Test/Case/Network/CakeRequestTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index 137d9950c7d..99d51c8acbe 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -61,6 +61,7 @@ public function reConstruct($url = 'some/path', $parseEnvironment = true) { public function headerDetector($detect) { return $this->_headerDetector($detect); } + } /** From 17e5d41e55712fd1a1320a79f584dc3edd465905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Fri, 21 Nov 2014 18:49:36 +0100 Subject: [PATCH 006/336] Restructuring the CakeRequest::is() code and related code a little. --- lib/Cake/Network/CakeRequest.php | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index f98379eb553..8cddce0eb0b 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -500,20 +500,14 @@ public function is($type) { return false; } $detect = $this->_detectors[$type]; - if (isset($detect['env'])) { - if ($this->_environmentDetector($detect)) { - return true; - } + if (isset($detect['env']) && $this->_environmentDetector($detect)) { + return true; } - if (isset($detect['header'])) { - if ($this->_environmentDetector($detect)) { - return true; - } + if (isset($detect['header']) && $this->_environmentDetector($detect)) { + return true; } - if (isset($detect['param'])) { - if ($this->_paramDetector($detect)) { - return true; - } + if (isset($detect['param']) && $this->_paramDetector($detect)) { + return true; } if (isset($detect['callback']) && is_callable($detect['callback'])) { return call_user_func($detect['callback'], $this); @@ -528,13 +522,11 @@ public function is($type) { */ public function getAcceptHeaders() { $headers = array(); - if (function_exists('getallheaders')) { + if (isset($_SERVER['HTTP_ACCEPT'])) { + $headers = explode(',', $_SERVER['HTTP_ACCEPT']); + } elseif (function_exists('getallheaders')) { $headers = getallheaders(); $headers = explode(',', $headers['Accept']); - } else { - if (isset($_SERVER['HTTP_ACCEPT'])) { - $headers = explode(',', $_SERVER['HTTP_ACCEPT']); - } } return $headers; } From 83eb8ce7de46be59e4bd1e05f1e674ce1446454a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Sat, 22 Nov 2014 12:55:22 +0100 Subject: [PATCH 007/336] Changes to Cake/Network/CakeRequest.php as discussed on Github for the detector code changes. Fixed the description of a few doc blocks, removed the use of getallheaders(), removed the failsafe (based on extension) for the xml and json detectors. --- lib/Cake/Network/CakeRequest.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 8cddce0eb0b..452dcb0473c 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -112,8 +112,8 @@ class CakeRequest implements ArrayAccess { 'webOS', 'Windows CE', 'Windows Phone OS', 'Xiino' )), 'requested' => array('param' => 'requested', 'value' => 1), - 'json' => array('header' => array('application/json'), 'param' => 'ext', 'value' => 'json'), - 'xml' => array('header' => array('application/xml', 'text/xml'), 'param' => 'ext', 'value' => 'xml'), + 'json' => array('header' => array('application/json')), + 'xml' => array('header' => array('application/xml', 'text/xml')), ); /** @@ -524,9 +524,6 @@ public function getAcceptHeaders() { $headers = array(); if (isset($_SERVER['HTTP_ACCEPT'])) { $headers = explode(',', $_SERVER['HTTP_ACCEPT']); - } elseif (function_exists('getallheaders')) { - $headers = getallheaders(); - $headers = explode(',', $headers['Accept']); } return $headers; } @@ -538,9 +535,9 @@ public function getAcceptHeaders() { * @return bool Whether or not the request is the type you are checking. */ protected function _headerDetector($detect) { - $headers = $this->getAcceptHeaders(); + $acceptHeaders = $this->getAcceptHeaders(); foreach ($detect['header'] as $header) { - if (in_array($header, $headers)) { + if (in_array($header, $acceptHeaders)) { return true; } } @@ -548,7 +545,7 @@ protected function _headerDetector($detect) { } /** - * Detects if a specific header is present + * Detects if a specific request parameter is present. * * @param array $detect Detector options array. * @return bool Whether or not the request is the type you are checking. @@ -566,7 +563,7 @@ protected function _paramDetector($detect) { } /** - * Detects if a specific header is present + * Detects if a specific environment variable is present. * * @param array $detect Detector options array. * @return bool Whether or not the request is the type you are checking. From 4ff07b745aecb159a053067fea0a622d0b7b4af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Sat, 22 Nov 2014 17:30:53 +0100 Subject: [PATCH 008/336] Adding a test for the new json and xml detectors that were added to the CakeRequest class. --- lib/Cake/Network/CakeRequest.php | 2 +- .../Test/Case/Network/CakeRequestTest.php | 20 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 452dcb0473c..307066299cc 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -503,7 +503,7 @@ public function is($type) { if (isset($detect['env']) && $this->_environmentDetector($detect)) { return true; } - if (isset($detect['header']) && $this->_environmentDetector($detect)) { + if (isset($detect['header']) && $this->_headerDetector($detect)) { return true; } if (isset($detect['param']) && $this->_paramDetector($detect)) { diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index 99d51c8acbe..14a3d63f4a7 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -106,7 +106,7 @@ public function tearDown() { */ public function testHeaderDetector() { $request = $this->getMock('TestCakeRequest', array('getAcceptHeaders')); - $_SERVER['HTTP_ACCEPT'] = 'application/json'; + $_SERVER['HTTP_ACCEPT'] = 'application/json, text/plain, */*'; $detector = array('header' => array('application/json'), 'param' => 'ext', 'value' => 'json'); $request->expects($this->once()) ->method('getAcceptHeaders') @@ -776,6 +776,24 @@ public function testIsHttpMethods() { $this->assertFalse($request->is('delete')); } +/** + * Test is() with json and xml. + * + * @return void + */ + public function testIsJsonAndXml() { + $request = new CakeRequest('some/path'); + + $_SERVER['HTTP_ACCEPT'] = 'application/json, text/plain, */*'; + $this->assertTrue($request->is(array('json'))); + + $_SERVER['HTTP_ACCEPT'] = 'application/xml, text/plain, */*'; + $this->assertTrue($request->is(array('xml'))); + + $_SERVER['HTTP_ACCEPT'] = 'text/xml, */*'; + $this->assertTrue($request->is(array('xml'))); + } + /** * Test is() with multiple types. * From 43f7fcc735ef2c64212638f9565cee0ed54dd785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Thu, 27 Nov 2014 01:00:44 +0100 Subject: [PATCH 009/336] Adding a few more ways to detect HTTP headers, extensions and the accept header. --- lib/Cake/Network/CakeRequest.php | 48 +++++++++++++++-- .../Test/Case/Network/CakeRequestTest.php | 53 ++++++++++++------- 2 files changed, 78 insertions(+), 23 deletions(-) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 307066299cc..01179cb9dc7 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -112,8 +112,8 @@ class CakeRequest implements ArrayAccess { 'webOS', 'Windows CE', 'Windows Phone OS', 'Xiino' )), 'requested' => array('param' => 'requested', 'value' => 1), - 'json' => array('header' => array('application/json')), - 'xml' => array('header' => array('application/xml', 'text/xml')), + 'json' => array('accept' => array('application/json'), 'param' => 'ext', 'value' => 'json'), + 'xml' => array('accept' => array('application/xml', 'text/xml'), 'param' => 'ext', 'value' => 'xml'), ); /** @@ -506,6 +506,9 @@ public function is($type) { if (isset($detect['header']) && $this->_headerDetector($detect)) { return true; } + if (isset($detect['accept']) && $this->_acceptHeaderDetector($detect)) { + return true; + } if (isset($detect['param']) && $this->_paramDetector($detect)) { return true; } @@ -529,14 +532,30 @@ public function getAcceptHeaders() { } /** - * Detects if a specific header is present. + * Detects if an URL extension is present. * * @param array $detect Detector options array. * @return bool Whether or not the request is the type you are checking. */ - protected function _headerDetector($detect) { + protected function _extensionDetector($detect) { + if (is_string($detect['extension'])) { + $detect['extension'] = array($detect['extension']); + } + if (in_array($this->params['ext'], $detect['extension'])) { + return true; + } + return false; + } + +/** + * Detects if a specific accept header is present. + * + * @param array $detect Detector options array. + * @return bool Whether or not the request is the type you are checking. + */ + protected function _acceptHeaderDetector($detect) { $acceptHeaders = $this->getAcceptHeaders(); - foreach ($detect['header'] as $header) { + foreach ($detect['accept'] as $header) { if (in_array($header, $acceptHeaders)) { return true; } @@ -544,6 +563,25 @@ protected function _headerDetector($detect) { return false; } +/** + * Detects if a specific header is present. + * + * @param array $detect Detector options array. + * @return bool Whether or not the request is the type you are checking. + */ + protected function _headerDetector($detect) { + foreach ($detect['header'] as $header => $value) { + $header = 'HTTP_' . strtoupper($header); + if (isset($_SERVER[$header])) { + if (is_callable($value)) { + return call_user_func($value, $_SERVER[$header]); + } + return ($_SERVER[$header] === $value); + } + } + return false; + } + /** * Detects if a specific request parameter is present. * diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index 14a3d63f4a7..f9d8c584250 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -52,16 +52,6 @@ public function reConstruct($url = 'some/path', $parseEnvironment = true) { $this->here = $this->base . '/' . $this->url; } -/** - * Detects if a specific header is present. - * - * @param $detect Detector options array. - * @return bool Whether or not the request is the type you are checking. - */ - public function headerDetector($detect) { - return $this->_headerDetector($detect); - } - } /** @@ -105,15 +95,42 @@ public function tearDown() { * @return void */ public function testHeaderDetector() { - $request = $this->getMock('TestCakeRequest', array('getAcceptHeaders')); + $request = new CakeRequest('some/path'); + $request->addDetector('host', array('header' => array('host' => 'cakephp.org'))); + + $_SERVER['HTTP_HOST'] = 'cakephp.org'; + $this->assertTrue($request->is('host')); + + $_SERVER['HTTP_HOST'] = 'php.net'; + $this->assertFalse($request->is('host')); + } + +/** + * Test the accept header detector. + * + * @return void + */ + public function testExtensionDetector() { + $request = new CakeRequest('some/path'); + $request->params['ext'] = 'json'; + $this->assertTrue($request->is('json')); + + $request->params['ext'] = 'xml'; + $this->assertFalse($request->is('json')); + } + +/** + * Test the accept header detector. + * + * @return void + */ + public function testAcceptHeaderDetector() { + $request = new CakeRequest('some/path'); $_SERVER['HTTP_ACCEPT'] = 'application/json, text/plain, */*'; - $detector = array('header' => array('application/json'), 'param' => 'ext', 'value' => 'json'); - $request->expects($this->once()) - ->method('getAcceptHeaders') - ->will($this->returnValue(array( - 'application/json' - ))); - $this->assertTrue($request->headerDetector($detector)); + $this->assertTrue($request->is('json')); + + $_SERVER['HTTP_ACCEPT'] = 'text/plain, */*'; + $this->assertFalse($request->is('json')); } /** From e7f554cba70086ad51c8b03b8cc4bfb8b4ac6236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Sat, 29 Nov 2014 03:04:07 +0100 Subject: [PATCH 010/336] Changing the direct access of super globals in Cake/Network/CakeRequest.php to use env() and fixed a typo. --- lib/Cake/Network/CakeRequest.php | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 01179cb9dc7..32e6b884ae8 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -519,20 +519,7 @@ public function is($type) { } /** - * Gets the accept header from the current request. - * - * @return bool Returns an array of accept header values. - */ - public function getAcceptHeaders() { - $headers = array(); - if (isset($_SERVER['HTTP_ACCEPT'])) { - $headers = explode(',', $_SERVER['HTTP_ACCEPT']); - } - return $headers; - } - -/** - * Detects if an URL extension is present. + * Detects if a URL extension is present. * * @param array $detect Detector options array. * @return bool Whether or not the request is the type you are checking. @@ -554,7 +541,7 @@ protected function _extensionDetector($detect) { * @return bool Whether or not the request is the type you are checking. */ protected function _acceptHeaderDetector($detect) { - $acceptHeaders = $this->getAcceptHeaders(); + $acceptHeaders = explode(',', (string)env('HTTP_ACCEPT')); foreach ($detect['accept'] as $header) { if (in_array($header, $acceptHeaders)) { return true; @@ -571,12 +558,12 @@ protected function _acceptHeaderDetector($detect) { */ protected function _headerDetector($detect) { foreach ($detect['header'] as $header => $value) { - $header = 'HTTP_' . strtoupper($header); - if (isset($_SERVER[$header])) { - if (is_callable($value)) { - return call_user_func($value, $_SERVER[$header]); + $header = env('HTTP_' . strtoupper($header)); + if (!is_null($header)) { + if (!is_string($value) && !is_bool($value) && is_callable($value)) { + return call_user_func($value, $header); } - return ($_SERVER[$header] === $value); + return ($header === $value); } } return false; From 9be725613e818ed9cc1b8775dbbe569397904f70 Mon Sep 17 00:00:00 2001 From: Walther Lalk Date: Thu, 11 Dec 2014 16:44:11 +0200 Subject: [PATCH 011/336] Backport helper method for view blocks from 3.0 Related PR is #5385 --- lib/Cake/Test/Case/View/ViewTest.php | 11 +++++++++++ lib/Cake/View/View.php | 10 ++++++++++ lib/Cake/View/ViewBlock.php | 10 ++++++++++ 3 files changed, 31 insertions(+) diff --git a/lib/Cake/Test/Case/View/ViewTest.php b/lib/Cake/Test/Case/View/ViewTest.php index f18a02093b9..d154e8deaa5 100644 --- a/lib/Cake/Test/Case/View/ViewTest.php +++ b/lib/Cake/Test/Case/View/ViewTest.php @@ -1425,6 +1425,17 @@ public function testBlockReset() { $this->assertSame('', $result); } +/** + * Test checking a block's existance. + * + * @return void + */ + public function testBlockExist() { + $this->assertFalse($this->View->exists('test')); + $this->View->assign('test', 'Block content'); + $this->assertTrue($this->View->exists('test')); + } + /** * Test setting a block's content to null * diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index a33dd1a1ffd..01bacfef58b 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -698,6 +698,16 @@ public function fetch($name, $default = '') { return $this->Blocks->get($name, $default); } +/** + * Check if a block exists + * + * @param string $name Name of the block + * @return bool + */ + public function exists($name) { + return $this->Blocks->exists($name); + } + /** * End a capturing block. The compliment to View::start() * diff --git a/lib/Cake/View/ViewBlock.php b/lib/Cake/View/ViewBlock.php index f45119db7a4..51ec8e767b7 100644 --- a/lib/Cake/View/ViewBlock.php +++ b/lib/Cake/View/ViewBlock.php @@ -196,6 +196,16 @@ public function get($name, $default = '') { return $this->_blocks[$name]; } +/** + * Check if a block exists + * + * @param string $name Name of the block + * @return bool + */ + public function exists($name) { + return isset($this->_blocks[$name]); + } + /** * Get the names of all the existing blocks. * From 515302528da096311d871f0c8db430fecdc61c95 Mon Sep 17 00:00:00 2001 From: euromark Date: Tue, 23 Dec 2014 03:26:03 +0100 Subject: [PATCH 012/336] Backport Configure::consume() to 2.x --- lib/Cake/Core/Configure.php | 24 +++++++++++++++++++++++ lib/Cake/Test/Case/Core/ConfigureTest.php | 20 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/lib/Cake/Core/Configure.php b/lib/Cake/Core/Configure.php index 18c85589d0f..c778fc0bed8 100644 --- a/lib/Cake/Core/Configure.php +++ b/lib/Cake/Core/Configure.php @@ -190,6 +190,30 @@ public static function read($var = null) { return Hash::get(self::$_values, $var); } +/** + * Used to read and delete a variable from Configure. + * + * This is primarily used during bootstrapping to move configuration data + * out of configure into the various other classes in CakePHP. + * + * @param string $var The key to read and remove. + * @return array|null + */ + public static function consume($var) { + $simple = strpos($var, '.') === false; + if ($simple && !isset(self::$_values[$var])) { + return null; + } + if ($simple) { + $value = self::$_values[$var]; + unset(self::$_values[$var]); + return $value; + } + $value = Hash::get(self::$_values, $var); + self::$_values = Hash::remove(self::$_values, $var); + return $value; + } + /** * Returns true if given variable is set in Configure. * diff --git a/lib/Cake/Test/Case/Core/ConfigureTest.php b/lib/Cake/Test/Case/Core/ConfigureTest.php index f91218418c2..717b52bc569 100644 --- a/lib/Cake/Test/Case/Core/ConfigureTest.php +++ b/lib/Cake/Test/Case/Core/ConfigureTest.php @@ -148,6 +148,26 @@ public function testWrite() { $this->assertEquals('4', $result); } +/** + * Test the consume method. + * + * @return void + */ + public function testConsume() { + $this->assertNull(Configure::consume('DoesNotExist'), 'Should be null on empty value'); + Configure::write('Test', ['key' => 'value', 'key2' => 'value2']); + + $result = Configure::consume('Test.key'); + $this->assertEquals('value', $result); + + $result = Configure::read('Test.key2'); + $this->assertEquals('value2', $result, 'Other values should remain.'); + + $result = Configure::consume('Test'); + $expected = ['key2' => 'value2']; + $this->assertEquals($expected, $result); + } + /** * test setting display_errors with debug. * From 5af24bdb31d50d4f47ed13940867dc52b8477212 Mon Sep 17 00:00:00 2001 From: euromark Date: Tue, 23 Dec 2014 03:29:52 +0100 Subject: [PATCH 013/336] Correct array syntax. --- lib/Cake/Test/Case/Core/ConfigureTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/Core/ConfigureTest.php b/lib/Cake/Test/Case/Core/ConfigureTest.php index 717b52bc569..435e6b310a8 100644 --- a/lib/Cake/Test/Case/Core/ConfigureTest.php +++ b/lib/Cake/Test/Case/Core/ConfigureTest.php @@ -155,7 +155,7 @@ public function testWrite() { */ public function testConsume() { $this->assertNull(Configure::consume('DoesNotExist'), 'Should be null on empty value'); - Configure::write('Test', ['key' => 'value', 'key2' => 'value2']); + Configure::write('Test', array('key' => 'value', 'key2' => 'value2')); $result = Configure::consume('Test.key'); $this->assertEquals('value', $result); @@ -164,7 +164,7 @@ public function testConsume() { $this->assertEquals('value2', $result, 'Other values should remain.'); $result = Configure::consume('Test'); - $expected = ['key2' => 'value2']; + $expected = array('key2' => 'value2'); $this->assertEquals($expected, $result); } From 813925abeeb8526ab19e9cd9acd9314a50765864 Mon Sep 17 00:00:00 2001 From: euromark Date: Tue, 23 Dec 2014 03:39:05 +0100 Subject: [PATCH 014/336] Backport Session consume() --- lib/Cake/Model/Datasource/CakeSession.php | 18 +++++++++++++++ .../Case/Model/Datasource/CakeSessionTest.php | 22 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index 6d7d53a20da..536b1073055 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -432,6 +432,24 @@ public static function write($name, $value = null) { return true; } +/** + * Reads and deletes a variable from session. + * + * @param string $name The key to read and remove (or a path as sent to Hash.extract). + * @return mixed The value of the session variable, null if session not available, + * session not started, or provided name not found in the session. + */ + public static function consume($name) { + if (empty($name)) { + return null; + } + $value = self::read($name); + if ($value !== null) { + self::_overwrite($_SESSION, Hash::remove($_SESSION, $name)); + } + return $value; + } + /** * Helper method to destroy invalid sessions. * diff --git a/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php b/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php index 534aaa1edcc..469100d94f8 100644 --- a/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php @@ -328,6 +328,28 @@ public function testWriteOverwriteStringValue() { ); } +/** + * Test consuming session data. + * + * @return void + */ + public function testConsume() { + TestCakeSession::write('Some.string', 'value'); + TestCakeSession::write('Some.array', array('key1' => 'value1', 'key2' => 'value2')); + $this->assertEquals('value', TestCakeSession::read('Some.string')); + $value = TestCakeSession::consume('Some.string'); + $this->assertEquals('value', $value); + $this->assertFalse(TestCakeSession::check('Some.string')); + $value = TestCakeSession::consume(''); + $this->assertNull($value); + $value = TestCakeSession::consume(null); + $this->assertNull($value); + $value = TestCakeSession::consume('Some.array'); + $expected = array('key1' => 'value1', 'key2' => 'value2'); + $this->assertEquals($expected, $value); + $this->assertFalse(TestCakeSession::check('Some.array')); + } + /** * testId method * From 545ff20e1dbb575db1eef17360f4e7c4343db2fa Mon Sep 17 00:00:00 2001 From: euromark Date: Tue, 23 Dec 2014 03:50:35 +0100 Subject: [PATCH 015/336] Add component and helper wrapper methods. --- .../Controller/Component/SessionComponent.php | 20 +++++++++++++++---- lib/Cake/View/Helper/SessionHelper.php | 16 +++++++++++++-- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/lib/Cake/Controller/Component/SessionComponent.php b/lib/Cake/Controller/Component/SessionComponent.php index 9ce9a38f93b..67bc4f42685 100644 --- a/lib/Cake/Controller/Component/SessionComponent.php +++ b/lib/Cake/Controller/Component/SessionComponent.php @@ -41,7 +41,7 @@ public function userAgent($userAgent = null) { } /** - * Used to write a value to a session key. + * Writes a value to a session key. * * In your controller: $this->Session->write('Controller.sessKey', 'session value'); * @@ -56,7 +56,7 @@ public function write($name, $value = null) { } /** - * Used to read a session values for a key or return values for all keys. + * Reads a session value for a key or returns values for all keys. * * In your controller: $this->Session->read('Controller.sessKey'); * Calling the method without a param will return all session vars @@ -70,7 +70,7 @@ public function read($name = null) { } /** - * Wrapper for SessionComponent::del(); + * Deletes a session value for a key. * * In your controller: $this->Session->delete('Controller.sessKey'); * @@ -83,7 +83,19 @@ public function delete($name) { } /** - * Used to check if a session variable is set + * Reads and deletes a session value for a key. + * + * In your controller: `$this->Session->consume('Controller.sessKey');` + * + * @param string $name the name of the session key you want to read + * @return mixed values from the session vars + */ + public function consume($name) { + return CakeSession::consume($name); + } + +/** + * Checks if a session variable is set. * * In your controller: $this->Session->check('Controller.sessKey'); * diff --git a/lib/Cake/View/Helper/SessionHelper.php b/lib/Cake/View/Helper/SessionHelper.php index 9ea5e65f9ab..6d2ac48f6f1 100644 --- a/lib/Cake/View/Helper/SessionHelper.php +++ b/lib/Cake/View/Helper/SessionHelper.php @@ -30,7 +30,7 @@ class SessionHelper extends AppHelper { /** - * Used to read a session values set in a controller for a key or return values for all keys. + * Reads a session value for a key or returns values for all keys. * * In your view: `$this->Session->read('Controller.sessKey');` * Calling the method without a param will return all session vars @@ -44,7 +44,19 @@ public function read($name = null) { } /** - * Used to check is a session key has been set + * Reads and deletes a session value for a key. + * + * In your view: `$this->Session->consume('Controller.sessKey');` + * + * @param string $name the name of the session key you want to read + * @return mixed values from the session vars + */ + public function consume($name) { + return CakeSession::consume($name); + } + +/** + * Checks if a session key has been set. * * In your view: `$this->Session->check('Controller.sessKey');` * From 53f1390b7d567ca72b697e37942dc6c15a564b20 Mon Sep 17 00:00:00 2001 From: euromark Date: Tue, 23 Dec 2014 13:42:21 +0100 Subject: [PATCH 016/336] Backport array support for testAction() --- .../Test/Case/TestSuite/ControllerTestCaseTest.php | 11 +++++++++++ lib/Cake/TestSuite/ControllerTestCase.php | 8 ++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php b/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php index 4eb1d301142..e101505d82c 100644 --- a/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php +++ b/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php @@ -299,6 +299,17 @@ public function testTestAction() { $this->assertEquals($expected, $results); } +/** + * Test array URLs with testAction() + * + * @return void + */ + public function testTestActionArrayUrls() { + $Controller = $this->Case->generate('TestsApps'); + $this->Case->testAction(array('controller' => 'tests_apps', 'action' => 'index')); + $this->assertInternalType('array', $this->Case->controller->viewVars); + } + /** * Make sure testAction() can hit plugin controllers. * diff --git a/lib/Cake/TestSuite/ControllerTestCase.php b/lib/Cake/TestSuite/ControllerTestCase.php index e7577a6af6b..2596a269539 100644 --- a/lib/Cake/TestSuite/ControllerTestCase.php +++ b/lib/Cake/TestSuite/ControllerTestCase.php @@ -210,12 +210,12 @@ public function __call($name, $arguments) { * - `result` Get the return value of the controller action. Useful * for testing requestAction methods. * - * @param string $url The url to test + * @param string|array $url The url to test * @param array $options See options * @return mixed The specified return type. * @triggers ControllerTestCase $Dispatch, array('request' => $request) */ - protected function _testAction($url = '', $options = array()) { + protected function _testAction($url, $options = array()) { $this->vars = $this->result = $this->view = $this->contents = $this->headers = null; $options += array( @@ -224,6 +224,10 @@ protected function _testAction($url = '', $options = array()) { 'return' => 'result' ); + if (is_array($url)) { + $url = Router::url($url); + } + $restore = array('get' => $_GET, 'post' => $_POST); $_SERVER['REQUEST_METHOD'] = strtoupper($options['method']); From d089341ee7872ec3d50740535dea29901992ce70 Mon Sep 17 00:00:00 2001 From: euromark Date: Tue, 23 Dec 2014 13:46:55 +0100 Subject: [PATCH 017/336] Wording. --- lib/Cake/TestSuite/ControllerTestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/TestSuite/ControllerTestCase.php b/lib/Cake/TestSuite/ControllerTestCase.php index 2596a269539..1edd40fdd5c 100644 --- a/lib/Cake/TestSuite/ControllerTestCase.php +++ b/lib/Cake/TestSuite/ControllerTestCase.php @@ -210,7 +210,7 @@ public function __call($name, $arguments) { * - `result` Get the return value of the controller action. Useful * for testing requestAction methods. * - * @param string|array $url The url to test + * @param string|array $url The URL to test. * @param array $options See options * @return mixed The specified return type. * @triggers ControllerTestCase $Dispatch, array('request' => $request) From e5fc1858f93857d64ddb8bbb6efe1d723b567310 Mon Sep 17 00:00:00 2001 From: Kaz Watanabe Date: Tue, 30 Dec 2014 09:24:31 +0900 Subject: [PATCH 018/336] fix error at change type of text field to integer in PostgreSQL --- .../Model/Datasource/Database/Postgres.php | 6 +++- .../Datasource/Database/PostgresTest.php | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Model/Datasource/Database/Postgres.php b/lib/Cake/Model/Datasource/Database/Postgres.php index 87b26798fd3..acac1ff17ae 100644 --- a/lib/Cake/Model/Datasource/Database/Postgres.php +++ b/lib/Cake/Model/Datasource/Database/Postgres.php @@ -558,7 +558,11 @@ public function alterSchema($compare, $table = null) { $colList[] = 'ALTER COLUMN ' . $fieldName . ' SET DEFAULT NULL'; $colList[] = 'ALTER COLUMN ' . $fieldName . ' TYPE ' . str_replace(array($fieldName, 'NOT NULL'), '', $this->buildColumn($col)) . ' USING CASE WHEN TRUE THEN 1 ELSE 0 END'; } else { - $colList[] = 'ALTER COLUMN ' . $fieldName . ' TYPE ' . str_replace(array($fieldName, 'NOT NULL'), '', $this->buildColumn($col)); + if ($original['type'] === 'text' && $col['type'] === 'integer') { + $colList[] = 'ALTER COLUMN ' . $fieldName . ' TYPE ' . str_replace(array($fieldName, 'NOT NULL'), '', $this->buildColumn($col)) . " USING cast({$fieldName} as INTEGER)"; + } else { + $colList[] = 'ALTER COLUMN ' . $fieldName . ' TYPE ' . str_replace(array($fieldName, 'NOT NULL'), '', $this->buildColumn($col)); + } } if (isset($nullable)) { diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php index e41567150f3..97cf4c4ab1a 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php @@ -731,6 +731,34 @@ public function testAlterSchemaBooleanToIntegerField() { $this->Dbo->query($this->Dbo->dropSchema($Old)); } +/** + * Test the alterSchema changing text to integer + * + * @return void + */ + public function testAlterSchemaTextToIntegerField() { + $default = array( + 'connection' => 'test', + 'name' => 'TextField', + 'text_fields' => array( + 'id' => array('type' => 'integer', 'key' => 'primary'), + 'name' => array('type' => 'string', 'length' => 50), + 'active' => array('type' => 'text', 'null' => false), + ) + ); + $Old = new CakeSchema($default); + $result = $this->Dbo->query($this->Dbo->createSchema($Old)); + $this->assertTrue($result); + + $modified = $default; + $modified['text_fields']['active'] = array('type' => 'integer', 'null' => true); + + $New = new CakeSchema($modified); + $query = $this->Dbo->alterSchema($New->compare($Old)); + $result = $this->Dbo->query($query); + $this->Dbo->query($this->Dbo->dropSchema($Old)); + } + /** * Test the alter index capabilities of postgres * From 39e0ce415d574fbb7daeafa004b8e1e1cbba6b97 Mon Sep 17 00:00:00 2001 From: euromark Date: Sun, 4 Jan 2015 01:40:09 +0100 Subject: [PATCH 019/336] Backport of 3.0 Session API hardening and clear(). --- lib/Cake/Model/Datasource/CakeSession.php | 25 +++++++++++-------- .../Case/Model/Datasource/CakeSessionTest.php | 20 ++++++++++++++- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index 3451642a341..4f1ff8d5eef 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -137,7 +137,7 @@ class CakeSession { /** * Pseudo constructor. * - * @param string $base The base path for the Session + * @param string|null $base The base path for the Session * @return void */ public static function init($base = null) { @@ -160,7 +160,7 @@ public static function init($base = null) { /** * Setup the Path variable * - * @param string $base base path + * @param string|null $base base path * @return void */ protected static function _setPath($base = null) { @@ -227,7 +227,7 @@ public static function started() { * @param string $name Variable name to check for * @return bool True if variable is there */ - public static function check($name = null) { + public static function check($name) { if (empty($name) || !self::_hasSession() || !self::start()) { return false; } @@ -246,7 +246,7 @@ public static function check($name = null) { * within the session id. For example, the file session handler only allows * characters in the range a-z A-Z 0-9 , (comma) and - (minus). * - * @param string $id Id to replace the current session id + * @param string|null $id Id to replace the current session id * @return string Session id */ public static function id($id = null) { @@ -356,7 +356,7 @@ protected static function _validAgentAndTime() { /** * Get / Set the user agent * - * @param string $userAgent Set the user agent + * @param string|null $userAgent Set the user agent * @return string Current user agent */ public static function userAgent($userAgent = null) { @@ -372,7 +372,7 @@ public static function userAgent($userAgent = null) { /** * Returns given session variable, or all of them, if no parameters given. * - * @param string|array $name The name of the session variable (or a path as sent to Set.extract) + * @param string|null $name The name of the session variable (or a path as sent to Set.extract) * @return mixed The value of the session variable, null if session not available, * session not started, or provided name not found in the session. */ @@ -468,14 +468,19 @@ public static function destroy() { } /** - * Clears the session, the session id, and renews the session. + * Clears the session. * + * Optionally also clears the session id and renews the session. + * + * @param bool $renew If the session should also be renewed. Defaults to false. * @return void */ - public static function clear() { + public static function clear($renew = false) { $_SESSION = null; - self::$id = null; - self::renew(); + if ($renew) { + self::$id = null; + self::renew(); + } } /** diff --git a/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php b/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php index 469100d94f8..74727a503f2 100644 --- a/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php @@ -393,11 +393,28 @@ public function testDelete() { $this->assertTrue(TestCakeSession::check('Delete')); $this->assertTrue(TestCakeSession::write('Clearing.sale', 'everything must go')); + $this->assertFalse(TestCakeSession::delete('')); + $this->assertTrue(TestCakeSession::check('Clearing.sale')); + $this->assertFalse(TestCakeSession::delete(null)); + $this->assertTrue(TestCakeSession::check('Clearing.sale')); + $this->assertTrue(TestCakeSession::delete('Clearing')); $this->assertFalse(TestCakeSession::check('Clearing.sale')); $this->assertFalse(TestCakeSession::check('Clearing')); } + /** + * testClear method + * + * @return void + */ + public function testClear() { + $this->assertTrue(TestCakeSession::write('Delete.me', 'Clearing out')); + TestCakeSession::clear(); + $this->assertFalse(TestCakeSession::check('Delete.me')); + $this->assertFalse(TestCakeSession::check('Delete')); + } + /** * testDestroy method * @@ -451,7 +468,8 @@ public function testCheckKeyWithSpaces() { * @return void */ public function testCheckEmpty() { - $this->assertFalse(TestCakeSession::check()); + $this->assertFalse(TestCakeSession::check('')); + $this->assertFalse(TestCakeSession::check(null)); } /** From b936a34471f97aa50e6fc1173912e24480db7327 Mon Sep 17 00:00:00 2001 From: euromark Date: Sun, 4 Jan 2015 01:57:06 +0100 Subject: [PATCH 020/336] Backport of 3.0 Configure corrections. --- lib/Cake/Core/Configure.php | 10 +++++----- lib/Cake/Test/Case/Core/ConfigureTest.php | 22 ++++++++++++++++++---- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/lib/Cake/Core/Configure.php b/lib/Cake/Core/Configure.php index c778fc0bed8..88eedfd51e6 100644 --- a/lib/Cake/Core/Configure.php +++ b/lib/Cake/Core/Configure.php @@ -179,7 +179,7 @@ public static function write($config, $value = null) { * Configure::read('Name.key'); will return only the value of Configure::Name[key] * }}} * - * @param string $var Variable to obtain. Use '.' to access array elements. + * @param string|null $var Variable to obtain. Use '.' to access array elements. * @return mixed value stored in configure, or null. * @link http://book.cakephp.org/2.0/en/development/configuration.html#Configure::read */ @@ -220,7 +220,7 @@ public static function consume($var) { * @param string $var Variable name to check for * @return bool True if variable is there */ - public static function check($var = null) { + public static function check($var) { if (empty($var)) { return false; } @@ -240,7 +240,7 @@ public static function check($var = null) { * @return void * @link http://book.cakephp.org/2.0/en/development/configuration.html#Configure::delete */ - public static function delete($var = null) { + public static function delete($var) { self::$_values = Hash::remove(self::$_values, $var); } @@ -265,7 +265,7 @@ public static function config($name, ConfigReaderInterface $reader) { /** * Gets the names of the configured reader objects. * - * @param string $name Name to check. If null returns all configured reader names. + * @param string|null $name Name to check. If null returns all configured reader names. * @return array Array of the configured reader objects. */ public static function configured($name = null) { @@ -443,7 +443,7 @@ public static function restore($name, $cacheConfig = 'default') { /** * Clear all values stored in Configure. * - * @return bool success. + * @return bool Success. */ public static function clear() { self::$_values = array(); diff --git a/lib/Cake/Test/Case/Core/ConfigureTest.php b/lib/Cake/Test/Case/Core/ConfigureTest.php index 435e6b310a8..d8837b9488b 100644 --- a/lib/Cake/Test/Case/Core/ConfigureTest.php +++ b/lib/Cake/Test/Case/Core/ConfigureTest.php @@ -168,6 +168,19 @@ public function testConsume() { $this->assertEquals($expected, $result); } + /** + * testConsumeEmpty + * + * @return void + */ + public function testConsumeEmpty() { + Configure::write('Test', array('key' => 'value', 'key2' => 'value2')); + $result = Configure::consume(''); + $this->assertNull($result); + $result = Configure::consume(null); + $this->assertNull($result); + } + /** * test setting display_errors with debug. * @@ -195,7 +208,7 @@ public function testDelete() { Configure::delete('SomeName.someKey'); $result = Configure::read('SomeName.someKey'); - $this->assertTrue($result === null); + $this->assertNull($result); Configure::write('SomeName', array('someKey' => 'myvalue', 'otherKey' => 'otherValue')); @@ -208,10 +221,10 @@ public function testDelete() { Configure::delete('SomeName'); $result = Configure::read('SomeName.someKey'); - $this->assertTrue($result === null); + $this->assertNull($result); $result = Configure::read('SomeName.otherKey'); - $this->assertTrue($result === null); + $this->assertNull($result); } /** @@ -265,7 +278,8 @@ public function testCheckKeyWithSpaces() { * @return void */ public function testCheckEmpty() { - $this->assertFalse(Configure::check()); + $this->assertFalse(Configure::check('')); + $this->assertFalse(Configure::check(null)); } /** From d848c5f32782f0bd0086aff02e8dc2373f4ab57e Mon Sep 17 00:00:00 2001 From: euromark Date: Sun, 4 Jan 2015 02:22:37 +0100 Subject: [PATCH 021/336] cs --- .../Test/Case/Model/Datasource/CakeSessionTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php b/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php index 74727a503f2..361822aa229 100644 --- a/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php @@ -403,11 +403,11 @@ public function testDelete() { $this->assertFalse(TestCakeSession::check('Clearing')); } - /** - * testClear method - * - * @return void - */ +/** + * testClear method + * + * @return void + */ public function testClear() { $this->assertTrue(TestCakeSession::write('Delete.me', 'Clearing out')); TestCakeSession::clear(); From a947958dc9d792ca979761ce679743e8cfc85394 Mon Sep 17 00:00:00 2001 From: euromark Date: Sun, 4 Jan 2015 02:27:40 +0100 Subject: [PATCH 022/336] Fix cs --- lib/Cake/Test/Case/Core/ConfigureTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Test/Case/Core/ConfigureTest.php b/lib/Cake/Test/Case/Core/ConfigureTest.php index d8837b9488b..a0c321e1ace 100644 --- a/lib/Cake/Test/Case/Core/ConfigureTest.php +++ b/lib/Cake/Test/Case/Core/ConfigureTest.php @@ -168,11 +168,11 @@ public function testConsume() { $this->assertEquals($expected, $result); } - /** - * testConsumeEmpty - * - * @return void - */ +/** + * testConsumeEmpty + * + * @return void + */ public function testConsumeEmpty() { Configure::write('Test', array('key' => 'value', 'key2' => 'value2')); $result = Configure::consume(''); From 394da88d234ea66fa53c08f1b7979cc4457961c1 Mon Sep 17 00:00:00 2001 From: euromark Date: Sun, 4 Jan 2015 10:52:18 +0100 Subject: [PATCH 023/336] Stay 100% BC for 2.7 --- lib/Cake/Model/Datasource/CakeSession.php | 4 ++-- lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index 4f1ff8d5eef..fa89d041097 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -472,10 +472,10 @@ public static function destroy() { * * Optionally also clears the session id and renews the session. * - * @param bool $renew If the session should also be renewed. Defaults to false. + * @param bool $renew If the session should also be renewed. Defaults to true. * @return void */ - public static function clear($renew = false) { + public static function clear($renew = true) { $_SESSION = null; if ($renew) { self::$id = null; diff --git a/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php b/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php index 361822aa229..2b7cac57946 100644 --- a/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php @@ -410,7 +410,7 @@ public function testDelete() { */ public function testClear() { $this->assertTrue(TestCakeSession::write('Delete.me', 'Clearing out')); - TestCakeSession::clear(); + TestCakeSession::clear(false); $this->assertFalse(TestCakeSession::check('Delete.me')); $this->assertFalse(TestCakeSession::check('Delete')); } From 722e54279cc8c7f7c0c9bfc7ec4b61dc761c8722 Mon Sep 17 00:00:00 2001 From: euromark Date: Mon, 5 Jan 2015 00:53:32 +0100 Subject: [PATCH 024/336] Rename String to CakeText. --- lib/Cake/Utility/{String.php => CakeText.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lib/Cake/Utility/{String.php => CakeText.php} (100%) diff --git a/lib/Cake/Utility/String.php b/lib/Cake/Utility/CakeText.php similarity index 100% rename from lib/Cake/Utility/String.php rename to lib/Cake/Utility/CakeText.php From 274b78e44c2d3238e97a872ba6cadb2bd72fe3c2 Mon Sep 17 00:00:00 2001 From: euromark Date: Mon, 5 Jan 2015 00:54:36 +0100 Subject: [PATCH 025/336] Rename test case. --- lib/Cake/Test/Case/Utility/{StringTest.php => CakeTextTest.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lib/Cake/Test/Case/Utility/{StringTest.php => CakeTextTest.php} (100%) diff --git a/lib/Cake/Test/Case/Utility/StringTest.php b/lib/Cake/Test/Case/Utility/CakeTextTest.php similarity index 100% rename from lib/Cake/Test/Case/Utility/StringTest.php rename to lib/Cake/Test/Case/Utility/CakeTextTest.php From 63093e1d30fc00a5fc2ff89aa6973775459ab8c7 Mon Sep 17 00:00:00 2001 From: euromark Date: Mon, 5 Jan 2015 00:55:23 +0100 Subject: [PATCH 026/336] More String CakeText replacements and a BC class. --- lib/Cake/Test/Case/Utility/CakeTextTest.php | 127 +++++++++--------- .../Test/Case/View/Helper/TextHelperTest.php | 14 +- lib/Cake/Utility/CakeText.php | 30 ++--- lib/Cake/Utility/String.php | 27 ++++ lib/Cake/View/Helper/TextHelper.php | 8 +- 5 files changed, 119 insertions(+), 87 deletions(-) create mode 100644 lib/Cake/Utility/String.php diff --git a/lib/Cake/Test/Case/Utility/CakeTextTest.php b/lib/Cake/Test/Case/Utility/CakeTextTest.php index 775f02832c1..4692673462e 100644 --- a/lib/Cake/Test/Case/Utility/CakeTextTest.php +++ b/lib/Cake/Test/Case/Utility/CakeTextTest.php @@ -1,6 +1,6 @@ Text = new String(); + $this->Text = new CakeText(); } public function tearDown() { @@ -41,7 +41,7 @@ public function tearDown() { * @return void */ public function testUuidGeneration() { - $result = String::uuid(); + $result = CakeText::uuid(); $pattern = "/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/"; $match = (bool)preg_match($pattern, $result); $this->assertTrue($match); @@ -58,7 +58,7 @@ public function testMultipleUuidGeneration() { $pattern = "/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/"; for ($i = 0; $i < $count; $i++) { - $result = String::uuid(); + $result = CakeText::uuid(); $match = (bool)preg_match($pattern, $result); $this->assertTrue($match); $this->assertFalse(in_array($result, $check)); @@ -74,127 +74,127 @@ public function testMultipleUuidGeneration() { public function testInsert() { $string = 'some string'; $expected = 'some string'; - $result = String::insert($string, array()); + $result = CakeText::insert($string, array()); $this->assertEquals($expected, $result); $string = '2 + 2 = :sum. Cake is :adjective.'; $expected = '2 + 2 = 4. Cake is yummy.'; - $result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy')); + $result = CakeText::insert($string, array('sum' => '4', 'adjective' => 'yummy')); $this->assertEquals($expected, $result); $string = '2 + 2 = %sum. Cake is %adjective.'; - $result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('before' => '%')); + $result = CakeText::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('before' => '%')); $this->assertEquals($expected, $result); $string = '2 + 2 = 2sum2. Cake is 9adjective9.'; - $result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('format' => '/([\d])%s\\1/')); + $result = CakeText::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('format' => '/([\d])%s\\1/')); $this->assertEquals($expected, $result); $string = '2 + 2 = 12sum21. Cake is 23adjective45.'; $expected = '2 + 2 = 4. Cake is 23adjective45.'; - $result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('format' => '/([\d])([\d])%s\\2\\1/')); + $result = CakeText::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('format' => '/([\d])([\d])%s\\2\\1/')); $this->assertEquals($expected, $result); $string = ':web :web_site'; $expected = 'www http'; - $result = String::insert($string, array('web' => 'www', 'web_site' => 'http')); + $result = CakeText::insert($string, array('web' => 'www', 'web_site' => 'http')); $this->assertEquals($expected, $result); $string = '2 + 2 = .'; $expected = '2 + 2 = '4', 'adjective' => 'yummy'), array('before' => '<', 'after' => '>')); + $result = CakeText::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('before' => '<', 'after' => '>')); $this->assertEquals($expected, $result); $string = '2 + 2 = \:sum. Cake is :adjective.'; $expected = '2 + 2 = :sum. Cake is yummy.'; - $result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy')); + $result = CakeText::insert($string, array('sum' => '4', 'adjective' => 'yummy')); $this->assertEquals($expected, $result); $string = '2 + 2 = !:sum. Cake is :adjective.'; - $result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('escape' => '!')); + $result = CakeText::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('escape' => '!')); $this->assertEquals($expected, $result); $string = '2 + 2 = \%sum. Cake is %adjective.'; $expected = '2 + 2 = %sum. Cake is yummy.'; - $result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('before' => '%')); + $result = CakeText::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('before' => '%')); $this->assertEquals($expected, $result); $string = ':a :b \:a :a'; $expected = '1 2 :a 1'; - $result = String::insert($string, array('a' => 1, 'b' => 2)); + $result = CakeText::insert($string, array('a' => 1, 'b' => 2)); $this->assertEquals($expected, $result); $string = ':a :b :c'; $expected = '2 3'; - $result = String::insert($string, array('b' => 2, 'c' => 3), array('clean' => true)); + $result = CakeText::insert($string, array('b' => 2, 'c' => 3), array('clean' => true)); $this->assertEquals($expected, $result); $string = ':a :b :c'; $expected = '1 3'; - $result = String::insert($string, array('a' => 1, 'c' => 3), array('clean' => true)); + $result = CakeText::insert($string, array('a' => 1, 'c' => 3), array('clean' => true)); $this->assertEquals($expected, $result); $string = ':a :b :c'; $expected = '2 3'; - $result = String::insert($string, array('b' => 2, 'c' => 3), array('clean' => true)); + $result = CakeText::insert($string, array('b' => 2, 'c' => 3), array('clean' => true)); $this->assertEquals($expected, $result); $string = ':a, :b and :c'; $expected = '2 and 3'; - $result = String::insert($string, array('b' => 2, 'c' => 3), array('clean' => true)); + $result = CakeText::insert($string, array('b' => 2, 'c' => 3), array('clean' => true)); $this->assertEquals($expected, $result); $string = '":a, :b and :c"'; $expected = '"1, 2"'; - $result = String::insert($string, array('a' => 1, 'b' => 2), array('clean' => true)); + $result = CakeText::insert($string, array('a' => 1, 'b' => 2), array('clean' => true)); $this->assertEquals($expected, $result); $string = '"${a}, ${b} and ${c}"'; $expected = '"1, 2"'; - $result = String::insert($string, array('a' => 1, 'b' => 2), array('before' => '${', 'after' => '}', 'clean' => true)); + $result = CakeText::insert($string, array('a' => 1, 'b' => 2), array('before' => '${', 'after' => '}', 'clean' => true)); $this->assertEquals($expected, $result); $string = ':alt'; $expected = ''; - $result = String::insert($string, array('src' => 'foo'), array('clean' => 'html')); + $result = CakeText::insert($string, array('src' => 'foo'), array('clean' => 'html')); $this->assertEquals($expected, $result); $string = ''; $expected = ''; - $result = String::insert($string, array('src' => 'foo'), array('clean' => 'html')); + $result = CakeText::insert($string, array('src' => 'foo'), array('clean' => 'html')); $this->assertEquals($expected, $result); $string = ''; $expected = ''; - $result = String::insert($string, array('src' => 'foo', 'extra' => 'bar'), array('clean' => 'html')); + $result = CakeText::insert($string, array('src' => 'foo', 'extra' => 'bar'), array('clean' => 'html')); $this->assertEquals($expected, $result); - $result = String::insert("this is a ? string", "test"); + $result = CakeText::insert("this is a ? string", "test"); $expected = "this is a test string"; $this->assertEquals($expected, $result); - $result = String::insert("this is a ? string with a ? ? ?", array('long', 'few?', 'params', 'you know')); + $result = CakeText::insert("this is a ? string with a ? ? ?", array('long', 'few?', 'params', 'you know')); $expected = "this is a long string with a few? params you know"; $this->assertEquals($expected, $result); - $result = String::insert('update saved_urls set url = :url where id = :id', array('url' => 'http://www.testurl.com/param1:url/param2:id', 'id' => 1)); + $result = CakeText::insert('update saved_urls set url = :url where id = :id', array('url' => 'http://www.testurl.com/param1:url/param2:id', 'id' => 1)); $expected = "update saved_urls set url = http://www.testurl.com/param1:url/param2:id where id = 1"; $this->assertEquals($expected, $result); - $result = String::insert('update saved_urls set url = :url where id = :id', array('id' => 1, 'url' => 'http://www.testurl.com/param1:url/param2:id')); + $result = CakeText::insert('update saved_urls set url = :url where id = :id', array('id' => 1, 'url' => 'http://www.testurl.com/param1:url/param2:id')); $expected = "update saved_urls set url = http://www.testurl.com/param1:url/param2:id where id = 1"; $this->assertEquals($expected, $result); - $result = String::insert(':me cake. :subject :verb fantastic.', array('me' => 'I :verb', 'subject' => 'cake', 'verb' => 'is')); + $result = CakeText::insert(':me cake. :subject :verb fantastic.', array('me' => 'I :verb', 'subject' => 'cake', 'verb' => 'is')); $expected = "I :verb cake. cake is fantastic."; $this->assertEquals($expected, $result); - $result = String::insert(':I.am: :not.yet: passing.', array('I.am' => 'We are'), array('before' => ':', 'after' => ':', 'clean' => array('replacement' => ' of course', 'method' => 'text'))); + $result = CakeText::insert(':I.am: :not.yet: passing.', array('I.am' => 'We are'), array('before' => ':', 'after' => ':', 'clean' => array('replacement' => ' of course', 'method' => 'text'))); $expected = "We are of course passing."; $this->assertEquals($expected, $result); - $result = String::insert( + $result = CakeText::insert( ':I.am: :not.yet: passing.', array('I.am' => 'We are'), array('before' => ':', 'after' => ':', 'clean' => true) @@ -202,28 +202,28 @@ public function testInsert() { $expected = "We are passing."; $this->assertEquals($expected, $result); - $result = String::insert('?-pended result', array('Pre')); + $result = CakeText::insert('?-pended result', array('Pre')); $expected = "Pre-pended result"; $this->assertEquals($expected, $result); $string = 'switching :timeout / :timeout_count'; $expected = 'switching 5 / 10'; - $result = String::insert($string, array('timeout' => 5, 'timeout_count' => 10)); + $result = CakeText::insert($string, array('timeout' => 5, 'timeout_count' => 10)); $this->assertEquals($expected, $result); $string = 'switching :timeout / :timeout_count'; $expected = 'switching 5 / 10'; - $result = String::insert($string, array('timeout_count' => 10, 'timeout' => 5)); + $result = CakeText::insert($string, array('timeout_count' => 10, 'timeout' => 5)); $this->assertEquals($expected, $result); $string = 'switching :timeout_count by :timeout'; $expected = 'switching 10 by 5'; - $result = String::insert($string, array('timeout' => 5, 'timeout_count' => 10)); + $result = CakeText::insert($string, array('timeout' => 5, 'timeout_count' => 10)); $this->assertEquals($expected, $result); $string = 'switching :timeout_count by :timeout'; $expected = 'switching 10 by 5'; - $result = String::insert($string, array('timeout_count' => 10, 'timeout' => 5)); + $result = CakeText::insert($string, array('timeout_count' => 10, 'timeout' => 5)); $this->assertEquals($expected, $result); } @@ -233,33 +233,33 @@ public function testInsert() { * @return void */ public function testCleanInsert() { - $result = String::cleanInsert(':incomplete', array( + $result = CakeText::cleanInsert(':incomplete', array( 'clean' => true, 'before' => ':', 'after' => '' )); $this->assertEquals('', $result); - $result = String::cleanInsert(':incomplete', array( + $result = CakeText::cleanInsert(':incomplete', array( 'clean' => array('method' => 'text', 'replacement' => 'complete'), 'before' => ':', 'after' => '') ); $this->assertEquals('complete', $result); - $result = String::cleanInsert(':in.complete', array( + $result = CakeText::cleanInsert(':in.complete', array( 'clean' => true, 'before' => ':', 'after' => '' )); $this->assertEquals('', $result); - $result = String::cleanInsert(':in.complete and', array( + $result = CakeText::cleanInsert(':in.complete and', array( 'clean' => true, 'before' => ':', 'after' => '') ); $this->assertEquals('', $result); - $result = String::cleanInsert(':in.complete or stuff', array( + $result = CakeText::cleanInsert(':in.complete or stuff', array( 'clean' => true, 'before' => ':', 'after' => '' )); $this->assertEquals('stuff', $result); - $result = String::cleanInsert( + $result = CakeText::cleanInsert( '

Text here

', array('clean' => 'html', 'before' => ':', 'after' => '') ); @@ -268,13 +268,13 @@ public function testCleanInsert() { /** * Tests that non-insertable variables (i.e. arrays) are skipped when used as values in - * String::insert(). + * CakeText::insert(). * * @return void */ public function testAutoIgnoreBadInsertData() { $data = array('foo' => 'alpha', 'bar' => 'beta', 'fale' => array()); - $result = String::insert('(:foo > :bar || :fale!)', $data, array('clean' => 'text')); + $result = CakeText::insert('(:foo > :bar || :fale!)', $data, array('clean' => 'text')); $this->assertEquals('(alpha > beta || !)', $result); } @@ -284,35 +284,40 @@ public function testAutoIgnoreBadInsertData() { * @return void */ public function testTokenize() { - $result = String::tokenize('A,(short,boring test)'); + $result = CakeText::tokenize('A,(short,boring test)'); $expected = array('A', '(short,boring test)'); $this->assertEquals($expected, $result); - $result = String::tokenize('A,(short,more interesting( test)'); + $result = CakeText::tokenize('A,(short,more interesting( test)'); $expected = array('A', '(short,more interesting( test)'); $this->assertEquals($expected, $result); - $result = String::tokenize('A,(short,very interesting( test))'); + $result = CakeText::tokenize('A,(short,very interesting( test))'); $expected = array('A', '(short,very interesting( test))'); $this->assertEquals($expected, $result); - $result = String::tokenize('"single tag"', ' ', '"', '"'); + $result = CakeText::tokenize('"single tag"', ' ', '"', '"'); $expected = array('"single tag"'); $this->assertEquals($expected, $result); - $result = String::tokenize('tagA "single tag" tagB', ' ', '"', '"'); + $result = CakeText::tokenize('tagA "single tag" tagB', ' ', '"', '"'); $expected = array('tagA', '"single tag"', 'tagB'); $this->assertEquals($expected, $result); - $result = String::tokenize(''); + $result = CakeText::tokenize(''); $expected = array(); $this->assertEquals($expected, $result); } +/** + * testReplaceWithQuestionMarkInString method + * + * @return void + */ public function testReplaceWithQuestionMarkInString() { $string = ':a, :b and :c?'; $expected = '2 and 3?'; - $result = String::insert($string, array('b' => 2, 'c' => 3), array('clean' => true)); + $result = CakeText::insert($string, array('b' => 2, 'c' => 3), array('clean' => true)); $this->assertEquals($expected, $result); } @@ -323,7 +328,7 @@ public function testReplaceWithQuestionMarkInString() { * @return void */ public function testWordWrap($text, $width, $break = "\n", $cut = false) { - $result = String::wordWrap($text, $width, $break, $cut); + $result = CakeText::wordWrap($text, $width, $break, $cut); $expected = wordwrap($text, $width, $break, $cut); $this->assertTextEquals($expected, $result, 'Text not wrapped same as built-in function.'); } @@ -357,7 +362,7 @@ public function wordWrapProvider() { */ public function testWordWrapUnicodeAware() { $text = 'Но вим омниюм факёльиси элыктрам, мюнырэ лэгыры векж ыт. Выльёт квюандо нюмквуам ты кюм. Зыд эю рыбюм.'; - $result = String::wordWrap($text, 33, "\n", true); + $result = CakeText::wordWrap($text, 33, "\n", true); $expected = <<assertTextEquals($expected, $result, 'Text not wrapped.'); $text = 'Но вим омниюм факёльиси элыктрам, мюнырэ лэгыры векж ыт. Выльёт квюандо нюмквуам ты кюм. Зыд эю рыбюм.'; - $result = String::wordWrap($text, 33, "\n"); + $result = CakeText::wordWrap($text, 33, "\n"); $expected = <<assertTextEquals($expected, $result, 'Text not wrapped.'); - $result = String::wrap($text, array('width' => 20, 'wordWrap' => false)); + $result = CakeText::wrap($text, array('width' => 20, 'wordWrap' => false)); $expected = 'This is the song th' . "\n" . 'at never ends. This' . "\n" . ' is the song that n' . "\n" . @@ -402,7 +407,7 @@ public function testWrap() { $this->assertTextEquals($expected, $result, 'Text not wrapped.'); $text = 'Но вим омниюм факёльиси элыктрам, мюнырэ лэгыры векж ыт. Выльёт квюандо нюмквуам ты кюм. Зыд эю рыбюм.'; - $result = String::wrap($text, 33); + $result = CakeText::wrap($text, 33); $expected = << 33, 'indent' => "\t", 'indentAt' => 1)); + $result = CakeText::wrap($text, array('width' => 33, 'indent' => "\t", 'indentAt' => 1)); $expected = <<_engine = $string; } @@ -37,11 +37,11 @@ public function engine() { } /** - * StringMock class + * CakeTextMock class * * @package Cake.Test.Case.View.Helper */ -class StringMock { +class CakeTextMock { } /** @@ -81,11 +81,11 @@ public function testTextHelperProxyMethodCalls() { $methods = array( 'highlight', 'stripLinks', 'truncate', 'tail', 'excerpt', 'toList', ); - $String = $this->getMock('StringMock', $methods); - $Text = new TextHelperTestObject($this->View, array('engine' => 'StringMock')); - $Text->attach($String); + $CakeText = $this->getMock('CakeTextMock', $methods); + $Text = new TextHelperTestObject($this->View, array('engine' => 'CakeTextMock')); + $Text->attach($CakeText); foreach ($methods as $method) { - $String->expects($this->at(0))->method($method); + $CakeText->expects($this->at(0))->method($method); $Text->{$method}('who', 'what', 'when', 'where', 'how'); } } diff --git a/lib/Cake/Utility/CakeText.php b/lib/Cake/Utility/CakeText.php index 4e0130b5838..18d5763fbcd 100644 --- a/lib/Cake/Utility/CakeText.php +++ b/lib/Cake/Utility/CakeText.php @@ -21,7 +21,7 @@ * * @package Cake.Utility */ -class String { +class CakeText { /** * Generate a random UUID @@ -175,7 +175,7 @@ public static function tokenize($data, $separator = ',', $leftBound = '(', $righ /** * Replaces variable placeholders inside a $str with any given $data. Each key in the $data array * corresponds to a variable placeholder name in $str. - * Example: `String::insert(':name is :age years old.', array('name' => 'Bob', '65'));` + * Example: `CakeText::insert(':name is :age years old.', array('name' => 'Bob', '65'));` * Returns: Bob is 65 years old. * * Available $options are: @@ -185,7 +185,7 @@ public static function tokenize($data, $separator = ',', $leftBound = '(', $righ * - escape: The character or string used to escape the before character / string (Defaults to `\`) * - format: A regex to use for matching variable placeholders. Default is: `/(? val array where each key stands for a placeholder variable name @@ -201,7 +201,7 @@ public static function insert($str, $data, $options = array()) { $format = $options['format']; $data = (array)$data; if (empty($data)) { - return ($options['clean']) ? String::cleanInsert($str, $options) : $str; + return ($options['clean']) ? CakeText::cleanInsert($str, $options) : $str; } if (!isset($format)) { @@ -220,7 +220,7 @@ public static function insert($str, $data, $options = array()) { $offset = $pos + strlen($val); $str = substr_replace($str, $val, $pos, 1); } - return ($options['clean']) ? String::cleanInsert($str, $options) : $str; + return ($options['clean']) ? CakeText::cleanInsert($str, $options) : $str; } asort($data); @@ -243,19 +243,19 @@ public static function insert($str, $data, $options = array()) { if (!isset($options['format']) && isset($options['before'])) { $str = str_replace($options['escape'] . $options['before'], $options['before'], $str); } - return ($options['clean']) ? String::cleanInsert($str, $options) : $str; + return ($options['clean']) ? CakeText::cleanInsert($str, $options) : $str; } /** - * Cleans up a String::insert() formatted string with given $options depending on the 'clean' key in + * Cleans up a CakeText::insert() formatted string with given $options depending on the 'clean' key in * $options. The default method used is text but html is also available. The goal of this function * is to replace all whitespace and unneeded markup around placeholders that did not get replaced - * by String::insert(). + * by CakeText::insert(). * - * @param string $str String to clean. + * @param string $str CakeText to clean. * @param array $options Options list. * @return string - * @see String::insert() + * @see CakeText::insert() */ public static function cleanInsert($str, $options) { $clean = $options['clean']; @@ -284,7 +284,7 @@ public static function cleanInsert($str, $options) { $str = preg_replace($kleenex, $clean['replacement'], $str); if ($clean['andText']) { $options['clean'] = array('method' => 'text'); - $str = String::cleanInsert($str, $options); + $str = CakeText::cleanInsert($str, $options); } break; case 'text': @@ -318,7 +318,7 @@ public static function cleanInsert($str, $options) { * * - `width` The width to wrap to. Defaults to 72. * - `wordWrap` Only wrap on words breaks (spaces) Defaults to true. - * - `indent` String to indent with. Defaults to null. + * - `indent` CakeText to indent with. Defaults to null. * - `indentAt` 0 based index to start indenting at. Defaults to 0. * * @param string $text The text to format. @@ -470,7 +470,7 @@ public static function stripLinks($text) { * - `ellipsis` Will be used as Beginning and prepended to the trimmed string * - `exact` If false, $text will not be cut mid-word * - * @param string $text String to truncate. + * @param string $text CakeText to truncate. * @param int $length Length of returned string, including ellipsis. * @param array $options An array of options. * @return string Trimmed string. @@ -511,7 +511,7 @@ class_exists('Multibyte'); * - `exact` If false, $text will not be cut mid-word * - `html` If true, HTML tags would be handled correctly * - * @param string $text String to truncate. + * @param string $text CakeText to truncate. * @param int $length Length of returned string, including ellipsis. * @param array $options An array of html attributes and options. * @return string Trimmed string. @@ -630,7 +630,7 @@ class_exists('Multibyte'); * Extracts an excerpt from the text surrounding the phrase with a number of characters on each side * determined by radius. * - * @param string $text String to search the phrase in + * @param string $text CakeText to search the phrase in * @param string $phrase Phrase that will be searched for * @param int $radius The amount of characters that will be returned on each side of the founded phrase * @param string $ellipsis Ending that will be appended diff --git a/lib/Cake/Utility/String.php b/lib/Cake/Utility/String.php new file mode 100644 index 00000000000..7540906860c --- /dev/null +++ b/lib/Cake/Utility/String.php @@ -0,0 +1,27 @@ + 'String'), $settings); + $settings = Hash::merge(array('engine' => 'CakeText'), $settings); parent::__construct($View, $settings); list($plugin, $engineClass) = pluginSplit($settings['engine'], true); App::uses($engineClass, $plugin . 'Utility'); @@ -80,7 +80,7 @@ public function __construct(View $View, $settings = array()) { } /** - * Call methods from String utility class + * Call methods from CakeText utility class * * @param string $method Method to call. * @param array $params Parameters to pass to method. From 52ecccb1a295d4605e8777162c5017d23a5eec3c Mon Sep 17 00:00:00 2001 From: euromark Date: Mon, 5 Jan 2015 01:00:57 +0100 Subject: [PATCH 027/336] App::uses and usage replacements for String => CakeText. --- lib/Cake/Console/Command/SchemaShell.php | 4 ++-- lib/Cake/Console/Command/Task/FixtureTask.php | 2 +- lib/Cake/Console/Command/Task/ProjectTask.php | 4 ++-- lib/Cake/Console/HelpFormatter.php | 12 ++++++------ lib/Cake/Console/Shell.php | 4 ++-- lib/Cake/Controller/Component/SecurityComponent.php | 2 +- lib/Cake/Core/Configure.php | 4 ++-- lib/Cake/Model/Behavior/TranslateBehavior.php | 2 +- lib/Cake/Model/Datasource/Database/Sqlite.php | 4 ++-- lib/Cake/Model/Datasource/DboSource.php | 6 +++--- lib/Cake/Model/Model.php | 10 +++++----- lib/Cake/Network/Email/CakeEmail.php | 4 ++-- .../Case/Model/Behavior/TreeBehaviorUuidTest.php | 4 ++-- lib/Cake/Utility/Debugger.php | 12 ++++++------ lib/Cake/Utility/Hash.php | 8 ++++---- lib/Cake/Utility/Security.php | 4 ++-- lib/Cake/Utility/Set.php | 4 ++-- lib/Cake/View/Helper/TextHelper.php | 12 ++++++------ 18 files changed, 51 insertions(+), 51 deletions(-) diff --git a/lib/Cake/Console/Command/SchemaShell.php b/lib/Cake/Console/Command/SchemaShell.php index 6f77220d89c..16abb600ddf 100644 --- a/lib/Cake/Console/Command/SchemaShell.php +++ b/lib/Cake/Console/Command/SchemaShell.php @@ -122,7 +122,7 @@ public function generate() { if ($this->params['force']) { $options['models'] = false; } elseif (!empty($this->params['models'])) { - $options['models'] = String::tokenize($this->params['models']); + $options['models'] = CakeText::tokenize($this->params['models']); } $snapshot = false; @@ -151,7 +151,7 @@ public function generate() { Configure::write('Cache.disable', $cacheDisable); if (!empty($this->params['exclude']) && !empty($content)) { - $excluded = String::tokenize($this->params['exclude']); + $excluded = CakeText::tokenize($this->params['exclude']); foreach ($excluded as $table) { unset($content['tables'][$table]); } diff --git a/lib/Cake/Console/Command/Task/FixtureTask.php b/lib/Cake/Console/Command/Task/FixtureTask.php index 65404fb1cf2..b20c22b4b79 100644 --- a/lib/Cake/Console/Command/Task/FixtureTask.php +++ b/lib/Cake/Console/Command/Task/FixtureTask.php @@ -340,7 +340,7 @@ protected function _generateRecords($tableInfo, $recordCount = 1) { isset($fieldInfo['length']) && $fieldInfo['length'] == 36 ); if ($isPrimaryUuid) { - $insert = String::uuid(); + $insert = CakeText::uuid(); } else { $insert = "Lorem ipsum dolor sit amet"; if (!empty($fieldInfo['length'])) { diff --git a/lib/Cake/Console/Command/Task/ProjectTask.php b/lib/Cake/Console/Command/Task/ProjectTask.php index 4763b28765c..df1ab19db4a 100644 --- a/lib/Cake/Console/Command/Task/ProjectTask.php +++ b/lib/Cake/Console/Command/Task/ProjectTask.php @@ -18,7 +18,7 @@ App::uses('AppShell', 'Console/Command'); App::uses('File', 'Utility'); App::uses('Folder', 'Utility'); -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); App::uses('Security', 'Utility'); /** @@ -212,7 +212,7 @@ public function bake($path, $skel = null, $skip = array('empty')) { } foreach ($Folder->messages() as $message) { - $this->out(String::wrap(' * ' . $message), 1, Shell::VERBOSE); + $this->out(CakeText::wrap(' * ' . $message), 1, Shell::VERBOSE); } return true; diff --git a/lib/Cake/Console/HelpFormatter.php b/lib/Cake/Console/HelpFormatter.php index 140c289bd72..3a8fac98f99 100644 --- a/lib/Cake/Console/HelpFormatter.php +++ b/lib/Cake/Console/HelpFormatter.php @@ -14,7 +14,7 @@ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); /** * HelpFormatter formats help for console shells. Can format to either @@ -64,7 +64,7 @@ public function text($width = 72) { $out = array(); $description = $parser->description(); if (!empty($description)) { - $out[] = String::wrap($description, $width); + $out[] = CakeText::wrap($description, $width); $out[] = ''; } $out[] = __d('cake_console', 'Usage:'); @@ -76,7 +76,7 @@ public function text($width = 72) { $out[] = ''; $max = $this->_getMaxLength($subcommands) + 2; foreach ($subcommands as $command) { - $out[] = String::wrap($command->help($max), array( + $out[] = CakeText::wrap($command->help($max), array( 'width' => $width, 'indent' => str_repeat(' ', $max), 'indentAt' => 1 @@ -93,7 +93,7 @@ public function text($width = 72) { $out[] = __d('cake_console', 'Options:'); $out[] = ''; foreach ($options as $option) { - $out[] = String::wrap($option->help($max), array( + $out[] = CakeText::wrap($option->help($max), array( 'width' => $width, 'indent' => str_repeat(' ', $max), 'indentAt' => 1 @@ -108,7 +108,7 @@ public function text($width = 72) { $out[] = __d('cake_console', 'Arguments:'); $out[] = ''; foreach ($arguments as $argument) { - $out[] = String::wrap($argument->help($max), array( + $out[] = CakeText::wrap($argument->help($max), array( 'width' => $width, 'indent' => str_repeat(' ', $max), 'indentAt' => 1 @@ -118,7 +118,7 @@ public function text($width = 72) { } $epilog = $parser->epilog(); if (!empty($epilog)) { - $out[] = String::wrap($epilog, $width); + $out[] = CakeText::wrap($epilog, $width); $out[] = ''; } return implode("\n", $out); diff --git a/lib/Cake/Console/Shell.php b/lib/Cake/Console/Shell.php index 67e3c2eab29..6315a4ef900 100644 --- a/lib/Cake/Console/Shell.php +++ b/lib/Cake/Console/Shell.php @@ -584,11 +584,11 @@ protected function _getInput($prompt, $options, $default) { * @param string $text Text the text to format. * @param string|int|array $options Array of options to use, or an integer to wrap the text to. * @return string Wrapped / indented text - * @see String::wrap() + * @see CakeText::wrap() * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::wrapText */ public function wrapText($text, $options = array()) { - return String::wrap($text, $options); + return CakeText::wrap($text, $options); } /** diff --git a/lib/Cake/Controller/Component/SecurityComponent.php b/lib/Cake/Controller/Component/SecurityComponent.php index 68255eb2e93..cb41cf7ff41 100644 --- a/lib/Cake/Controller/Component/SecurityComponent.php +++ b/lib/Cake/Controller/Component/SecurityComponent.php @@ -17,7 +17,7 @@ */ App::uses('Component', 'Controller'); -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); App::uses('Hash', 'Utility'); App::uses('Security', 'Utility'); diff --git a/lib/Cake/Core/Configure.php b/lib/Cake/Core/Configure.php index 88eedfd51e6..4c26eca1b19 100644 --- a/lib/Cake/Core/Configure.php +++ b/lib/Cake/Core/Configure.php @@ -103,10 +103,10 @@ public static function bootstrap($boot = true) { self::$_values['Exception'] ); - // Preload Debugger + String in case of E_STRICT errors when loading files. + // Preload Debugger + CakeText in case of E_STRICT errors when loading files. if (self::$_values['debug'] > 0) { class_exists('Debugger'); - class_exists('String'); + class_exists('CakeText'); } } } diff --git a/lib/Cake/Model/Behavior/TranslateBehavior.php b/lib/Cake/Model/Behavior/TranslateBehavior.php index 1b0be00abfd..3ba00ff75de 100644 --- a/lib/Cake/Model/Behavior/TranslateBehavior.php +++ b/lib/Cake/Model/Behavior/TranslateBehavior.php @@ -140,7 +140,7 @@ public function beforeFind(Model $Model, $query) { unset($this->_joinTable, $this->_runtimeModel); return $query; } elseif (is_string($query['fields'])) { - $query['fields'] = String::tokenize($query['fields']); + $query['fields'] = CakeText::tokenize($query['fields']); } $fields = array_merge( diff --git a/lib/Cake/Model/Datasource/Database/Sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php index 37c3787a8f7..e7394744809 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlite.php +++ b/lib/Cake/Model/Datasource/Database/Sqlite.php @@ -17,7 +17,7 @@ */ App::uses('DboSource', 'Model/Datasource'); -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); /** * DBO implementation for the SQLite3 DBMS. @@ -303,7 +303,7 @@ public function resultSet($results) { if (stripos($querystring, 'SELECT') === 0 && stripos($querystring, 'FROM') > 0) { $selectpart = substr($querystring, 7); $selects = array(); - foreach (String::tokenize($selectpart, ',', '(', ')') as $part) { + foreach (CakeText::tokenize($selectpart, ',', '(', ')') as $part) { $fromPos = stripos($part, ' FROM '); if ($fromPos !== false) { $selects[] = trim(substr($part, 0, $fromPos)); diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index c18f3318a88..b17cf3d2b52 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -17,7 +17,7 @@ */ App::uses('DataSource', 'Model/Datasource'); -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); App::uses('View', 'View'); /** @@ -2513,7 +2513,7 @@ public function fields(Model $Model, $alias = null, $fields = array(), $quote = if ($allFields) { $fields = array_keys($Model->schema()); } elseif (!is_array($fields)) { - $fields = String::tokenize($fields); + $fields = CakeText::tokenize($fields); } $fields = array_values(array_filter($fields)); $allFields = $allFields || in_array('*', $fields) || in_array($Model->alias . '.*', $fields); @@ -2813,7 +2813,7 @@ protected function _parseKey($key, $value, Model $Model = null) { } if ($bound) { - return String::insert($key . ' ' . trim($operator), $value); + return CakeText::insert($key . ' ' . trim($operator), $value); } if (!preg_match($operatorMatch, trim($operator))) { diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index dee55cffdd0..dcb481093eb 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -20,7 +20,7 @@ App::uses('ClassRegistry', 'Utility'); App::uses('Validation', 'Utility'); -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); App::uses('Hash', 'Utility'); App::uses('BehaviorCollection', 'Model'); App::uses('ModelBehavior', 'Model'); @@ -1915,9 +1915,9 @@ protected function _doSave($data = null, $options = array()) { if (empty($this->data[$this->alias][$this->primaryKey]) && $this->_isUUIDField($this->primaryKey)) { if (array_key_exists($this->primaryKey, $this->data[$this->alias])) { $j = array_search($this->primaryKey, $fields); - $values[$j] = String::uuid(); + $values[$j] = CakeText::uuid(); } else { - list($fields[], $values[]) = array($this->primaryKey, String::uuid()); + list($fields[], $values[]) = array($this->primaryKey, CakeText::uuid()); } } @@ -2026,7 +2026,7 @@ protected function _saveMulti($joined, $id, $db) { $values = array($id, $row); if ($isUUID && $primaryAdded) { - $values[] = String::uuid(); + $values[] = CakeText::uuid(); } $newValues[$row] = $values; @@ -3187,7 +3187,7 @@ protected function _findList($state, $query, $results = array()) { $list = array("{n}.{$this->alias}.{$this->primaryKey}", "{n}.{$this->alias}.{$this->displayField}", null); } else { if (!is_array($query['fields'])) { - $query['fields'] = String::tokenize($query['fields']); + $query['fields'] = CakeText::tokenize($query['fields']); } if (count($query['fields']) === 1) { diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index ca7f8a97c52..23b9f9cdc0f 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -17,7 +17,7 @@ App::uses('Multibyte', 'I18n'); App::uses('AbstractTransport', 'Network/Email'); App::uses('File', 'Utility'); -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); App::uses('View', 'View'); /** @@ -776,7 +776,7 @@ public function getHeaders($include = array()) { } if ($this->_messageId !== false) { if ($this->_messageId === true) { - $headers['Message-ID'] = '<' . str_replace('-', '', String::UUID()) . '@' . $this->_domain . '>'; + $headers['Message-ID'] = '<' . str_replace('-', '', CakeText::UUID()) . '@' . $this->_domain . '>'; } else { $headers['Message-ID'] = $this->_messageId; } diff --git a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorUuidTest.php b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorUuidTest.php index b106abb88f0..ee031bebb12 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorUuidTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorUuidTest.php @@ -20,7 +20,7 @@ App::uses('Model', 'Model'); App::uses('AppModel', 'Model'); -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); require_once dirname(dirname(__FILE__)) . DS . 'models.php'; @@ -73,7 +73,7 @@ public function testAddWithPreSpecifiedId() { 'conditions' => array($modelClass . '.name' => '1.1') )); - $id = String::uuid(); + $id = CakeText::uuid(); $this->Tree->create(); $result = $this->Tree->save(array($modelClass => array( 'id' => $id, diff --git a/lib/Cake/Utility/Debugger.php b/lib/Cake/Utility/Debugger.php index d35ea1ffc95..69f0f8cea95 100644 --- a/lib/Cake/Utility/Debugger.php +++ b/lib/Cake/Utility/Debugger.php @@ -19,7 +19,7 @@ */ App::uses('CakeLog', 'Log'); -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); /** * Provide custom logging and error handling. @@ -337,7 +337,7 @@ public static function trace($options = array()) { $trace['path'] = self::trimPath($trace['file']); $trace['reference'] = $reference; unset($trace['object'], $trace['args']); - $back[] = String::insert($tpl, $trace, array('before' => '{:', 'after' => '}')); + $back[] = CakeText::insert($tpl, $trace, array('before' => '{:', 'after' => '}')); } } @@ -637,7 +637,7 @@ public static function outputAs($format = null) { * * `Debugger::addFormat('custom', $data);` * - * Where $data is an array of strings that use String::insert() variable + * Where $data is an array of strings that use CakeText::insert() variable * replacement. The template vars should be in a `{:id}` style. * An error formatter can have the following keys: * @@ -775,7 +775,7 @@ public function outputError($data) { if (isset($tpl['links'])) { foreach ($tpl['links'] as $key => $val) { - $links[$key] = String::insert($val, $data, $insertOpts); + $links[$key] = CakeText::insert($val, $data, $insertOpts); } } @@ -791,14 +791,14 @@ public function outputError($data) { if (is_array($value)) { $value = implode("\n", $value); } - $info .= String::insert($tpl[$key], array($key => $value) + $data, $insertOpts); + $info .= CakeText::insert($tpl[$key], array($key => $value) + $data, $insertOpts); } $links = implode(' ', $links); if (isset($tpl['callback']) && is_callable($tpl['callback'])) { return call_user_func($tpl['callback'], $data, compact('links', 'info')); } - echo String::insert($tpl['error'], compact('links', 'info') + $data, $insertOpts); + echo CakeText::insert($tpl['error'], compact('links', 'info') + $data, $insertOpts); } /** diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index c4639126307..7abe4515cfa 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -14,7 +14,7 @@ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); /** * Library of array functions for manipulating and extracting data @@ -112,7 +112,7 @@ public static function extract(array $data, $path) { if (strpos($path, '[') === false) { $tokens = explode('.', $path); } else { - $tokens = String::tokenize($path, '.', '[', ']'); + $tokens = CakeText::tokenize($path, '.', '[', ']'); } $_key = '__set_item__'; @@ -258,7 +258,7 @@ public static function insert(array $data, $path, $values = null) { if (strpos($path, '[') === false) { $tokens = explode('.', $path); } else { - $tokens = String::tokenize($path, '.', '[', ']'); + $tokens = CakeText::tokenize($path, '.', '[', ']'); } if (strpos($path, '{') === false && strpos($path, '[') === false) { @@ -341,7 +341,7 @@ public static function remove(array $data, $path) { if (strpos($path, '[') === false) { $tokens = explode('.', $path); } else { - $tokens = String::tokenize($path, '.', '[', ']'); + $tokens = CakeText::tokenize($path, '.', '[', ']'); } if (strpos($path, '{') === false && strpos($path, '[') === false) { diff --git a/lib/Cake/Utility/Security.php b/lib/Cake/Utility/Security.php index c2d21066478..51c43ace497 100644 --- a/lib/Cake/Utility/Security.php +++ b/lib/Cake/Utility/Security.php @@ -16,7 +16,7 @@ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); /** * Security Library contains utility methods related to security @@ -63,7 +63,7 @@ public static function inactiveMins() { * @return string Hash */ public static function generateAuthKey() { - return Security::hash(String::uuid()); + return Security::hash(CakeText::uuid()); } /** diff --git a/lib/Cake/Utility/Set.php b/lib/Cake/Utility/Set.php index 5d05e0c8b26..d52c8d7ad0b 100644 --- a/lib/Cake/Utility/Set.php +++ b/lib/Cake/Utility/Set.php @@ -16,7 +16,7 @@ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); App::uses('Hash', 'Utility'); /** @@ -549,7 +549,7 @@ public static function classicExtract($data, $path = null) { return null; } if (is_string($path) && strpos($path, '{') !== false) { - $path = String::tokenize($path, '.', '{', '}'); + $path = CakeText::tokenize($path, '.', '{', '}'); } elseif (is_string($path)) { $path = explode('.', $path); } diff --git a/lib/Cake/View/Helper/TextHelper.php b/lib/Cake/View/Helper/TextHelper.php index 05907c518bb..77d1595dcbd 100644 --- a/lib/Cake/View/Helper/TextHelper.php +++ b/lib/Cake/View/Helper/TextHelper.php @@ -225,7 +225,7 @@ public function autoLink($text, $options = array()) { * @param string $phrase The phrase that will be searched * @param array $options An array of html attributes and options. * @return string The highlighted text - * @see String::highlight() + * @see CakeText::highlight() * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::highlight */ public function highlight($text, $phrase, $options = array()) { @@ -260,7 +260,7 @@ public function autoParagraph($text) { * * @param string $text Text * @return string The text without links - * @see String::stripLinks() + * @see CakeText::stripLinks() * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::stripLinks */ public function stripLinks($text) { @@ -283,7 +283,7 @@ public function stripLinks($text) { * @param int $length Length of returned string, including ellipsis. * @param array $options An array of html attributes and options. * @return string Trimmed string. - * @see String::truncate() + * @see CakeText::truncate() * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::truncate */ public function truncate($text, $length = 100, $options = array()) { @@ -305,7 +305,7 @@ public function truncate($text, $length = 100, $options = array()) { * @param int $length Length of returned string, including ellipsis. * @param array $options An array of html attributes and options. * @return string Trimmed string. - * @see String::tail() + * @see CakeText::tail() * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::tail */ public function tail($text, $length = 100, $options = array()) { @@ -321,7 +321,7 @@ public function tail($text, $length = 100, $options = array()) { * @param int $radius The amount of characters that will be returned on each side of the founded phrase * @param string $ending Ending that will be appended * @return string Modified string - * @see String::excerpt() + * @see CakeText::excerpt() * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::excerpt */ public function excerpt($text, $phrase, $radius = 100, $ending = '...') { @@ -335,7 +335,7 @@ public function excerpt($text, $phrase, $radius = 100, $ending = '...') { * @param string $and The word used to join the last and second last items together with. Defaults to 'and'. * @param string $separator The separator used to join all the other items together. Defaults to ', '. * @return string The glued together string. - * @see String::toList() + * @see CakeText::toList() * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::toList */ public function toList($list, $and = null, $separator = ', ') { From 22b0275a58cadc7548f5904cf588e44b073eb0cd Mon Sep 17 00:00:00 2001 From: Istvan Pusztai Date: Mon, 5 Jan 2015 12:04:24 -0500 Subject: [PATCH 028/336] Prevent NULL value on NOT NULL column when value is an empty string (MySQL) --- .../Model/Datasource/Database/Sqlserver.php | 7 +++-- lib/Cake/Model/Datasource/DboSource.php | 13 +++++---- .../Datasource/Database/PostgresTest.php | 4 +-- .../Case/Model/Datasource/DboSourceTest.php | 29 +++++++++++++++++++ 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/lib/Cake/Model/Datasource/Database/Sqlserver.php b/lib/Cake/Model/Datasource/Database/Sqlserver.php index eb7dad8c086..c9cfdf2debc 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlserver.php +++ b/lib/Cake/Model/Datasource/Database/Sqlserver.php @@ -584,11 +584,12 @@ public function renderStatement($type, $data) { * * @param string $data String to be prepared for use in an SQL statement * @param string $column The column into which this data will be inserted + * @param bool $null Column allows NULL values * @return string Quoted and escaped data */ - public function value($data, $column = null) { + public function value($data, $column = null, $null = true) { if ($data === null || is_array($data) || is_object($data)) { - return parent::value($data, $column); + return parent::value($data, $column, $null); } if (in_array($data, array('{$__cakeID__$}', '{$__cakeForeignKey__$}'), true)) { return $data; @@ -603,7 +604,7 @@ public function value($data, $column = null) { case 'text': return 'N' . $this->_connection->quote($data, PDO::PARAM_STR); default: - return parent::value($data, $column); + return parent::value($data, $column, $null); } } diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index c18f3318a88..67277d3ff42 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -312,9 +312,10 @@ public function getVersion() { * * @param string $data String to be prepared for use in an SQL statement * @param string $column The column datatype into which this data will be inserted. + * @param bool $null Column allows NULL values * @return string Quoted and escaped data */ - public function value($data, $column = null) { + public function value($data, $column = null, $null = true) { if (is_array($data) && !empty($data)) { return array_map( array(&$this, 'value'), @@ -348,7 +349,7 @@ public function value($data, $column = null) { return $this->_connection->quote($data, PDO::PARAM_STR); default: if ($data === '') { - return 'NULL'; + return $null ? 'NULL' : '""'; } if (is_float($data)) { return str_replace(',', '.', strval($data)); @@ -994,7 +995,8 @@ public function create(Model $Model, $fields = null, $values = null) { $count = count($fields); for ($i = 0; $i < $count; $i++) { - $valueInsert[] = $this->value($values[$i], $Model->getColumnType($fields[$i])); + $schema = $Model->schema(); + $valueInsert[] = $this->value($values[$i], $Model->getColumnType($fields[$i]), isset($schema[$fields[$i]]) ? $schema[$fields[$i]]['null'] : true); $fieldInsert[] = $this->name($fields[$i]); if ($fields[$i] === $Model->primaryKey) { $id = $values[$i]; @@ -2061,6 +2063,7 @@ public function update(Model $Model, $fields = array(), $values = null, $conditi */ protected function _prepareUpdateFields(Model $Model, $fields, $quoteValues = true, $alias = false) { $quotedAlias = $this->startQuote . $Model->alias . $this->endQuote; + $schema = $Model->schema(); $updates = array(); foreach ($fields as $field => $value) { @@ -2081,7 +2084,7 @@ protected function _prepareUpdateFields(Model $Model, $fields, $quoteValues = tr $update = $quoted . ' = '; if ($quoteValues) { - $update .= $this->value($value, $Model->getColumnType($field)); + $update .= $this->value($value, $Model->getColumnType($field), isset($schema[$field]) ? $schema[$field]['null'] : true); } elseif ($Model->getColumnType($field) === 'boolean' && (is_int($value) || is_bool($value))) { $update .= $this->boolean($value, true); } elseif (!$alias) { @@ -3563,4 +3566,4 @@ public function __destruct() { } } -} +} \ No newline at end of file diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php index e41567150f3..6fa681e3105 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php @@ -318,8 +318,8 @@ public function testValueQuoting() { $this->assertEquals("0", $this->Dbo->value('0', 'integer')); $this->assertEquals('NULL', $this->Dbo->value('', 'integer')); $this->assertEquals('NULL', $this->Dbo->value('', 'float')); - $this->assertEquals("NULL", $this->Dbo->value('', 'integer', false)); - $this->assertEquals("NULL", $this->Dbo->value('', 'float', false)); + $this->assertEquals('""', $this->Dbo->value('', 'integer', false)); + $this->assertEquals('""', $this->Dbo->value('', 'float', false)); $this->assertEquals("'0.0'", $this->Dbo->value('0.0', 'float')); $this->assertEquals("'TRUE'", $this->Dbo->value('t', 'boolean')); diff --git a/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php b/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php index dff12ecc527..9b5bf1655a5 100644 --- a/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php @@ -784,6 +784,35 @@ public function testFetchAllBooleanReturns() { $this->assertTrue($result, 'Query did not return a boolean'); } +/** + * Test NOT NULL on ENUM data type with empty string as a value + * + * @return void + */ + public function testNotNullOnEnum() { + if (!$this->db instanceof Mysql) { + $this->markTestSkipped('This test can only run on MySQL'); + } + $name = $this->db->fullTableName('enum_tests'); + $query = "CREATE TABLE {$name} (mood ENUM('','happy','sad','ok') NOT NULL);"; + $result = $this->db->query($query); + $this->assertTrue($result); + + $EnumTest = ClassRegistry::init('EnumTest'); + $enumResult = $EnumTest->save(array('mood' => '')); + + $query = "DROP TABLE {$name};"; + $result = $this->db->query($query); + $this->assertTrue($result); + + $this->assertEquals(array( + 'EnumTest' => array( + 'mood' => '', + 'id' => '0' + ) + ), $enumResult); + } + /** * test order to generate query order clause for virtual fields * From 7b20884d43ff138f922367acb2e2b66ad8335dba Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 12 Jan 2015 21:36:28 -0500 Subject: [PATCH 029/336] Fix failing tests. --- lib/Cake/Test/Case/Utility/CakeTextTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Utility/CakeTextTest.php b/lib/Cake/Test/Case/Utility/CakeTextTest.php index ade7732764c..e130e2832ff 100644 --- a/lib/Cake/Test/Case/Utility/CakeTextTest.php +++ b/lib/Cake/Test/Case/Utility/CakeTextTest.php @@ -390,7 +390,7 @@ public function testWordWrapUnicodeAware() { public function testWordWrapNewlineAware() { $text = 'This is a line that is almost the 55 chars long. This is a new sentence which is manually newlined, but is so long it needs two lines.'; - $result = String::wordWrap($text, 55); + $result = CakeText::wordWrap($text, 55); $expected = << Date: Thu, 15 Jan 2015 11:00:27 +0100 Subject: [PATCH 030/336] Backport of https://github.com/cakephp/cakephp/issues/5667 --- lib/Cake/Model/Datasource/CakeSession.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index bfb16e298b1..3d5a3976287 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -442,7 +442,9 @@ public static function destroy() { self::_startSession(); } - session_destroy(); + if (self::started()) { + session_destroy(); + } $_SESSION = null; self::$id = null; From f621bb7fe5c6e648630ac615b4e90a08d290708f Mon Sep 17 00:00:00 2001 From: David Steinsland Date: Thu, 15 Jan 2015 19:20:28 +0100 Subject: [PATCH 031/336] Fixed nesting when ExceptionRenderer throws exception --- lib/Cake/Error/ErrorHandler.php | 13 +++++-- lib/Cake/Test/Case/Error/ErrorHandlerTest.php | 34 +++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index e87c636d1ce..18efed6cec4 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -125,6 +125,8 @@ public static function handleException(Exception $exception) { $e->getMessage(), $e->getTraceAsString() ); + + Configure::write('Exception.bail', true); trigger_error($message, E_USER_ERROR); } } @@ -249,10 +251,17 @@ public static function handleFatalError($code, $description, $file, $line) { } if (Configure::read('debug')) { - call_user_func($exceptionHandler, new FatalErrorException($description, 500, $file, $line)); + $exception = new FatalErrorException($description, 500, $file, $line); } else { - call_user_func($exceptionHandler, new InternalErrorException()); + $exception = new InternalErrorException(); + } + + if (Configure::read('Exception.bail')) { + throw $exception; } + + call_user_func($exceptionHandler, $exception); + return false; } diff --git a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php index 6ec656036bf..b2f87882dfc 100644 --- a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php +++ b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php @@ -20,6 +20,16 @@ App::uses('Controller', 'Controller'); App::uses('Router', 'Routing'); +/** + * A faulty ExceptionRenderer to test nesting. + */ +class FaultyExceptionRenderer extends ExceptionRenderer { + + public function render() { + throw new Exception('Error from renderer.'); + } +} + /** * ErrorHandlerTest class * @@ -320,4 +330,28 @@ public function testHandleFatalErrorLog() { $this->assertContains('[FatalErrorException] Something wrong', $log[1], 'message missing.'); } +/** + * testExceptionRendererNestingDebug method + * + * @expectedException FatalErrorException + * @return void + */ + public function testExceptionRendererNestingDebug() { + Configure::write('debug', 2); + Configure::write('Exception.renderer', 'FaultyExceptionRenderer'); + ErrorHandler::handleFatalError(E_USER_ERROR, 'Initial error', __FILE__ ,__LINE__); + } + +/** + * testExceptionRendererNestingProduction method + * + * @expectedException InternalErrorException + * @return void + */ + public function testExceptionRendererNestingProduction() { + Configure::write('debug', 0); + Configure::write('Exception.renderer', 'FaultyExceptionRenderer'); + ErrorHandler::handleFatalError(E_USER_ERROR, 'Initial error', __FILE__ ,__LINE__); + } + } From ed3b15f13b4b7e70c3d49d3aa05ce9a68a2ede4a Mon Sep 17 00:00:00 2001 From: David Steinsland Date: Thu, 15 Jan 2015 20:04:06 +0100 Subject: [PATCH 032/336] Fixed phpcs --- lib/Cake/Error/ErrorHandler.php | 2 ++ lib/Cake/Test/Case/Error/ErrorHandlerTest.php | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index 18efed6cec4..e7fe53da5c9 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -236,6 +236,8 @@ public static function handleError($code, $description, $file = null, $line = nu * @param string $file File on which error occurred * @param int $line Line that triggered the error * @return bool + * @throws FatalErrorException If the Exception renderer threw an exception during rendering, and debug > 0. + * @throws InternalErrorException If the Exception renderer threw an exception during rendering, and debug is 0. */ public static function handleFatalError($code, $description, $file, $line) { $logMessage = 'Fatal Error (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']'; diff --git a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php index b2f87882dfc..2db99959fb7 100644 --- a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php +++ b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php @@ -25,9 +25,16 @@ */ class FaultyExceptionRenderer extends ExceptionRenderer { +/** + * Dummy rendering implementation. + * + * @return void + * @throws Exception + */ public function render() { throw new Exception('Error from renderer.'); } + } /** @@ -339,7 +346,7 @@ public function testHandleFatalErrorLog() { public function testExceptionRendererNestingDebug() { Configure::write('debug', 2); Configure::write('Exception.renderer', 'FaultyExceptionRenderer'); - ErrorHandler::handleFatalError(E_USER_ERROR, 'Initial error', __FILE__ ,__LINE__); + ErrorHandler::handleFatalError(E_USER_ERROR, 'Initial error', __FILE__, __LINE__); } /** @@ -351,7 +358,7 @@ public function testExceptionRendererNestingDebug() { public function testExceptionRendererNestingProduction() { Configure::write('debug', 0); Configure::write('Exception.renderer', 'FaultyExceptionRenderer'); - ErrorHandler::handleFatalError(E_USER_ERROR, 'Initial error', __FILE__ ,__LINE__); + ErrorHandler::handleFatalError(E_USER_ERROR, 'Initial error', __FILE__, __LINE__); } } From e5134986e616a3bc137b97ba0b0424cbcd48c3ec Mon Sep 17 00:00:00 2001 From: David Steinsland Date: Thu, 15 Jan 2015 20:10:48 +0100 Subject: [PATCH 033/336] Reset Exception.bail just in case --- lib/Cake/Error/ErrorHandler.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index e7fe53da5c9..33a7e764e36 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -259,6 +259,7 @@ public static function handleFatalError($code, $description, $file, $line) { } if (Configure::read('Exception.bail')) { + Configure::write('Exception.bail', false); throw $exception; } From a5e1be7abfb3b45d3b588e99105c782ccd17a259 Mon Sep 17 00:00:00 2001 From: David Steinsland Date: Thu, 15 Jan 2015 23:11:36 +0100 Subject: [PATCH 034/336] Fixed tests --- lib/Cake/Test/Case/Error/ErrorHandlerTest.php | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php index 2db99959fb7..aa7448d6454 100644 --- a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php +++ b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php @@ -340,25 +340,45 @@ public function testHandleFatalErrorLog() { /** * testExceptionRendererNestingDebug method * - * @expectedException FatalErrorException * @return void */ public function testExceptionRendererNestingDebug() { Configure::write('debug', 2); Configure::write('Exception.renderer', 'FaultyExceptionRenderer'); - ErrorHandler::handleFatalError(E_USER_ERROR, 'Initial error', __FILE__, __LINE__); + + $result = false; + try { + ob_start(); + ob_start(); + ErrorHandler::handleFatalError(E_USER_ERROR, 'Initial error', __FILE__, __LINE__); + } catch (Exception $e) { + $result = $e instanceof FatalErrorException; + } + + restore_error_handler(); + $this->assertTrue($result); } /** * testExceptionRendererNestingProduction method * - * @expectedException InternalErrorException * @return void */ public function testExceptionRendererNestingProduction() { Configure::write('debug', 0); Configure::write('Exception.renderer', 'FaultyExceptionRenderer'); - ErrorHandler::handleFatalError(E_USER_ERROR, 'Initial error', __FILE__, __LINE__); + + $result = false; + try { + ob_start(); + ob_start(); + ErrorHandler::handleFatalError(E_USER_ERROR, 'Initial error', __FILE__, __LINE__); + } catch (Exception $e) { + $result = $e instanceof InternalErrorException; + } + + restore_error_handler(); + $this->assertTrue($result); } } From 2b1e487530aac1efa71f1cb60d988c935eb58b90 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Thu, 15 Jan 2015 23:39:09 +0100 Subject: [PATCH 035/336] Correct CakeSocket docblocks. --- lib/Cake/Network/CakeSocket.php | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/Cake/Network/CakeSocket.php b/lib/Cake/Network/CakeSocket.php index 55c45998148..d428a74cb64 100644 --- a/lib/Cake/Network/CakeSocket.php +++ b/lib/Cake/Network/CakeSocket.php @@ -119,7 +119,7 @@ public function __construct($config = array()) { } /** - * Connect the socket to the given host and port. + * Connects the socket to the given host and port. * * @return bool Success * @throws SocketException @@ -188,7 +188,7 @@ protected function _connectionErrorHandler($code, $message) { } /** - * Get the connection context. + * Gets the connection context. * * @return null|array Null when there is no connection, an array when there is. */ @@ -200,7 +200,7 @@ public function context() { } /** - * Get the host name of the current connection. + * Gets the host name of the current connection. * * @return string Host name */ @@ -212,7 +212,7 @@ public function host() { } /** - * Get the IP address of the current connection. + * Gets the IP address of the current connection. * * @return string IP address */ @@ -224,7 +224,7 @@ public function address() { } /** - * Get all IP addresses associated with the current connection. + * Gets all IP addresses associated with the current connection. * * @return array IP addresses */ @@ -236,7 +236,7 @@ public function addresses() { } /** - * Get the last error as a string. + * Gets the last error as a string. * * @return string|null Last error */ @@ -248,7 +248,7 @@ public function lastError() { } /** - * Set the last error. + * Sets the last error. * * @param int $errNum Error code * @param string $errStr Error string @@ -259,7 +259,7 @@ public function setLastError($errNum, $errStr) { } /** - * Write data to the socket. + * Writes data to the socket. * * @param string $data The data to write to the socket * @return bool Success @@ -281,7 +281,7 @@ public function write($data) { } /** - * Read data from the socket. Returns false if no data is available or no connection could be + * Reads data from the socket. Returns false if no data is available or no connection could be * established. * * @param int $length Optional buffer length to read; defaults to 1024 @@ -307,7 +307,7 @@ public function read($length = 1024) { } /** - * Disconnect the socket from the current connection. + * Disconnects the socket from the current connection. * * @return bool Success */ @@ -353,14 +353,14 @@ public function reset($state = null) { } /** - * Encrypts current stream socket, using one of the defined encryption methods + * Encrypts current stream socket, using one of the defined encryption methods. * - * @param string $type can be one of 'ssl2', 'ssl3', 'ssl23' or 'tls' - * @param string $clientOrServer can be one of 'client', 'server'. Default is 'client' - * @param bool $enable enable or disable encryption. Default is true (enable) + * @param string $type Type which can be one of 'sslv2', 'sslv3', 'sslv23' or 'tls'. + * @param string $clientOrServer Can be one of 'client', 'server'. Default is 'client'. + * @param bool $enable Enable or disable encryption. Default is true (enable) * @return bool True on success * @throws InvalidArgumentException When an invalid encryption scheme is chosen. - * @throws SocketException When attempting to enable SSL/TLS fails + * @throws SocketException When attempting to enable SSL/TLS fails. * @see stream_socket_enable_crypto */ public function enableCrypto($type, $clientOrServer = 'client', $enable = true) { @@ -369,7 +369,8 @@ public function enableCrypto($type, $clientOrServer = 'client', $enable = true) } $enableCryptoResult = false; try { - $enableCryptoResult = stream_socket_enable_crypto($this->connection, $enable, $this->_encryptMethods[$type . '_' . $clientOrServer]); + $enableCryptoResult = stream_socket_enable_crypto($this->connection, $enable, + $this->_encryptMethods[$type . '_' . $clientOrServer]); } catch (Exception $e) { $this->setLastError(null, $e->getMessage()); throw new SocketException($e->getMessage()); From d4a6d3f6c0da784f4a6c927b2b718c6d844ba683 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 14 Jan 2015 22:18:13 -0500 Subject: [PATCH 036/336] Fix numeric values not being quoted for MySQL set columns. Set columns should always have their values quoted. Not quoting values makes MySQL do bad things. Refs #5649 --- lib/Cake/Model/Datasource/Database/Mysql.php | 11 ++++++++++ lib/Cake/Model/Datasource/DboSource.php | 6 ++++-- .../Model/Datasource/Database/MysqlTest.php | 21 +++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index a18706078f5..63fda04ab44 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -795,6 +795,17 @@ public function column($real) { return 'text'; } +/** + * {@inheritDoc} + */ + public function value($data, $column = null) { + $value = parent::value($data, $column); + if (is_numeric($value) && substr($column, 0, 3) === 'set') { + return $this->_connection->quote($value); + } + return $value; + } + /** * Gets the schema name * diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index c18f3318a88..b94d9eb6cd6 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -354,8 +354,10 @@ public function value($data, $column = null) { return str_replace(',', '.', strval($data)); } if ((is_int($data) || $data === '0') || ( - is_numeric($data) && strpos($data, ',') === false && - $data[0] != '0' && strpos($data, 'e') === false) + is_numeric($data) && + strpos($data, ',') === false && + $data[0] != '0' && + strpos($data, 'e') === false) ) { return $data; } diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index 994ad75e1a4..6c52c06d34c 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -553,6 +553,10 @@ public function testColumn() { $result = $this->Dbo->column('decimal(14,7) unsigned'); $expected = 'decimal'; $this->assertEquals($expected, $result); + + $result = $this->Dbo->column("set('a','b','c')"); + $expected = "set('a','b','c')"; + $this->assertEquals($expected, $result); } /** @@ -4071,4 +4075,21 @@ public function testNestedTransaction() { $this->Dbo->useNestedTransactions = $nested; } +/** + * Test that value() quotes set values even when numeric. + * + * @return void + */ + public function testSetValue() { + $column = "set('a','b','c')"; + $result = $this->Dbo->value('1', $column); + $this->assertEquals("'1'", $result); + + $result = $this->Dbo->value(1, $column); + $this->assertEquals("'1'", $result); + + $result = $this->Dbo->value('a', $column); + $this->assertEquals("'a'", $result); + } + } From 396d501d1e70da79494bba21161d66f0aede8852 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 15 Jan 2015 21:16:15 -0500 Subject: [PATCH 037/336] Fix / being handled incorrect by referer() Backport changes in #4987 to 2.x. This solves issues with duplicate base directories when redirecting back to '/' Fixes #4812 --- lib/Cake/Controller/Controller.php | 2 +- .../Test/Case/Controller/ControllerTest.php | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index 6005a1dc25c..74b65e7b66c 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -974,7 +974,7 @@ public function referer($default = null, $local = false) { } $referer = $this->request->referer($local); - if ($referer === '/' && $default) { + if ($referer === '/' && $default && $default !== $referer) { return Router::url($default, !$local); } return $referer; diff --git a/lib/Cake/Test/Case/Controller/ControllerTest.php b/lib/Cake/Test/Case/Controller/ControllerTest.php index d713e0d8078..eae1e49b754 100644 --- a/lib/Cake/Test/Case/Controller/ControllerTest.php +++ b/lib/Cake/Test/Case/Controller/ControllerTest.php @@ -1031,6 +1031,30 @@ public function testReferer() { $this->assertEquals('/', $result); } +/** + * Test that the referer is not absolute if it is '/'. + * + * This avoids the base path being applied twice on string urls. + * + * @return void + */ + public function testRefererSlash() { + $request = $this->getMock('CakeRequest', array('referer')); + $request->base = '/base'; + $request->expects($this->any()) + ->method('referer') + ->will($this->returnValue('/')); + Router::setRequestInfo($request); + + $controller = new Controller($request); + $result = $controller->referer('/', true); + $this->assertEquals('/', $result); + + $controller = new Controller($request); + $result = $controller->referer('/some/path', true); + $this->assertEquals('/base/some/path', $result); + } + /** * testSetAction method * From 09e5e43d0950bcee1b1792bc1355492024a5e54c Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 15 Jan 2015 21:36:35 -0500 Subject: [PATCH 038/336] Update version number to 2.6.1 --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index 94e1bce93fa..8ede76ab154 100644 --- a/lib/Cake/VERSION.txt +++ b/lib/Cake/VERSION.txt @@ -17,4 +17,4 @@ // @license http://www.opensource.org/licenses/mit-license.php MIT License // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -2.6.0 +2.6.1 From 8a918780334b47c48c7c7cf4ea4d162e71aba129 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 15 Jan 2015 21:59:23 -0500 Subject: [PATCH 039/336] We can't depend on PHPUnit anymore as it doesn't exist in pear form --- build.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/build.xml b/build.xml index 42ed084bdef..786916b99d4 100644 --- a/build.xml +++ b/build.xml @@ -136,7 +136,6 @@ - script php From d37721ab0e0a471af0b3e9fbbcf2ae7b8251d453 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Fri, 16 Jan 2015 14:11:32 +0100 Subject: [PATCH 040/336] Fix notice in PaginatorHelper when model params are not available. --- lib/Cake/View/Helper/PaginatorHelper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/View/Helper/PaginatorHelper.php b/lib/Cake/View/Helper/PaginatorHelper.php index f5550b27ff8..f79e09e7ed2 100644 --- a/lib/Cake/View/Helper/PaginatorHelper.php +++ b/lib/Cake/View/Helper/PaginatorHelper.php @@ -706,7 +706,7 @@ public function counter($options = array()) { * - `currentClass` Class for wrapper tag on current active page, defaults to 'current' * - `currentTag` Tag to use for current page number, defaults to null * - * @param array $options Options for the numbers, (before, after, model, modulus, separator) + * @param array|bool $options Options for the numbers, (before, after, model, modulus, separator) * @return string Numbers string. * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::numbers */ @@ -727,7 +727,7 @@ public function numbers($options = array()) { $params = (array)$this->params($options['model']) + array('page' => 1); unset($options['model']); - if ($params['pageCount'] <= 1) { + if (empty($params['pageCount']) || $params['pageCount'] <= 1) { return ''; } From e37db25ce0ece51a63a76a26ef08ad6781ca88dc Mon Sep 17 00:00:00 2001 From: David Steinsland Date: Fri, 16 Jan 2015 14:47:44 +0100 Subject: [PATCH 041/336] Change configuration property to static class property --- lib/Cake/Error/ErrorHandler.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index 33a7e764e36..e89574a85c8 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -95,6 +95,14 @@ */ class ErrorHandler { +/** + * Whether to give up rendering an exception, if the renderer itself is + * throwing exceptions. + * + * @var bool + */ + protected static $_bailExceptionRendering = false; + /** * Set as the default exception handler by the CakePHP bootstrap process. * @@ -126,7 +134,7 @@ public static function handleException(Exception $exception) { $e->getTraceAsString() ); - Configure::write('Exception.bail', true); + static::$_bailExceptionRendering = true; trigger_error($message, E_USER_ERROR); } } @@ -258,8 +266,8 @@ public static function handleFatalError($code, $description, $file, $line) { $exception = new InternalErrorException(); } - if (Configure::read('Exception.bail')) { - Configure::write('Exception.bail', false); + if (static::$_bailExceptionRendering) { + static::$_bailExceptionRendering = false; throw $exception; } From e5d1846d4b59e1ebd960ddeca600d17b6cb091d0 Mon Sep 17 00:00:00 2001 From: David Steinsland Date: Fri, 16 Jan 2015 16:02:44 +0100 Subject: [PATCH 042/336] Fixed PHP 5.2 compatibility --- lib/Cake/Error/ErrorHandler.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index e89574a85c8..5ecba0960f2 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -134,7 +134,7 @@ public static function handleException(Exception $exception) { $e->getTraceAsString() ); - static::$_bailExceptionRendering = true; + self::$_bailExceptionRendering = true; trigger_error($message, E_USER_ERROR); } } @@ -266,8 +266,8 @@ public static function handleFatalError($code, $description, $file, $line) { $exception = new InternalErrorException(); } - if (static::$_bailExceptionRendering) { - static::$_bailExceptionRendering = false; + if (self::$_bailExceptionRendering) { + self::$_bailExceptionRendering = false; throw $exception; } From dedb2e4191f7ed8b9104953d2a1801308029a3c7 Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 16 Jan 2015 14:30:28 +0100 Subject: [PATCH 043/336] Added short plugin alias in shells --- lib/Cake/Console/ShellDispatcher.php | 5 +++ .../Test/Case/Console/ShellDispatcherTest.php | 8 +++++ .../Console/Command/TestPluginShell.php | 33 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 lib/Cake/Test/test_app/Plugin/TestPlugin/Console/Command/TestPluginShell.php diff --git a/lib/Cake/Console/ShellDispatcher.php b/lib/Cake/Console/ShellDispatcher.php index 30f37aa0978..a385dc12be0 100644 --- a/lib/Cake/Console/ShellDispatcher.php +++ b/lib/Cake/Console/ShellDispatcher.php @@ -246,6 +246,11 @@ protected function _getShell($shell) { App::uses('AppShell', 'Console/Command'); App::uses($class, $plugin . 'Console/Command'); + if (!class_exists($class)) { + $plugin = Inflector::camelize($shell) . '.'; + App::uses($class, $plugin . 'Console/Command'); + } + if (!class_exists($class)) { throw new MissingShellException(array( 'class' => $class diff --git a/lib/Cake/Test/Case/Console/ShellDispatcherTest.php b/lib/Cake/Test/Case/Console/ShellDispatcherTest.php index 2d3aa5bf59a..20473db635e 100644 --- a/lib/Cake/Test/Case/Console/ShellDispatcherTest.php +++ b/lib/Cake/Test/Case/Console/ShellDispatcherTest.php @@ -427,6 +427,14 @@ public function testGetShell() { $Dispatcher = new TestShellDispatcher(); $result = $Dispatcher->getShell('TestPlugin.example'); $this->assertInstanceOf('ExampleShell', $result); + + $Dispatcher = new TestShellDispatcher(); + $result = $Dispatcher->getShell('test_plugin'); + $this->assertInstanceOf('TestPluginShell', $result); + + $Dispatcher = new TestShellDispatcher(); + $result = $Dispatcher->getShell('TestPlugin'); + $this->assertInstanceOf('TestPluginShell', $result); } /** diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Console/Command/TestPluginShell.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Console/Command/TestPluginShell.php new file mode 100644 index 00000000000..30ce333c5cd --- /dev/null +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Console/Command/TestPluginShell.php @@ -0,0 +1,33 @@ + + * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * For full copyright and license information, please see the LICENSE.txt + * Redistributions of files must retain the above copyright notice + * + * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests + * @package Cake.Test.TestApp.Plugin.TestPlugin.Console.Command + * @since CakePHP(tm) v 1.2.0.7871 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ + +/** + * Class TestPluginShell + * @package Cake.Test.TestApp.Plugin.TestPlugin.Console.Command + */ +class TestPluginShell extends Shell { + +/** + * main method + * + * @return void + */ + public function main() { + $this->out('This is the main method called from TestPlugin.TestPluginShell'); + } +} From f4933b29a89252b9da853aeaea0df470425157a4 Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 16 Jan 2015 14:38:00 +0100 Subject: [PATCH 044/336] CS fix --- lib/Cake/Console/ShellDispatcher.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Console/ShellDispatcher.php b/lib/Cake/Console/ShellDispatcher.php index a385dc12be0..08df249400a 100644 --- a/lib/Cake/Console/ShellDispatcher.php +++ b/lib/Cake/Console/ShellDispatcher.php @@ -247,9 +247,9 @@ protected function _getShell($shell) { App::uses($class, $plugin . 'Console/Command'); if (!class_exists($class)) { - $plugin = Inflector::camelize($shell) . '.'; - App::uses($class, $plugin . 'Console/Command'); - } + $plugin = Inflector::camelize($shell) . '.'; + App::uses($class, $plugin . 'Console/Command'); + } if (!class_exists($class)) { throw new MissingShellException(array( From db1442573dba65a29cd230d0b9eeddd223e7e37c Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 16 Jan 2015 15:07:08 +0100 Subject: [PATCH 045/336] Fix failing tests --- lib/Cake/Test/Case/Console/Command/CompletionShellTest.php | 2 +- lib/Cake/Test/Case/Console/Command/Task/CommandTaskTest.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Test/Case/Console/Command/CompletionShellTest.php b/lib/Cake/Test/Case/Console/Command/CompletionShellTest.php index 7ef3ef53a01..b28db0c65cd 100644 --- a/lib/Cake/Test/Case/Console/Command/CompletionShellTest.php +++ b/lib/Cake/Test/Case/Console/Command/CompletionShellTest.php @@ -125,7 +125,7 @@ public function testCommands() { $this->Shell->runCommand('commands', array()); $output = $this->Shell->stdout->output; - $expected = "TestPlugin.example TestPluginTwo.example TestPluginTwo.welcome acl api bake command_list completion console i18n schema server test testsuite upgrade sample\n"; + $expected = "TestPlugin.example TestPlugin.test_plugin TestPluginTwo.example TestPluginTwo.welcome acl api bake command_list completion console i18n schema server test testsuite upgrade sample\n"; $this->assertEquals($expected, $output); } diff --git a/lib/Cake/Test/Case/Console/Command/Task/CommandTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/CommandTaskTest.php index 6a129325913..1aa91ffd72e 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/CommandTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/CommandTaskTest.php @@ -85,9 +85,10 @@ public function testGetShellList() { 'upgrade' ), 'TestPlugin' => array( - 'example' + 'example', + 'test_plugin' ), - 'TestPluginTwo' => array( + 'TestPluginTwo' => array( 'example', 'welcome' ), @@ -108,6 +109,7 @@ public function testCommands() { $expected = array( 'TestPlugin.example', + 'TestPlugin.test_plugin', 'TestPluginTwo.example', 'TestPluginTwo.welcome', 'acl', From c755d9b5e5e220558c3d020578be02d9ace92e68 Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 19 Jan 2015 08:55:40 +0100 Subject: [PATCH 046/336] Updated comments --- .../Plugin/TestPlugin/Console/Command/TestPluginShell.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Console/Command/TestPluginShell.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Console/Command/TestPluginShell.php index 30ce333c5cd..b756c643a1b 100644 --- a/lib/Cake/Test/test_app/Plugin/TestPlugin/Console/Command/TestPluginShell.php +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Console/Command/TestPluginShell.php @@ -1,7 +1,5 @@ * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) * @@ -12,7 +10,7 @@ * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests * @package Cake.Test.TestApp.Plugin.TestPlugin.Console.Command - * @since CakePHP(tm) v 1.2.0.7871 + * @since CakePHP(tm) v 2.7.0 * @license http://www.opensource.org/licenses/mit-license.php MIT License */ From 511ee1f776774c105d4f9ba8fde9de85d19788d6 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 19 Jan 2015 21:43:14 -0500 Subject: [PATCH 047/336] Fix strict error with 2.6 code. --- lib/Cake/Model/Datasource/Database/Mysql.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index 63fda04ab44..6a6828e2f99 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -798,8 +798,8 @@ public function column($real) { /** * {@inheritDoc} */ - public function value($data, $column = null) { - $value = parent::value($data, $column); + public function value($data, $column = null, $null = true) { + $value = parent::value($data, $column, $null); if (is_numeric($value) && substr($column, 0, 3) === 'set') { return $this->_connection->quote($value); } From a7d604bca8421211bc4f72d1e5dedffa6aa90a42 Mon Sep 17 00:00:00 2001 From: Richan Fongdasen Date: Wed, 21 Jan 2015 13:47:03 +0700 Subject: [PATCH 048/336] Add mobile agent for Blackberry Z10 and Blackberry Z30, fixes #5706 --- lib/Cake/Network/CakeRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 5e9932069e8..678937ca9f6 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -109,7 +109,7 @@ class CakeRequest implements ArrayAccess { 'Android', 'AvantGo', 'BlackBerry', 'DoCoMo', 'Fennec', 'iPod', 'iPhone', 'iPad', 'J2ME', 'MIDP', 'NetFront', 'Nokia', 'Opera Mini', 'Opera Mobi', 'PalmOS', 'PalmSource', 'portalmmm', 'Plucker', 'ReqwirelessWeb', 'SonyEricsson', 'Symbian', 'UP\\.Browser', - 'webOS', 'Windows CE', 'Windows Phone OS', 'Xiino' + 'webOS', 'Windows CE', 'Windows Phone OS', 'Xiino', 'BB10' )), 'requested' => array('param' => 'requested', 'value' => 1) ); From 2c251b80afb2db8411ba947faebba7a95dbe116d Mon Sep 17 00:00:00 2001 From: cake17 Date: Wed, 21 Jan 2015 16:41:34 +0100 Subject: [PATCH 049/336] put message in cake.pot file instead of default.pot --- lib/Cake/View/ViewBlock.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/View/ViewBlock.php b/lib/Cake/View/ViewBlock.php index f45119db7a4..cdcd5b837b4 100644 --- a/lib/Cake/View/ViewBlock.php +++ b/lib/Cake/View/ViewBlock.php @@ -75,7 +75,7 @@ class ViewBlock { */ public function start($name) { if (in_array($name, $this->_active)) { - throw new CakeException(__("A view block with the name '%s' is already/still open.", $name)); + throw new CakeException(__d('cake', "A view block with the name '%s' is already/still open.", $name)); } $this->_active[] = $name; ob_start(); From fd47d26f6bce090621d717f8a9e866b39d211837 Mon Sep 17 00:00:00 2001 From: Richan Fongdasen Date: Wed, 21 Jan 2015 22:50:46 +0700 Subject: [PATCH 050/336] Keep the user agent list in alphabetical order --- lib/Cake/Network/CakeRequest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 678937ca9f6..d46dbce9cae 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -106,10 +106,10 @@ class CakeRequest implements ArrayAccess { 'ajax' => array('env' => 'HTTP_X_REQUESTED_WITH', 'value' => 'XMLHttpRequest'), 'flash' => array('env' => 'HTTP_USER_AGENT', 'pattern' => '/^(Shockwave|Adobe) Flash/'), 'mobile' => array('env' => 'HTTP_USER_AGENT', 'options' => array( - 'Android', 'AvantGo', 'BlackBerry', 'DoCoMo', 'Fennec', 'iPod', 'iPhone', 'iPad', + 'Android', 'AvantGo', 'BB10', 'BlackBerry', 'DoCoMo', 'Fennec', 'iPod', 'iPhone', 'iPad', 'J2ME', 'MIDP', 'NetFront', 'Nokia', 'Opera Mini', 'Opera Mobi', 'PalmOS', 'PalmSource', 'portalmmm', 'Plucker', 'ReqwirelessWeb', 'SonyEricsson', 'Symbian', 'UP\\.Browser', - 'webOS', 'Windows CE', 'Windows Phone OS', 'Xiino', 'BB10' + 'webOS', 'Windows CE', 'Windows Phone OS', 'Xiino' )), 'requested' => array('param' => 'requested', 'value' => 1) ); From 9ce75e6fd63f3ce17be80ad7a2d31127e1ffc86b Mon Sep 17 00:00:00 2001 From: Ceeram Date: Wed, 21 Jan 2015 23:04:29 +0100 Subject: [PATCH 051/336] No need to get the datasource if column is defined in schema. Fixes #5712 --- lib/Cake/Model/Model.php | 6 +++- .../Test/Case/Model/ModelIntegrationTest.php | 13 ++++++++ lib/Cake/Test/Case/Model/models.php | 31 +++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 6a794b09a90..72d4361b73a 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -1428,8 +1428,12 @@ public function getColumnTypes() { * @return string Column type */ public function getColumnType($column) { - $db = $this->getDataSource(); $cols = $this->schema(); + if (isset($cols[$column]) && isset($cols[$column]['type'])) { + return $cols[$column]['type']; + } + + $db = $this->getDataSource(); $model = null; $startQuote = isset($db->startQuote) ? $db->startQuote : null; diff --git a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php index 839af667183..8f941b05921 100644 --- a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php +++ b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php @@ -2497,4 +2497,17 @@ public function testSchemaNoDB() { $model->expects($this->never())->method('getDataSource'); $this->assertEmpty($model->schema()); } + +/** + * Tests that calling getColumnType() on a model that is not supposed to use a table + * does not trigger any calls on any datasource + * + * @return void + */ + public function testGetColumnTypeNoDB() { + $model = $this->getMock('Example', array('getDataSource')); + $model->expects($this->never())->method('getDataSource'); + $result = $model->getColumnType('filefield'); + $this->assertEquals('string', $result); + } } diff --git a/lib/Cake/Test/Case/Model/models.php b/lib/Cake/Test/Case/Model/models.php index a4ce60c91d2..de578d21879 100644 --- a/lib/Cake/Test/Case/Model/models.php +++ b/lib/Cake/Test/Case/Model/models.php @@ -5048,3 +5048,34 @@ public function beforeValidate($options = array()) { } } + +/** + * Example class + * + * @package Cake.Test.Case.Model + */ +class Example extends AppModel { + +/** + * useTable property + * + * @var string + */ + public $useTable = false; + +/** + * schema property + * + * @var array + */ + protected $_schema = array( + 'filefield' => array( + 'type' => 'string', + 'length' => 254, + 'default' => null, + 'null' => true, + 'comment' => null + ), + ); + +} From 58334996a2af3f23bd4512766c886a87d1dfaf06 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 21 Jan 2015 23:32:08 -0500 Subject: [PATCH 052/336] Fix PHPCS errors. --- lib/Cake/Test/Case/Model/models.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Test/Case/Model/models.php b/lib/Cake/Test/Case/Model/models.php index de578d21879..ced7a56b367 100644 --- a/lib/Cake/Test/Case/Model/models.php +++ b/lib/Cake/Test/Case/Model/models.php @@ -5070,10 +5070,10 @@ class Example extends AppModel { */ protected $_schema = array( 'filefield' => array( - 'type' => 'string', - 'length' => 254, + 'type' => 'string', + 'length' => 254, 'default' => null, - 'null' => true, + 'null' => true, 'comment' => null ), ); From e86365ca0ffba680d5aefce6098baa35752b9681 Mon Sep 17 00:00:00 2001 From: AD7six Date: Thu, 22 Jan 2015 10:59:33 +0000 Subject: [PATCH 053/336] Add a failing test for session concurrency problems --- .../Session/DatabaseSessionTest.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php b/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php index b39a325169b..440b5226368 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php @@ -191,4 +191,34 @@ public function testGc() { $storage->gc(); $this->assertFalse($storage->read('foo')); } + +/** + * testConcurrentInsert + * + * @return void + */ + public function testConcurrentInsert() { + ClassRegistry::removeObject('Session'); + + $mockedModel = $this->getMockForModel( + 'SessionTestModel', + array('exists'), + array('alias' => 'MockedSessionTestModel', 'table' => 'sessions') + ); + Configure::write('Session.handler.model', 'MockedSessionTestModel'); + + $mockedModel->expects($this->any()) + ->method('exists') + ->will($this->returnValue(false)); + + $this->storage = new DatabaseSession(); + + $this->storage->write('foo', 'Some value'); + $return = $this->storage->read('foo'); + $this->assertSame('Some value', $return); + + $this->storage->write('foo', 'Some other value'); + $return = $this->storage->read('foo'); + $this->assertSame('Some other value', $return); + } } From 51bd1d0a2b2d8e6086ec2324ed9c332c9e467a89 Mon Sep 17 00:00:00 2001 From: AD7six Date: Fri, 23 Jan 2015 08:28:08 +0000 Subject: [PATCH 054/336] If a PDOException is thrown, try again. This can occur if the exists check returns no rows, but before this request inserts into the database a _different_ thread inserts a session record. --- .../Datasource/Session/DatabaseSession.php | 10 +++++- .../Session/DatabaseSessionTest.php | 34 ++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Model/Datasource/Session/DatabaseSession.php b/lib/Cake/Model/Datasource/Session/DatabaseSession.php index 4a1193beaf5..932a5f5fc4b 100644 --- a/lib/Cake/Model/Datasource/Session/DatabaseSession.php +++ b/lib/Cake/Model/Datasource/Session/DatabaseSession.php @@ -103,6 +103,9 @@ public function read($id) { /** * Helper function called on write for database sessions. * + * Will retry, once, if the save triggers a PDOException which + * can happen if a race condition is encountered + * * @param int $id ID that uniquely identifies session in database * @param mixed $data The value of the data to be saved. * @return bool True for successful write, false otherwise. @@ -114,7 +117,12 @@ public function write($id, $data) { $expires = time() + $this->_timeout; $record = compact('id', 'data', 'expires'); $record[$this->_model->primaryKey] = $id; - return $this->_model->save($record); + + try { + return $this->_model->save($record); + } catch (PDOException $e) { + return $this->_model->save($record); + } } /** diff --git a/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php b/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php index 440b5226368..84ea546ee1c 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php @@ -207,10 +207,42 @@ public function testConcurrentInsert() { ); Configure::write('Session.handler.model', 'MockedSessionTestModel'); - $mockedModel->expects($this->any()) + $counter = 0; + // First save + $mockedModel->expects($this->at($counter++)) ->method('exists') ->will($this->returnValue(false)); + // First validate + $mockedModel->expects($this->at($counter++)) + ->method('exists') + ->will($this->returnValue(false)); + + // Second save + $mockedModel->expects($this->at($counter++)) + ->method('exists') + ->will($this->returnValue(false)); + + // Second validate + $mockedModel->expects($this->at($counter++)) + ->method('exists') + ->will($this->returnValue(false)); + + // Second save retry + $mockedModel->expects($this->at($counter++)) + ->method('exists') + ->will($this->returnValue(true)); + + // Second validate retry + $mockedModel->expects($this->at($counter++)) + ->method('exists') + ->will($this->returnValue(false)); + + // Datasource exists check + $mockedModel->expects($this->at($counter++)) + ->method('exists') + ->will($this->returnValue(true)); + $this->storage = new DatabaseSession(); $this->storage->write('foo', 'Some value'); From 838d23300b03df066adb80462a95b4239947da09 Mon Sep 17 00:00:00 2001 From: AD7six Date: Fri, 23 Jan 2015 08:29:59 +0000 Subject: [PATCH 055/336] Remove some exists checks by not validating --- .../Model/Datasource/Session/DatabaseSession.php | 4 ++-- .../Datasource/Session/DatabaseSessionTest.php | 15 --------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/lib/Cake/Model/Datasource/Session/DatabaseSession.php b/lib/Cake/Model/Datasource/Session/DatabaseSession.php index 932a5f5fc4b..ff369623621 100644 --- a/lib/Cake/Model/Datasource/Session/DatabaseSession.php +++ b/lib/Cake/Model/Datasource/Session/DatabaseSession.php @@ -119,9 +119,9 @@ public function write($id, $data) { $record[$this->_model->primaryKey] = $id; try { - return $this->_model->save($record); + return $this->_model->save($record, array('validate' => false)); } catch (PDOException $e) { - return $this->_model->save($record); + return $this->_model->save($record, array('validate' => false)); } } diff --git a/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php b/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php index 84ea546ee1c..a0c6b30a3b9 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php @@ -213,31 +213,16 @@ public function testConcurrentInsert() { ->method('exists') ->will($this->returnValue(false)); - // First validate - $mockedModel->expects($this->at($counter++)) - ->method('exists') - ->will($this->returnValue(false)); - // Second save $mockedModel->expects($this->at($counter++)) ->method('exists') ->will($this->returnValue(false)); - // Second validate - $mockedModel->expects($this->at($counter++)) - ->method('exists') - ->will($this->returnValue(false)); - // Second save retry $mockedModel->expects($this->at($counter++)) ->method('exists') ->will($this->returnValue(true)); - // Second validate retry - $mockedModel->expects($this->at($counter++)) - ->method('exists') - ->will($this->returnValue(false)); - // Datasource exists check $mockedModel->expects($this->at($counter++)) ->method('exists') From c0ee49fe88c44f582ed7a906b165e8aab82dfad9 Mon Sep 17 00:00:00 2001 From: AD7six Date: Fri, 23 Jan 2015 08:30:26 +0000 Subject: [PATCH 056/336] Remove callbacks to speed up saving --- lib/Cake/Model/Datasource/Session/DatabaseSession.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Model/Datasource/Session/DatabaseSession.php b/lib/Cake/Model/Datasource/Session/DatabaseSession.php index ff369623621..e59a4a152d8 100644 --- a/lib/Cake/Model/Datasource/Session/DatabaseSession.php +++ b/lib/Cake/Model/Datasource/Session/DatabaseSession.php @@ -118,10 +118,11 @@ public function write($id, $data) { $record = compact('id', 'data', 'expires'); $record[$this->_model->primaryKey] = $id; + $options = array('validate' => false, 'callbacks' => false); try { - return $this->_model->save($record, array('validate' => false)); + return $this->_model->save($record, $options); } catch (PDOException $e) { - return $this->_model->save($record, array('validate' => false)); + return $this->_model->save($record, $options); } } From 5e89e893f24a63883a58a97f3f0b476c93fc3f94 Mon Sep 17 00:00:00 2001 From: AD7six Date: Thu, 22 Jan 2015 22:57:24 +0000 Subject: [PATCH 057/336] Ignore counter cache also --- lib/Cake/Model/Datasource/Session/DatabaseSession.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Model/Datasource/Session/DatabaseSession.php b/lib/Cake/Model/Datasource/Session/DatabaseSession.php index e59a4a152d8..08c398a7a37 100644 --- a/lib/Cake/Model/Datasource/Session/DatabaseSession.php +++ b/lib/Cake/Model/Datasource/Session/DatabaseSession.php @@ -118,7 +118,11 @@ public function write($id, $data) { $record = compact('id', 'data', 'expires'); $record[$this->_model->primaryKey] = $id; - $options = array('validate' => false, 'callbacks' => false); + $options = array( + 'validate' => false, + 'callbacks' => false, + 'counterCache' => false + ); try { return $this->_model->save($record, $options); } catch (PDOException $e) { From f9ba950ad415c67b5b3596dc4d4962f3f7dca284 Mon Sep 17 00:00:00 2001 From: AD7six Date: Fri, 23 Jan 2015 08:47:05 +0000 Subject: [PATCH 058/336] Skip Sqlite Sqlite will accept an insert with duplicate primary keys and silently drop the query. There is no exception, or indication that the insert failed. --- .../Case/Model/Datasource/Session/DatabaseSessionTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php b/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php index a0c6b30a3b9..1a4b316f06f 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php @@ -198,6 +198,11 @@ public function testGc() { * @return void */ public function testConcurrentInsert() { + $this->skipIf( + $this->db instanceof Sqlite, + 'Sqlite does not throw exceptions when attempting to insert a duplicate primary key' + ); + ClassRegistry::removeObject('Session'); $mockedModel = $this->getMockForModel( From a8ae12a700909a3b34424dfe390dbe61b8c80e63 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 25 Jan 2015 22:24:24 -0500 Subject: [PATCH 059/336] Fix warnings when php://output is used with ConsoleOutput. The php://output stream is not compatible with posix functions. Refs #4901 --- lib/Cake/Console/ConsoleOutput.php | 1 + lib/Cake/Test/Case/Console/ConsoleOutputTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/Cake/Console/ConsoleOutput.php b/lib/Cake/Console/ConsoleOutput.php index 32abf712346..4f56fb5c4f8 100644 --- a/lib/Cake/Console/ConsoleOutput.php +++ b/lib/Cake/Console/ConsoleOutput.php @@ -162,6 +162,7 @@ public function __construct($stream = 'php://stdout') { $this->_output = fopen($stream, 'w'); if ((DS === '\\' && !(bool)env('ANSICON')) || + $stream === 'php://output' || (function_exists('posix_isatty') && !posix_isatty($this->_output)) ) { $this->_outputAs = self::PLAIN; diff --git a/lib/Cake/Test/Case/Console/ConsoleOutputTest.php b/lib/Cake/Test/Case/Console/ConsoleOutputTest.php index 4b26aae250d..5eabefd5847 100644 --- a/lib/Cake/Test/Case/Console/ConsoleOutputTest.php +++ b/lib/Cake/Test/Case/Console/ConsoleOutputTest.php @@ -231,6 +231,17 @@ public function testOutputAsPlain() { $this->output->write('Bad Regular', false); } +/** + * test plain output when php://output, as php://output is + * not compatible with posix_ functions. + * + * @return void + */ + public function testOutputAsPlainWhenOutputStream() { + $output = $this->getMock('ConsoleOutput', array('_write'), array('php://output')); + $this->assertEquals(ConsoleOutput::PLAIN, $output->outputAs()); + } + /** * test plain output only strips tags used for formatting. * From 76f7754014c031bd6b01be6cf67bbc3aed39f9b2 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Mon, 26 Jan 2015 10:29:52 +0100 Subject: [PATCH 060/336] Adding a status code test. --- lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php b/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php index 4eb1d301142..bb2df1d3194 100644 --- a/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php +++ b/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php @@ -297,6 +297,7 @@ public function testTestAction() { 'Location' => 'http://cakephp.org' ); $this->assertEquals($expected, $results); + $this->assertSame(302, $Controller->response->statusCode()); } /** From e753fbadca7a31ce26f2800c73d6e5660067d85a Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Mon, 26 Jan 2015 10:31:04 +0100 Subject: [PATCH 061/336] Fix ControllerTestCase redirect --- lib/Cake/Controller/Controller.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index 74b65e7b66c..f8252914a10 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -751,7 +751,7 @@ public function loadModel($modelClass = null, $id = null) { * * @param string|array $url A string or array-based URL pointing to another location within the app, * or an absolute URL - * @param int $status Optional HTTP status code (eg: 404) + * @param int $status HTTP status code (eg: 301) * @param bool $exit If true, exit() will be called after the redirect * @return void * @triggers Controller.beforeRedirect $this, array($url, $status, $exit) @@ -785,6 +785,9 @@ public function redirect($url, $status = null, $exit = true) { } } + if ($status === null) { + $status = 302; + } if ($status) { $this->response->statusCode($status); } From 70276b7a7ad6b203d3e25ae320d441c1cd8dd925 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Mon, 26 Jan 2015 10:35:02 +0100 Subject: [PATCH 062/336] Doc block adjustment. --- lib/Cake/Controller/Controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index f8252914a10..3688386c64d 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -751,7 +751,7 @@ public function loadModel($modelClass = null, $id = null) { * * @param string|array $url A string or array-based URL pointing to another location within the app, * or an absolute URL - * @param int $status HTTP status code (eg: 301) + * @param int|array|null $status HTTP status code (eg: 301). Defaults to 302 when null is passed. * @param bool $exit If true, exit() will be called after the redirect * @return void * @triggers Controller.beforeRedirect $this, array($url, $status, $exit) From 4fa5dd62c57f3e51ac59d7b78722e45a14c938d6 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Mon, 26 Jan 2015 23:47:20 +0100 Subject: [PATCH 063/336] Remove conditional status setting. --- lib/Cake/Controller/Controller.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index 3688386c64d..8cd10fdf134 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -788,9 +788,7 @@ public function redirect($url, $status = null, $exit = true) { if ($status === null) { $status = 302; } - if ($status) { - $this->response->statusCode($status); - } + $this->response->statusCode($status); if ($exit) { $this->response->send(); From 97c6850005ed1e50ddcc6a7137138be2c575b654 Mon Sep 17 00:00:00 2001 From: tgskiv Date: Tue, 27 Jan 2015 19:06:46 +0200 Subject: [PATCH 064/336] Let IDE work better with ClassRegistry::init() This small change will allow some IDEs like NetBeans to work with returned object like with a instance of $class parameter. I`m sure, this will help Cake users a lot! --- lib/Cake/Utility/ClassRegistry.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Utility/ClassRegistry.php b/lib/Cake/Utility/ClassRegistry.php index 144a0318fea..1208b4401f1 100644 --- a/lib/Cake/Utility/ClassRegistry.php +++ b/lib/Cake/Utility/ClassRegistry.php @@ -91,7 +91,7 @@ public static function getInstance() { * stored in the registry and returned. * @param bool $strict if set to true it will return false if the class was not found instead * of trying to create an AppModel - * @return object instance of ClassName. + * @return $class instance of ClassName. * @throws CakeException when you try to construct an interface or abstract class. */ public static function init($class, $strict = false) { From 611889235a001b9dc22f3dc8921c20f27f86f545 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Wed, 28 Jan 2015 23:54:32 +0100 Subject: [PATCH 065/336] Fix clear(). Add test cases. --- lib/Cake/Model/Datasource/CakeSession.php | 13 ++++++++----- .../Test/Case/Model/Datasource/CakeSessionTest.php | 8 ++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index f232ec30618..9e04158b5c7 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -374,7 +374,7 @@ public static function userAgent($userAgent = null) { * * @param string|null $name The name of the session variable (or a path as sent to Set.extract) * @return mixed The value of the session variable, null if session not available, - * session not started, or provided name not found in the session. + * session not started, or provided name not found in the session, false on failure. */ public static function read($name = null) { if (empty($name) && $name !== null) { @@ -478,11 +478,14 @@ public static function destroy() { * @return void */ public static function clear($renew = true) { - $_SESSION = null; - if ($renew) { - self::$id = null; - self::renew(); + if (!$renew) { + $_SESSION = array(); + return; } + + $_SESSION = null; + self::$id = null; + self::renew(); } /** diff --git a/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php b/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php index 2b7cac57946..2c691844d32 100644 --- a/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php @@ -413,6 +413,14 @@ public function testClear() { TestCakeSession::clear(false); $this->assertFalse(TestCakeSession::check('Delete.me')); $this->assertFalse(TestCakeSession::check('Delete')); + + TestCakeSession::write('Some.string', 'value'); + TestCakeSession::clear(false); + $this->assertNull(TestCakeSession::read('Some')); + + TestCakeSession::write('Some.string.array', array('values')); + TestCakeSession::clear(false); + $this->assertFalse(TestCakeSession::read()); } /** From 8a600e357b0009d571d174eb19b486679d445bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20Barta?= Date: Thu, 29 Jan 2015 16:38:01 +0100 Subject: [PATCH 066/336] Adding webfont formats as binary in .gitattributes With the current state, our Linux workstations with default configs convert fonts' line endings, and that screws them up. These lines fix this. --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitattributes b/.gitattributes index cc576ac7960..3c21bde619a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -33,3 +33,6 @@ *.ico binary *.mo binary *.pdf binary +*.woff binary +*.ttf binary +*.eot binary From 54fe7ed20476a2780a6fc726322bcae247ea9f69 Mon Sep 17 00:00:00 2001 From: ADmad Date: Sun, 1 Feb 2015 13:11:44 +0530 Subject: [PATCH 067/336] Add method to get depth of tree's node. Backported from 3.0. --- lib/Cake/Model/Behavior/TreeBehavior.php | 35 +++++++++++++++++++ .../Model/Behavior/TreeBehaviorNumberTest.php | 20 +++++++++++ 2 files changed, 55 insertions(+) diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index 11bbb5bb18e..1cb3f003f6e 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -996,6 +996,41 @@ public function verify(Model $Model) { return true; } +/** + * Returns the depth level of a node in the tree. + * + * @param Model $Model Model using this behavior + * @param int|string $id The primary key for record to get the level of. + * @return int|bool Integer of the level or false if the node does not exist. + */ + public function getLevel(Model $Model, $id = null) { + if ($id === null) { + $id = $Model->id; + } + + $node = $Model->find('first', array( + 'conditions' => array($Model->escapeField() => $id), + 'order' => false, + 'recursive' => -1 + )); + + if (empty($node)) { + return false; + } + + extract($this->settings[$Model->alias]); + + return $Model->find('count', array( + 'conditions' => array( + $scope, + $left . ' <' => $node[$Model->alias][$left], + $right . ' >' => $node[$Model->alias][$right] + ), + 'order' => false, + 'recursive' => -1 + )); + } + /** * Sets the parent of the given node * diff --git a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php index f03ac2a79cd..e5503f56304 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php @@ -548,6 +548,26 @@ public function testMovePromote() { $this->assertTrue($validTree); } +/** + * testGetLevel method + * + * @return void + */ + public function testGetLevel() { + extract($this->settings); + $this->Tree = new $modelClass(); + $this->Tree->initialize(2, 2); + $this->Tree->id = null; + + $result = $this->Tree->getLevel(5); + $this->assertEquals(1, $result); + + $result = $this->Tree->getLevel(3); + $this->assertEquals(2, $result); + + $this->assertFalse($this->Tree->getLevel(999)); + } + /** * testMoveWithWhitelist method * From 970cb81d03dc8f3db9efe7b9271f4b4e089dd3ae Mon Sep 17 00:00:00 2001 From: James Watts Date: Mon, 2 Feb 2015 02:07:13 +0100 Subject: [PATCH 068/336] Typo typo --- 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 9902fe632dd..b2890b7f12a 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -1138,7 +1138,7 @@ public function length($bytes = null) { /** * Checks whether a response has not been modified according to the 'If-None-Match' * (Etags) and 'If-Modified-Since' (last modification date) request - * headers headers. If the response is detected to be not modified, it + * headers. If the response is detected to be not modified, it * is marked as so accordingly so the client can be informed of that. * * In order to mark a response as not modified, you need to set at least From acd32b71fe5e9e229d50d051bf208556d0835684 Mon Sep 17 00:00:00 2001 From: Rachman Chavik Date: Wed, 4 Feb 2015 15:47:01 +0700 Subject: [PATCH 069/336] Fix: "bake plugin" generates incorrect directory for View/Layouts --- lib/Cake/Console/Command/Task/PluginTask.php | 2 +- lib/Cake/Test/Case/Console/Command/Task/PluginTaskTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Console/Command/Task/PluginTask.php b/lib/Cake/Console/Command/Task/PluginTask.php index 8105cc8d0e5..95c3b30397b 100644 --- a/lib/Cake/Console/Command/Task/PluginTask.php +++ b/lib/Cake/Console/Command/Task/PluginTask.php @@ -123,7 +123,7 @@ public function bake($plugin) { 'Test' . DS . 'Fixture', 'View' . DS . 'Elements', 'View' . DS . 'Helper', - 'View' . DS . 'Layout', + 'View' . DS . 'Layouts', 'webroot' . DS . 'css', 'webroot' . DS . 'js', 'webroot' . DS . 'img', diff --git a/lib/Cake/Test/Case/Console/Command/Task/PluginTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/PluginTaskTest.php index 38c243d21a5..82500e3aac9 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/PluginTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/PluginTaskTest.php @@ -115,7 +115,7 @@ public function testBakeFoldersAndFiles() { 'Test' . DS . 'Fixture', 'View' . DS . 'Elements', 'View' . DS . 'Helper', - 'View' . DS . 'Layout', + 'View' . DS . 'Layouts', 'webroot' . DS . 'css', 'webroot' . DS . 'js', 'webroot' . DS . 'img', From 2ff6bdccec343d434231382d7f7501794c457ae3 Mon Sep 17 00:00:00 2001 From: James Tancock Date: Wed, 4 Feb 2015 12:18:31 +0000 Subject: [PATCH 070/336] Back port of Flash component & helper --- .../Controller/Component/FlashComponent.php | 120 ++++++++++++++++++ lib/Cake/View/Helper/FlashHelper.php | 90 +++++++++++++ 2 files changed, 210 insertions(+) create mode 100644 lib/Cake/Controller/Component/FlashComponent.php create mode 100644 lib/Cake/View/Helper/FlashHelper.php diff --git a/lib/Cake/Controller/Component/FlashComponent.php b/lib/Cake/Controller/Component/FlashComponent.php new file mode 100644 index 00000000000..7963af62950 --- /dev/null +++ b/lib/Cake/Controller/Component/FlashComponent.php @@ -0,0 +1,120 @@ + 'flash', + 'element' => 'default', + 'params' => array(), + ); + +/** + * Constructor + * + * @param ComponentCollection $collection + * @param array $settings + */ + public function __construct(ComponentCollection $collection, $settings = array()) { + $this->_defaultConfig = Hash::merge($this->_defaultConfig, $settings); + } + +/** + * Used to set a session variable that can be used to output messages in the view. + * + * In your controller: $this->Flash->set('This has been saved'); + * + * ### Options: + * + * - `key` The key to set under the session's Flash key + * - `element` The element used to render the flash message. Default to 'default'. + * - `params` An array of variables to make available when using an element + * + * @param string $message Message to be flashed. If an instance + * of Exception the exception message will be used and code will be set + * in params. + * @param array $options An array of options. + * @return void + */ + + public function set($message, $options = array()) { + $options += $this->_defaultConfig; + + if ($message instanceof Exception) { + $options['params'] += array('code' => $message->getCode()); + $message = $message->getMessage(); + } + + list($plugin, $element) = pluginSplit($options['element']); + + if ($plugin) { + $options['element'] = $plugin . '.Flash/' . $element; + } else { + $options['element'] = 'Flash/' . $element; + } + + CakeSession::write('Flash.' . $options['key'], array( + 'message' => $message, + 'key' => $options['key'], + 'element' => $options['element'], + 'params' => $options['params'] + )); + } + +/** + * Magic method for verbose flash methods based on element names. + * + * For example: $this->Flash->success('My message') would use the + * success.ctp element under `app/View/Element/Flash` for rendering the + * flash message. + * + * @param string $name Element name to use. + * @param array $args Parameters to pass when calling `FlashComponent::set()`. + * @return void + * @throws InternalErrorException If missing the flash message. + */ + public function __call($name, $args) { + $options = array('element' => Inflector::underscore($name)); + + if (count($args) < 1) { + throw new InternalErrorException(__('Flash message missing.')); + } + + if (!empty($args[1])) { + $options += (array)$args[1]; + } + + $this->set($args[0], $options); + } +} diff --git a/lib/Cake/View/Helper/FlashHelper.php b/lib/Cake/View/Helper/FlashHelper.php new file mode 100644 index 00000000000..63071e98253 --- /dev/null +++ b/lib/Cake/View/Helper/FlashHelper.php @@ -0,0 +1,90 @@ +Flash->render('somekey'); + * Will default to flash if no param is passed + * + * You can pass additional information into the flash message generation. This allows you + * to consolidate all the parameters for a given type of flash message into the view. + * + * ``` + * echo $this->Flash->render('flash', ['params' => ['name' => $user['User']['name']]]); + * ``` + * + * This would pass the current user's name into the flash message, so you could create personalized + * messages without the controller needing access to that data. + * + * Lastly you can choose the element that is used for rendering the flash message. Using + * custom elements allows you to fully customize how flash messages are generated. + * + * ``` + * echo $this->Flash->render('flash', ['element' => 'my_custom_element']); + * ``` + * + * If you want to use an element from a plugin for rendering your flash message + * you can use the dot notation for the plugin's element name: + * + * ``` + * echo $this->Flash->render('flash', [ + * 'element' => 'MyPlugin.my_custom_element', + * ]); + * ``` + * + * @param string $key The [Flash.]key you are rendering in the view. + * @param array $options Additional options to use for the creation of this flash message. + * Supports the 'params', and 'element' keys that are used in the helper. + * @return string|null Rendered flash message or null if flash key does not exist + * in session. + * @throws UnexpectedValueException If value for flash settings key is not an array. + */ + public function render($key = 'flash', $options = array()) { + + if (!CakeSession::check("Message.$key")) { + return; + } + + $flash = CakeSession::read("Message.$key"); + + if (!is_array($flash)) { + throw new UnexpectedValueException(sprintf( + 'Value for flash setting key "%s" must be an array.', + $key + )); + } + + $flash = $options + $flash; + CakeSession::delete("Flash.$key"); + + return $this->_View->element($flash['element'], $flash); + } +} From b8b6b67abd505d963fa2bdf4b488687b9e3a1ddd Mon Sep 17 00:00:00 2001 From: James Tancock Date: Wed, 4 Feb 2015 15:05:40 +0000 Subject: [PATCH 071/336] Tests for ported Flash component & helper --- .../Component/FlashComponentTest.php | 171 ++++++++++++++++++ .../Test/Case/View/Helper/FlashHelperTest.php | 153 ++++++++++++++++ .../test_app/View/Elements/Flash/default.ctp | 1 + .../test_app/View/Elements/flash_classy.ctp | 1 + .../test_app/View/Elements/flash_helper.ctp | 5 + lib/Cake/View/Helper/FlashHelper.php | 16 +- 6 files changed, 339 insertions(+), 8 deletions(-) create mode 100644 lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php create mode 100644 lib/Cake/Test/Case/View/Helper/FlashHelperTest.php create mode 100644 lib/Cake/Test/test_app/View/Elements/Flash/default.ctp create mode 100644 lib/Cake/Test/test_app/View/Elements/flash_classy.ctp create mode 100644 lib/Cake/Test/test_app/View/Elements/flash_helper.ctp diff --git a/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php b/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php new file mode 100644 index 00000000000..bfb71aae839 --- /dev/null +++ b/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php @@ -0,0 +1,171 @@ + + * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * For full copyright and license information, please see the LICENSE.txt + * Redistributions of files must retain the above copyright notice + * + * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests + * @package Cake.Test.Case.Controller.Component + * @since CakePHP(tm) v 2.7.0-dev + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ + +App::uses('FlashComponent', 'Controller/Component'); +App::uses('ComponentCollection', 'Controller'); + +/** +* FlashComponentTest class +* +* @package Cake.Test.Case.Controller.Component +*/ +class FlashComponentTest extends CakeTestCase { + +/** +* setUp method +* +* @return void +*/ + public function setUp() { + parent::setUp(); + $this->Components = new ComponentCollection(); + $this->Flash = new FlashComponent($this->Components); + } + +/** +* tearDown method +* +* @return void +*/ + public function tearDown() { + parent::tearDown(); + CakeSession::destroy(); + } + +/** +* testSet method +* +* @return void +*/ + public function testSet() { + $this->assertNull(CakeSession::read('Flash.flash')); + + $this->Flash->set('This is a test message'); + $expected = array( + 'message' => 'This is a test message', + 'key' => 'flash', + 'element' => 'Flash/default', + 'params' => array() + ); + $result = CakeSession::read('Flash.flash'); + $this->assertEquals($expected, $result); + + $this->Flash->set('This is a test message', array( + 'element' => 'test', + 'params' => array('foo' => 'bar') + )); + $expected = array( + 'message' => 'This is a test message', + 'key' => 'flash', + 'element' => 'Flash/test', + 'params' => array('foo' => 'bar') + ); + $result = CakeSession::read('Flash.flash'); + $this->assertEquals($expected, $result); + + $this->Flash->set('This is a test message', array('element' => 'MyPlugin.alert')); + $expected = array( + 'message' => 'This is a test message', + 'key' => 'flash', + 'element' => 'MyPlugin.Flash/alert', + 'params' => array() + ); + $result = CakeSession::read('Flash.flash'); + $this->assertEquals($expected, $result); + + $this->Flash->set('This is a test message', array('key' => 'foobar')); + $expected = array( + 'message' => 'This is a test message', + 'key' => 'foobar', + 'element' => 'Flash/default', + 'params' => array() + ); + $result = CakeSession::read('Flash.foobar'); + $this->assertEquals($expected, $result); + } + +/** +* testSetWithException method +* +* @return void +*/ + public function testSetWithException() { + $this->assertNull(CakeSession::read('Flash.flash')); + + $this->Flash->set(new Exception('This is a test message', 404)); + $expected = array( + 'message' => 'This is a test message', + 'key' => 'flash', + 'element' => 'Flash/default', + 'params' => array('code' => 404) + ); + $result = CakeSession::read('Flash.flash'); + $this->assertEquals($expected, $result); + } + +/** +* testSetWithComponentConfiguration method +* +* @return void +*/ + public function testSetWithComponentConfiguration() { + $this->assertNull(CakeSession::read('Flash.flash')); + + $FlashWithSettings = $this->Components->load('Flash', array('element' => 'test')); + $FlashWithSettings->set('This is a test message'); + $expected = array( + 'message' => 'This is a test message', + 'key' => 'flash', + 'element' => 'Flash/test', + 'params' => array() + ); + $result = CakeSession::read('Flash.flash'); + $this->assertEquals($expected, $result); + } + +/** +* Test magic call method. +* +* @return void +*/ + public function testCall() { + $this->assertNull(CakeSession::read('Flash.flash')); + + $this->Flash->success('It worked'); + $expected = array( + 'message' => 'It worked', + 'key' => 'flash', + 'element' => 'Flash/success', + 'params' => array() + ); + $result = CakeSession::read('Flash.flash'); + $this->assertEquals($expected, $result); + + $this->Flash->error('It did not work', array('element' => 'error_thing')); + $expected = array( + 'message' => 'It did not work', + 'key' => 'flash', + 'element' => 'Flash/error', + 'params' => array() + ); + $result = CakeSession::read('Flash.flash'); + $this->assertEquals($expected, $result, 'Element is ignored in magic call.'); + } +} diff --git a/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php b/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php new file mode 100644 index 00000000000..ad619f96649 --- /dev/null +++ b/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php @@ -0,0 +1,153 @@ + + * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * For full copyright and license information, please see the LICENSE.txt + * Redistributions of files must retain the above copyright notice + * + * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests + * @package Cake.Test.Case.View.Helper + * @since CakePHP(tm) v 2.7.0-dev + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ + +App::uses('FlashHelper', 'View/Helper'); +App::uses('View', 'View'); +App::uses('CakePlugin', 'Core'); + +/** +* FlashHelperTest class +* +* @package Cake.Test.Case.View.Helper +*/ +class FlashHelperTest extends CakeTestCase { + + public static function setupBeforeClass() { + App::build(array( + 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) + )); + } + + /** + * setUp method + * + * @return void + */ + public function setUp() { + parent::setUp(); + $controller = null; + $this->View = new View($controller); + $this->Flash = new FlashHelper($this->View); + + if (!CakeSession::started()) { + CakeSession::start(); + } + CakeSession::write(array( + 'Flash' => array( + 'flash' => array( + 'key' => 'flash', + 'message' => 'This is a calling', + 'element' => 'Flash/default', + 'params' => array() + ), + 'notification' => array( + 'key' => 'notification', + 'message' => 'Broadcast message testing', + 'element' => 'flash_helper', + 'params' => array( + 'title' => 'Notice!', + 'name' => 'Alert!' + ) + ), + 'classy' => array( + 'key' => 'classy', + 'message' => 'Recorded', + 'element' => 'flash_classy', + 'params' => array() + ) + ) + )); + } + + /** + * tearDown method + * + * @return void + */ + public function tearDown() { + parent::tearDown(); + unset($this->View, $this->Flash); + CakeSession::destroy(); + } + + /** + * testFlash method + * + * @return void + */ + public function testFlash() { + $result = $this->Flash->render(); + $expected = '
This is a calling
'; + $this->assertContains($expected, $result); + + $expected = '
Recorded
'; + $result = $this->Flash->render('classy'); + $this->assertContains($expected, $result); + + $result = $this->Flash->render('notification'); + $expected = "
\n\t

Alert!

\n\t

Notice!

\n\t

Broadcast message testing

\n
"; + + $this->assertContains($expected, $result); + + $this->assertNull($this->Flash->render('non-existent')); + } + + /** + * testFlashThrowsException + * + * @expectedException UnexpectedValueException + */ + public function testFlashThrowsException() { + CakeSession::write('Flash.foo', 'bar'); + $this->Flash->render('foo'); + } + + /** + * test setting the element from the attrs. + * + * @return void + */ + public function testFlashElementInAttrs() { + $result = $this->Flash->render('notification', array( + 'element' => 'flash_helper', + 'params' => array('title' => 'Alert!', 'name' => 'Notice!') + )); + + $expected = "
\n\t

Notice!

\n\t

Alert!

\n\t

Broadcast message testing

\n
"; + + $this->assertContains($expected, $result); + } + + /** + * test using elements in plugins. + * + * @return void + */ + public function testFlashWithPluginElement() { + App::build(array( + 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) + )); + CakePlugin::load('TestPlugin'); + + $result = $this->Flash->render('flash', array('element' => 'TestPlugin.plugin_element')); + $expected = 'this is the plugin element'; + $this->assertContains($expected, $result); + } +} diff --git a/lib/Cake/Test/test_app/View/Elements/Flash/default.ctp b/lib/Cake/Test/test_app/View/Elements/Flash/default.ctp new file mode 100644 index 00000000000..fd1533971b4 --- /dev/null +++ b/lib/Cake/Test/test_app/View/Elements/Flash/default.ctp @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/lib/Cake/Test/test_app/View/Elements/flash_classy.ctp b/lib/Cake/Test/test_app/View/Elements/flash_classy.ctp new file mode 100644 index 00000000000..6fd3a5d3ff9 --- /dev/null +++ b/lib/Cake/Test/test_app/View/Elements/flash_classy.ctp @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/lib/Cake/Test/test_app/View/Elements/flash_helper.ctp b/lib/Cake/Test/test_app/View/Elements/flash_helper.ctp new file mode 100644 index 00000000000..43be11a889f --- /dev/null +++ b/lib/Cake/Test/test_app/View/Elements/flash_helper.ctp @@ -0,0 +1,5 @@ +
+

+

+

+
\ No newline at end of file diff --git a/lib/Cake/View/Helper/FlashHelper.php b/lib/Cake/View/Helper/FlashHelper.php index 63071e98253..d0ca89e8cea 100644 --- a/lib/Cake/View/Helper/FlashHelper.php +++ b/lib/Cake/View/Helper/FlashHelper.php @@ -1,5 +1,7 @@ Flash->render('flash', ['params' => ['name' => $user['User']['name']]]); + * echo $this->Flash->render('flash', array('params' => array('name' => $user['User']['name']))); * ``` * * This would pass the current user's name into the flash message, so you could create personalized @@ -48,16 +49,16 @@ class FlashHelper extends AppHelper { * custom elements allows you to fully customize how flash messages are generated. * * ``` - * echo $this->Flash->render('flash', ['element' => 'my_custom_element']); + * echo $this->Flash->render('flash', array('element' => 'my_custom_element')); * ``` * * If you want to use an element from a plugin for rendering your flash message * you can use the dot notation for the plugin's element name: * * ``` - * echo $this->Flash->render('flash', [ + * echo $this->Flash->render('flash', array( * 'element' => 'MyPlugin.my_custom_element', - * ]); + * )); * ``` * * @param string $key The [Flash.]key you are rendering in the view. @@ -68,12 +69,11 @@ class FlashHelper extends AppHelper { * @throws UnexpectedValueException If value for flash settings key is not an array. */ public function render($key = 'flash', $options = array()) { - - if (!CakeSession::check("Message.$key")) { + if (!CakeSession::check("Flash.$key")) { return; } - $flash = CakeSession::read("Message.$key"); + $flash = CakeSession::read("Flash.$key"); if (!is_array($flash)) { throw new UnexpectedValueException(sprintf( From e173c29d332e1308d5656775bc332ddbb42ba9a6 Mon Sep 17 00:00:00 2001 From: James Tancock Date: Wed, 4 Feb 2015 15:31:50 +0000 Subject: [PATCH 072/336] Fix for phpcs --- .../Controller/Component/FlashComponent.php | 4 +- .../Component/FlashComponentTest.php | 56 +++++++------- .../Test/Case/View/Helper/FlashHelperTest.php | 73 ++++++++++--------- 3 files changed, 69 insertions(+), 64 deletions(-) diff --git a/lib/Cake/Controller/Component/FlashComponent.php b/lib/Cake/Controller/Component/FlashComponent.php index 7963af62950..d70388e6f25 100644 --- a/lib/Cake/Controller/Component/FlashComponent.php +++ b/lib/Cake/Controller/Component/FlashComponent.php @@ -43,8 +43,8 @@ class FlashComponent extends Component { /** * Constructor * - * @param ComponentCollection $collection - * @param array $settings + * @param ComponentCollection $collection The ComponentCollection object + * @param array $settings Settings passed via controller */ public function __construct(ComponentCollection $collection, $settings = array()) { $this->_defaultConfig = Hash::merge($this->_defaultConfig, $settings); diff --git a/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php b/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php index bfb71aae839..373cdf1940d 100644 --- a/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php @@ -22,17 +22,17 @@ App::uses('ComponentCollection', 'Controller'); /** -* FlashComponentTest class -* -* @package Cake.Test.Case.Controller.Component -*/ + * FlashComponentTest class + * + * @package Cake.Test.Case.Controller.Component + */ class FlashComponentTest extends CakeTestCase { /** -* setUp method -* -* @return void -*/ + * setUp method + * + * @return void + */ public function setUp() { parent::setUp(); $this->Components = new ComponentCollection(); @@ -40,20 +40,20 @@ public function setUp() { } /** -* tearDown method -* -* @return void -*/ + * tearDown method + * + * @return void + */ public function tearDown() { parent::tearDown(); CakeSession::destroy(); } /** -* testSet method -* -* @return void -*/ + * testSet method + * + * @return void + */ public function testSet() { $this->assertNull(CakeSession::read('Flash.flash')); @@ -102,10 +102,10 @@ public function testSet() { } /** -* testSetWithException method -* -* @return void -*/ + * testSetWithException method + * + * @return void + */ public function testSetWithException() { $this->assertNull(CakeSession::read('Flash.flash')); @@ -121,10 +121,10 @@ public function testSetWithException() { } /** -* testSetWithComponentConfiguration method -* -* @return void -*/ + * testSetWithComponentConfiguration method + * + * @return void + */ public function testSetWithComponentConfiguration() { $this->assertNull(CakeSession::read('Flash.flash')); @@ -141,10 +141,10 @@ public function testSetWithComponentConfiguration() { } /** -* Test magic call method. -* -* @return void -*/ + * Test magic call method. + * + * @return void + */ public function testCall() { $this->assertNull(CakeSession::read('Flash.flash')); diff --git a/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php b/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php index ad619f96649..d7cf2dc7b2c 100644 --- a/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php @@ -23,23 +23,28 @@ App::uses('CakePlugin', 'Core'); /** -* FlashHelperTest class -* -* @package Cake.Test.Case.View.Helper -*/ + * FlashHelperTest class + * + * @package Cake.Test.Case.View.Helper + */ class FlashHelperTest extends CakeTestCase { +/** + * setupBeforeClass method + * + * @return void + */ public static function setupBeforeClass() { App::build(array( 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) )); } - /** - * setUp method - * - * @return void - */ +/** + * setUp method + * + * @return void + */ public function setUp() { parent::setUp(); $controller = null; @@ -76,22 +81,22 @@ public function setUp() { )); } - /** - * tearDown method - * - * @return void - */ +/** + * tearDown method + * + * @return void + */ public function tearDown() { parent::tearDown(); unset($this->View, $this->Flash); CakeSession::destroy(); } - /** - * testFlash method - * - * @return void - */ +/** + * testFlash method + * + * @return void + */ public function testFlash() { $result = $this->Flash->render(); $expected = '
This is a calling
'; @@ -109,21 +114,21 @@ public function testFlash() { $this->assertNull($this->Flash->render('non-existent')); } - /** - * testFlashThrowsException - * - * @expectedException UnexpectedValueException - */ +/** + * testFlashThrowsException + * + * @expectedException UnexpectedValueException + */ public function testFlashThrowsException() { CakeSession::write('Flash.foo', 'bar'); $this->Flash->render('foo'); } - /** - * test setting the element from the attrs. - * - * @return void - */ +/** + * test setting the element from the attrs. + * + * @return void + */ public function testFlashElementInAttrs() { $result = $this->Flash->render('notification', array( 'element' => 'flash_helper', @@ -135,11 +140,11 @@ public function testFlashElementInAttrs() { $this->assertContains($expected, $result); } - /** - * test using elements in plugins. - * - * @return void - */ +/** + * test using elements in plugins. + * + * @return void + */ public function testFlashWithPluginElement() { App::build(array( 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) From 3f715c4262aa5f141c941a90b9015a2e50713ae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20M=C3=B8ller?= Date: Wed, 4 Feb 2015 21:29:16 +0100 Subject: [PATCH 073/336] Load ClassRegistry Once --- lib/Cake/Console/Shell.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Cake/Console/Shell.php b/lib/Cake/Console/Shell.php index 67e3c2eab29..71ca7235282 100644 --- a/lib/Cake/Console/Shell.php +++ b/lib/Cake/Console/Shell.php @@ -22,7 +22,6 @@ App::uses('ConsoleOptionParser', 'Console'); App::uses('ClassRegistry', 'Utility'); App::uses('File', 'Utility'); -App::uses('ClassRegistry', 'Utility'); /** * Base class for command-line utilities for automating programmer chores. From 703be31c83709d3008615257f5fb0bff744d2eb8 Mon Sep 17 00:00:00 2001 From: David Yell Date: Thu, 5 Feb 2015 12:02:18 +0000 Subject: [PATCH 074/336] Update phpunit.php PHPUnit can no longer be installed using pear --- lib/Cake/TestSuite/templates/phpunit.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/Cake/TestSuite/templates/phpunit.php b/lib/Cake/TestSuite/templates/phpunit.php index f25d8d971b0..3f39a59d9ed 100644 --- a/lib/Cake/TestSuite/templates/phpunit.php +++ b/lib/Cake/TestSuite/templates/phpunit.php @@ -20,12 +20,7 @@

PHPUnit is not installed!

You must install PHPUnit to use the CakePHP(tm) Test Suite.

-

PHPUnit can be installed with pear, using the pear installer.

-

To install with the PEAR installer run the following commands:

-
    -
  • pear config-set auto_discover 1
  • -
  • pear install pear.phpunit.de/PHPUnit
  • -
+

PHPUnit can be installed with Composer, or downloaded as a phar archive.

Once PHPUnit is installed make sure its located on PHP's include_path by checking your php.ini

For full instructions on how to install PHPUnit, see the PHPUnit installation guide.

Download PHPUnit

From ae8653a06622ed2a3886c1cb5f5753510156dbcc Mon Sep 17 00:00:00 2001 From: Michael Dabydeen Date: Thu, 5 Feb 2015 13:26:03 -0500 Subject: [PATCH 075/336] Contributing: Fixed a broken link. Link to markdown files should end in .md not .mdown. --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 85f793b6bfc..5bb12117948 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -60,7 +60,7 @@ To run the sniffs for CakePHP coding standards: phpcs -p --extensions=php --standard=CakePHP ./lib/Cake Check the [cakephp-codesniffer](https://github.com/cakephp/cakephp-codesniffer) -repository to setup the CakePHP standard. The [README](https://github.com/cakephp/cakephp-codesniffer/blob/master/README.mdown) contains installation info +repository to setup the CakePHP standard. The [README](https://github.com/cakephp/cakephp-codesniffer/blob/master/README.md) contains installation info for the sniff and phpcs. # Additional Resources From b974daac7bf66602f2d38c45782900033dc4e291 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 5 Feb 2015 22:28:02 -0500 Subject: [PATCH 076/336] Don't create invalid maxlength attributes for decimal columns. Converting the maxlength to an int avoids any commas from decimal columns. Refs #5832 --- .../Test/Case/View/Helper/FormHelperTest.php | 26 +++++++++++++++++++ lib/Cake/View/Helper/FormHelper.php | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 3f9a765cbd8..0a4e8f004df 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -763,6 +763,32 @@ public function testTextFieldGenerationForFloats() { $this->assertTags($result, $expected); } +/** + * Tests correct generation of decimal fields as text inputs + * + * @return void + */ + public function testTextFieldGenerationForDecimalAsText() { + $this->Form->create('ValidateUser'); + $result = $this->Form->input('cost_decimal', array( + 'type' => 'text' + )); + $expected = array( + 'div' => array('class' => 'input text'), + 'label' => array('for' => 'ValidateUserCostDecimal'), + 'Cost Decimal', + '/label', + array('input' => array( + 'type' => 'text', + 'name' => 'data[ValidateUser][cost_decimal]', + 'id' => 'ValidateUserCostDecimal', + 'maxlength' => 6, + )), + '/div' + ); + $this->assertTags($result, $expected); + } + /** * Tests correct generation of number fields for integer fields * diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index ed614e8307a..21e86e93d97 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -1292,7 +1292,7 @@ protected function _maxLength($options) { if ($autoLength && in_array($options['type'], array('text', 'textarea', 'email', 'tel', 'url', 'search')) ) { - $options['maxlength'] = $fieldDef['length']; + $options['maxlength'] = (int)$fieldDef['length']; } return $options; } From ff39d93299793cd6f1528a7a98db640010846d08 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 7 Feb 2015 15:52:34 -0500 Subject: [PATCH 077/336] Remove PHP5.2 from the build matrix. Travis-ci no longer supports PHP5.2. Attempting to run tests on it causes our builds to fail out. I think this also begs a broader discussion around supported versions in the future. I'm not personally comfortable saying we support PHP 5.2 when we don't run tests against it anymore. --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c62fd7bdeda..82761958e4c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 5.2 - 5.3 - 5.4 - 5.5 @@ -27,8 +26,8 @@ matrix: before_script: - - sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then composer global require 'phpunit/phpunit=3.7.33'; fi" - - sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then ln -s ~/.composer/vendor/phpunit/phpunit/PHPUnit ./vendors/PHPUnit; fi" + - sh -c "composer global require 'phpunit/phpunit=3.7.33'" + - sh -c "ln -s ~/.composer/vendor/phpunit/phpunit/PHPUnit ./vendors/PHPUnit" - sudo locale-gen de_DE - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi" - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test2;'; fi" From 1cb670bdfa4b4e2dba3a87431f20c5c5aeb039e8 Mon Sep 17 00:00:00 2001 From: James Tancock Date: Tue, 10 Feb 2015 08:15:01 +0000 Subject: [PATCH 078/336] Add deprecated doctag for current methods --- lib/Cake/Controller/Component/SessionComponent.php | 1 + lib/Cake/View/Helper/SessionHelper.php | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/Cake/Controller/Component/SessionComponent.php b/lib/Cake/Controller/Component/SessionComponent.php index 67bc4f42685..cb196775ae1 100644 --- a/lib/Cake/Controller/Component/SessionComponent.php +++ b/lib/Cake/Controller/Component/SessionComponent.php @@ -133,6 +133,7 @@ public function error() { * @param string $key Message key, default is 'flash' * @return void * @link http://book.cakephp.org/2.0/en/core-libraries/components/sessions.html#creating-notification-messages + * @deprecated 3.0.0 Since 2.7, use the FlashComponent instead. */ public function setFlash($message, $element = 'default', $params = array(), $key = 'flash') { CakeSession::write('Message.' . $key, compact('message', 'element', 'params')); diff --git a/lib/Cake/View/Helper/SessionHelper.php b/lib/Cake/View/Helper/SessionHelper.php index 95e00425eec..e1fd1a20115 100644 --- a/lib/Cake/View/Helper/SessionHelper.php +++ b/lib/Cake/View/Helper/SessionHelper.php @@ -126,6 +126,7 @@ public function error() { * Supports the 'params', and 'element' keys that are used in the helper. * @return string * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/session.html#SessionHelper::flash + * @deprecated 3.0.0 Since 2.7, use FlashHelper::render() instead. */ public function flash($key = 'flash', $attrs = array()) { $out = false; From 3dfa22b02117d09070c8eee2ec1c79faf6368533 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 10 Feb 2015 22:46:53 -0500 Subject: [PATCH 079/336] Fix order of hasOne assocation. This should fix non-deterministic failures. --- .../Controller/Component/Auth/BasicAuthenticateTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php index c4402a7f7ba..df18703c409 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php @@ -254,7 +254,11 @@ public function testAuthenticateUserFieldsSuccess() { */ public function testAuthenticateUserFieldsRelatedModelsSuccess() { $User = ClassRegistry::init('User'); - $User->bindModel(array('hasOne' => array('Article'))); + $User->bindModel(array('hasOne' => array( + 'Article' => array( + 'order' => 'Article.id ASC' + ) + ))); $this->auth->settings['recursive'] = 0; $this->auth->settings['userFields'] = array('Article.id', 'Article.title'); $request = new CakeRequest('posts/index', false); From 3cee029aa76d5e4bea2a041a1a67651535c0c153 Mon Sep 17 00:00:00 2001 From: James Tancock Date: Thu, 12 Feb 2015 15:09:18 +0000 Subject: [PATCH 080/336] Removed usage of __() for InternalError --- lib/Cake/Controller/Component/FlashComponent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Controller/Component/FlashComponent.php b/lib/Cake/Controller/Component/FlashComponent.php index d70388e6f25..5c382d299f9 100644 --- a/lib/Cake/Controller/Component/FlashComponent.php +++ b/lib/Cake/Controller/Component/FlashComponent.php @@ -108,7 +108,7 @@ public function __call($name, $args) { $options = array('element' => Inflector::underscore($name)); if (count($args) < 1) { - throw new InternalErrorException(__('Flash message missing.')); + throw new InternalErrorException('Flash message missing.'); } if (!empty($args[1])) { From b3c9c1615e36a200a308f7bd434eaad5ff4b89b8 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 13 Feb 2015 21:40:50 -0500 Subject: [PATCH 081/336] Fix doubly linking URLs starting with // Fixes #5889 --- lib/Cake/Test/Case/View/Helper/TextHelperTest.php | 4 ++++ lib/Cake/View/Helper/TextHelper.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/View/Helper/TextHelperTest.php b/lib/Cake/Test/Case/View/Helper/TextHelperTest.php index 41ef4b29649..87d81b14a0a 100644 --- a/lib/Cake/Test/Case/View/Helper/TextHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/TextHelperTest.php @@ -127,6 +127,10 @@ public function testAutoLink() { $expected = 'Text with a partial www.cakephp.org URL and test@cakephp\.org email address'; $this->assertRegExp('#^' . $expected . '$#', $result); + $text = 'Text with a partial link link'; + $result = $this->Text->autoLink($text, array('escape' => false)); + $this->assertEquals($text, $result); + $text = 'This is a test text with URL http://www.cakephp.org'; $expected = 'This is a test text with URL http://www.cakephp.org'; $result = $this->Text->autoLink($text); diff --git a/lib/Cake/View/Helper/TextHelper.php b/lib/Cake/View/Helper/TextHelper.php index 92d30ace6a5..2a2a536b49d 100644 --- a/lib/Cake/View/Helper/TextHelper.php +++ b/lib/Cake/View/Helper/TextHelper.php @@ -114,7 +114,7 @@ public function autoLinkUrls($text, $options = array()) { $text ); $text = preg_replace_callback( - '#(?)(?)(? Date: Sun, 15 Feb 2015 16:30:43 +0530 Subject: [PATCH 082/336] Reduced code nesting. --- lib/Cake/Model/Behavior/TreeBehavior.php | 72 +++++++++++++----------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index 11bbb5bb18e..fab0dc506e2 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -193,53 +193,59 @@ public function beforeSave(Model $Model, $options = array()) { if (!$parentNode) { return false; } - list($parentNode) = array_values($parentNode); + $Model->data[$Model->alias][$left] = 0; $Model->data[$Model->alias][$right] = 0; - } else { - $edge = $this->_getMax($Model, $scope, $right, $recursive); - $Model->data[$Model->alias][$left] = $edge + 1; - $Model->data[$Model->alias][$right] = $edge + 2; + return true; } - } elseif (array_key_exists($parent, $Model->data[$Model->alias])) { + + $edge = $this->_getMax($Model, $scope, $right, $recursive); + $Model->data[$Model->alias][$left] = $edge + 1; + $Model->data[$Model->alias][$right] = $edge + 2; + return true; + } + + if (array_key_exists($parent, $Model->data[$Model->alias])) { if ($Model->data[$Model->alias][$parent] != $Model->field($parent)) { $this->settings[$Model->alias]['__parentChange'] = true; } if (!$Model->data[$Model->alias][$parent]) { $Model->data[$Model->alias][$parent] = null; $this->_addToWhitelist($Model, $parent); - } else { - $values = $Model->find('first', array( - 'conditions' => array($scope, $Model->escapeField() => $Model->id), - 'fields' => array($Model->primaryKey, $parent, $left, $right), - 'order' => false, - 'recursive' => $recursive) - ); + return true; + } - if (empty($values)) { - return false; - } - list($node) = array_values($values); + $values = $Model->find('first', array( + 'conditions' => array($scope, $Model->escapeField() => $Model->id), + 'fields' => array($Model->primaryKey, $parent, $left, $right), + 'order' => false, + 'recursive' => $recursive) + ); - $parentNode = $Model->find('first', array( - 'conditions' => array($scope, $Model->escapeField() => $Model->data[$Model->alias][$parent]), - 'fields' => array($Model->primaryKey, $left, $right), - 'order' => false, - 'recursive' => $recursive - )); - if (!$parentNode) { - return false; - } - list($parentNode) = array_values($parentNode); + if (empty($values)) { + return false; + } + list($node) = array_values($values); - if (($node[$left] < $parentNode[$left]) && ($parentNode[$right] < $node[$right])) { - return false; - } - if ($node[$Model->primaryKey] === $parentNode[$Model->primaryKey]) { - return false; - } + $parentNode = $Model->find('first', array( + 'conditions' => array($scope, $Model->escapeField() => $Model->data[$Model->alias][$parent]), + 'fields' => array($Model->primaryKey, $left, $right), + 'order' => false, + 'recursive' => $recursive + )); + if (!$parentNode) { + return false; + } + list($parentNode) = array_values($parentNode); + + if (($node[$left] < $parentNode[$left]) && ($parentNode[$right] < $node[$right])) { + return false; + } + if ($node[$Model->primaryKey] === $parentNode[$Model->primaryKey]) { + return false; } } + return true; } From 546941a79be9fbf8d8c204a12bf6bc42b869eb31 Mon Sep 17 00:00:00 2001 From: Markus Fischer Date: Sun, 15 Feb 2015 12:38:48 +0100 Subject: [PATCH 083/336] i18n: Remove POT-Creation-Date Prevent app locale files getting marked as modified in VCS even if the actual content didn't change. Fixes #5887 --- lib/Cake/Console/Command/Task/ExtractTask.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Cake/Console/Command/Task/ExtractTask.php b/lib/Cake/Console/Command/Task/ExtractTask.php index 7a6ff14d135..57064917050 100644 --- a/lib/Cake/Console/Command/Task/ExtractTask.php +++ b/lib/Cake/Console/Command/Task/ExtractTask.php @@ -686,7 +686,6 @@ protected function _writeHeader() { $output .= "msgid \"\"\n"; $output .= "msgstr \"\"\n"; $output .= "\"Project-Id-Version: PROJECT VERSION\\n\"\n"; - $output .= "\"POT-Creation-Date: " . date("Y-m-d H:iO") . "\\n\"\n"; $output .= "\"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\\n\"\n"; $output .= "\"Last-Translator: NAME \\n\"\n"; $output .= "\"Language-Team: LANGUAGE \\n\"\n"; From 0750a63ed414f5dcdec888950c6e47c851e40cef Mon Sep 17 00:00:00 2001 From: ADmad Date: Sun, 15 Feb 2015 18:23:07 +0530 Subject: [PATCH 084/336] Make code DRYer. --- lib/Cake/Model/Behavior/TreeBehavior.php | 102 +++++++---------------- 1 file changed, 30 insertions(+), 72 deletions(-) diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index fab0dc506e2..1305d5b03d3 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -184,12 +184,7 @@ public function beforeSave(Model $Model, $options = array()) { $this->_addToWhitelist($Model, array($left, $right)); if (!$Model->id || !$Model->exists()) { if (array_key_exists($parent, $Model->data[$Model->alias]) && $Model->data[$Model->alias][$parent]) { - $parentNode = $Model->find('first', array( - 'conditions' => array($scope, $Model->escapeField() => $Model->data[$Model->alias][$parent]), - 'fields' => array($Model->primaryKey, $right), - 'recursive' => $recursive, - 'order' => false, - )); + $parentNode = $this->_getNode($Model, $Model->data[$Model->alias][$parent]); if (!$parentNode) { return false; } @@ -215,24 +210,13 @@ public function beforeSave(Model $Model, $options = array()) { return true; } - $values = $Model->find('first', array( - 'conditions' => array($scope, $Model->escapeField() => $Model->id), - 'fields' => array($Model->primaryKey, $parent, $left, $right), - 'order' => false, - 'recursive' => $recursive) - ); - + $values = $this->_getNode($Model, $Model->id); if (empty($values)) { return false; } list($node) = array_values($values); - $parentNode = $Model->find('first', array( - 'conditions' => array($scope, $Model->escapeField() => $Model->data[$Model->alias][$parent]), - 'fields' => array($Model->primaryKey, $left, $right), - 'order' => false, - 'recursive' => $recursive - )); + $parentNode = $this->_getNode($Model, $Model->data[$Model->alias][$parent]); if (!$parentNode) { return false; } @@ -249,6 +233,24 @@ public function beforeSave(Model $Model, $options = array()) { return true; } +/** + * Returns a single node from the tree from its primary key + * + * @param Model $Model Model using this behavior + * @param int|string $id The ID of the record to read + * @return array|boolean The record read or false + */ + protected function _getNode(Model $Model, $id) { + $settings = $this->settings[$Model->alias]; + + return $Model->find('first', array( + 'conditions' => array($Model->escapeField() => $id), + 'fields' => array($Model->primaryKey, $settings['parent'], $settings['left'], $settings['right']), + 'recursive' => $settings['recursive'], + 'order' => false, + )); + } + /** * Get the number of child nodes * @@ -281,11 +283,7 @@ public function childCount(Model $Model, $id = null, $direct = false) { } elseif ($Model->id === $id && isset($Model->data[$Model->alias][$left]) && isset($Model->data[$Model->alias][$right])) { $data = $Model->data[$Model->alias]; } else { - $data = $Model->find('first', array( - 'conditions' => array($scope, $Model->escapeField() => $id), - 'order' => false, - 'recursive' => $recursive - )); + $data = $this->_getNode($Model, $id); if (!$data) { return 0; } @@ -567,19 +565,9 @@ public function moveDown(Model $Model, $id = null, $number = 1) { $id = $Model->id; } extract($this->settings[$Model->alias]); - list($node) = array_values($Model->find('first', array( - 'conditions' => array($scope, $Model->escapeField() => $id), - 'fields' => array($Model->primaryKey, $left, $right, $parent), - 'order' => false, - 'recursive' => $recursive - ))); + list($node) = array_values($this->_getNode($Model, $id)); if ($node[$parent]) { - list($parentNode) = array_values($Model->find('first', array( - 'conditions' => array($scope, $Model->escapeField() => $node[$parent]), - 'fields' => array($Model->primaryKey, $left, $right), - 'order' => false, - 'recursive' => $recursive - ))); + list($parentNode) = array_values($this->_getNode($Model, $node[$parent])); if (($node[$right] + 1) == $parentNode[$right]) { return false; } @@ -631,19 +619,9 @@ public function moveUp(Model $Model, $id = null, $number = 1) { $id = $Model->id; } extract($this->settings[$Model->alias]); - list($node) = array_values($Model->find('first', array( - 'conditions' => array($scope, $Model->escapeField() => $id), - 'fields' => array($Model->primaryKey, $left, $right, $parent), - 'order' => false, - 'recursive' => $recursive - ))); + list($node) = array_values($this->_getNode($Model, $id)); if ($node[$parent]) { - list($parentNode) = array_values($Model->find('first', array( - 'conditions' => array($scope, $Model->escapeField() => $node[$parent]), - 'fields' => array($Model->primaryKey, $left, $right), - 'order' => false, - 'recursive' => $recursive - ))); + list($parentNode) = array_values($this->_getNode($Model, $node[$parent])); if (($node[$left] - 1) == $parentNode[$left]) { return false; } @@ -872,12 +850,7 @@ public function removeFromTree(Model $Model, $id = null, $delete = false) { } extract($this->settings[$Model->alias]); - list($node) = array_values($Model->find('first', array( - 'conditions' => array($scope, $Model->escapeField() => $id), - 'fields' => array($Model->primaryKey, $left, $right, $parent), - 'order' => false, - 'recursive' => $recursive - ))); + list($node) = array_values($this->_getNode($Model, $id)); if ($node[$right] == $node[$left] + 1) { if ($delete) { @@ -886,12 +859,7 @@ public function removeFromTree(Model $Model, $id = null, $delete = false) { $Model->id = $id; return $Model->saveField($parent, null); } elseif ($node[$parent]) { - list($parentNode) = array_values($Model->find('first', array( - 'conditions' => array($scope, $Model->escapeField() => $node[$parent]), - 'fields' => array($Model->primaryKey, $left, $right), - 'order' => false, - 'recursive' => $recursive - ))); + list($parentNode) = array_values($this->_getNode($Model, $node[$parent])); } else { $parentNode[$right] = $node[$right] + 1; } @@ -1016,24 +984,14 @@ public function verify(Model $Model) { */ protected function _setParent(Model $Model, $parentId = null, $created = false) { extract($this->settings[$Model->alias]); - list($node) = array_values($Model->find('first', array( - 'conditions' => array($scope, $Model->escapeField() => $Model->id), - 'fields' => array($Model->primaryKey, $parent, $left, $right), - 'order' => false, - 'recursive' => $recursive - ))); + list($node) = array_values($this->_getNode($Model, $Model->id)); $edge = $this->_getMax($Model, $scope, $right, $recursive, $created); if (empty($parentId)) { $this->_sync($Model, $edge - $node[$left] + 1, '+', 'BETWEEN ' . $node[$left] . ' AND ' . $node[$right], $created); $this->_sync($Model, $node[$right] - $node[$left] + 1, '-', '> ' . $node[$left], $created); } else { - $values = $Model->find('first', array( - 'conditions' => array($scope, $Model->escapeField() => $parentId), - 'fields' => array($Model->primaryKey, $left, $right), - 'order' => false, - 'recursive' => $recursive - )); + $values = $this->_getNode($Model, $parentId); if ($values === false) { return false; From bdc6a1f010de29b8a4e36468fdefbb871731549f Mon Sep 17 00:00:00 2001 From: ADmad Date: Sun, 15 Feb 2015 19:22:44 +0530 Subject: [PATCH 085/336] Fix CS error --- lib/Cake/Model/Behavior/TreeBehavior.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index 1305d5b03d3..6dc27df5ce1 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -238,7 +238,7 @@ public function beforeSave(Model $Model, $options = array()) { * * @param Model $Model Model using this behavior * @param int|string $id The ID of the record to read - * @return array|boolean The record read or false + * @return array|bool The record read or false */ protected function _getNode(Model $Model, $id) { $settings = $this->settings[$Model->alias]; From 6ad68ae1e2e1a0dada6554d0123bb6ea36899e85 Mon Sep 17 00:00:00 2001 From: ADmad Date: Sun, 15 Feb 2015 22:23:31 +0530 Subject: [PATCH 086/336] Allow setting level (depth) of tree nodes on save. Backported from 3.0. --- lib/Cake/Model/Behavior/TreeBehavior.php | 66 +++++++++++++++++-- .../Model/Behavior/TreeBehaviorNumberTest.php | 60 ++++++++++++++++- lib/Cake/Test/Fixture/NumberTreeFixture.php | 3 +- 3 files changed, 123 insertions(+), 6 deletions(-) diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index c4508fc21c1..bb3d81ba7cd 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -44,7 +44,7 @@ class TreeBehavior extends ModelBehavior { * @var array */ protected $_defaults = array( - 'parent' => 'parent_id', 'left' => 'lft', 'right' => 'rght', + 'parent' => 'parent_id', 'left' => 'lft', 'right' => 'rght', 'level' => null, 'scope' => '1 = 1', 'type' => 'nested', '__parentChange' => false, 'recursive' => -1 ); @@ -97,10 +97,47 @@ public function afterSave(Model $Model, $created, $options = array()) { } } elseif ($this->settings[$Model->alias]['__parentChange']) { $this->settings[$Model->alias]['__parentChange'] = false; + if ($level) { + $this->_setChildrenLevel($Model, $Model->id); + } return $this->_setParent($Model, $Model->data[$Model->alias][$parent]); } } +/** + * Set level for descendents. + * + * @param Model $Model Model using this behavior. + * @param int|string $id Record ID + * @return void + */ + protected function _setChildrenLevel($Model, $id) { + $settings = $Model->Behaviors->Tree->settings[$Model->alias]; + $primaryKey = $Model->primaryKey; + $depths = array($id => (int)$Model->data[$Model->alias][$settings['level']]); + + $children = $Model->children( + $id, + false, + array($primaryKey, $settings['parent'], $settings['level']), + $settings['left'], + null, + 1, + -1 + ); + + foreach ($children as $node) { + $parentIdValue = $node[$Model->alias][$settings['parent']]; + $depth = (int)$depths[$parentIdValue] + 1; + $depths[$node[$Model->alias][$primaryKey]] = $depth; + + $Model->updateAll( + array($settings['level'] => $depth), + array($primaryKey => $node[$Model->alias][$primaryKey]) + ); + } + } + /** * Runs before a find() operation * @@ -182,8 +219,13 @@ public function beforeSave(Model $Model, $options = array()) { extract($this->settings[$Model->alias]); $this->_addToWhitelist($Model, array($left, $right)); + if ($level) { + $this->_addToWhitelist($Model, $level); + } + $parentIsSet = array_key_exists($parent, $Model->data[$Model->alias]); + if (!$Model->id || !$Model->exists()) { - if (array_key_exists($parent, $Model->data[$Model->alias]) && $Model->data[$Model->alias][$parent]) { + if ($parentIsSet && $Model->data[$Model->alias][$parent]) { $parentNode = $this->_getNode($Model, $Model->data[$Model->alias][$parent]); if (!$parentNode) { return false; @@ -191,22 +233,31 @@ public function beforeSave(Model $Model, $options = array()) { $Model->data[$Model->alias][$left] = 0; $Model->data[$Model->alias][$right] = 0; + if ($level) { + $Model->data[$Model->alias][$level] = (int)$parentNode[$Model->alias][$level] + 1; + } return true; } $edge = $this->_getMax($Model, $scope, $right, $recursive); $Model->data[$Model->alias][$left] = $edge + 1; $Model->data[$Model->alias][$right] = $edge + 2; + if ($level) { + $Model->data[$Model->alias][$level] = 0; + } return true; } - if (array_key_exists($parent, $Model->data[$Model->alias])) { + if ($parentIsSet) { if ($Model->data[$Model->alias][$parent] != $Model->field($parent)) { $this->settings[$Model->alias]['__parentChange'] = true; } if (!$Model->data[$Model->alias][$parent]) { $Model->data[$Model->alias][$parent] = null; $this->_addToWhitelist($Model, $parent); + if ($level) { + $Model->data[$Model->alias][$level] = 0; + } return true; } @@ -228,6 +279,9 @@ public function beforeSave(Model $Model, $options = array()) { if ($node[$Model->primaryKey] === $parentNode[$Model->primaryKey]) { return false; } + if ($level) { + $Model->data[$Model->alias][$level] = (int)$parentNode[$level] + 1; + } } return true; @@ -242,10 +296,14 @@ public function beforeSave(Model $Model, $options = array()) { */ protected function _getNode(Model $Model, $id) { $settings = $this->settings[$Model->alias]; + $fields = array($Model->primaryKey, $settings['parent'], $settings['left'], $settings['right']); + if ($settings['level']) { + $fields[] = $settings['level']; + } return $Model->find('first', array( 'conditions' => array($Model->escapeField() => $id), - 'fields' => array($Model->primaryKey, $settings['parent'], $settings['left'], $settings['right']), + 'fields' => $fields, 'recursive' => $settings['recursive'], 'order' => false, )); diff --git a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php index e5503f56304..da7da8196c0 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php @@ -46,7 +46,8 @@ class TreeBehaviorNumberTest extends CakeTestCase { 'modelClass' => 'NumberTree', 'leftField' => 'lft', 'rightField' => 'rght', - 'parentField' => 'parent_id' + 'parentField' => 'parent_id', + 'level' => 'level' ); /** @@ -1527,4 +1528,61 @@ public function testFindThreaded() { ); $this->assertEquals($expected, $result); } + + public function testLevel() { + extract($this->settings); + $this->Tree = new $modelClass(); + $this->Tree->Behaviors->attach('Tree', array('level' => 'level')); + $this->Tree->initialize(2, 2); + + $result = $this->Tree->findByName('1. Root'); + $this->assertEquals(0, $result[$modelClass][$level]); + + $result = $this->Tree->findByName('1.1'); + $this->assertEquals(1, $result[$modelClass][$level]); + + $result = $this->Tree->findByName('1.2.2'); + $this->assertEquals(2, $result[$modelClass][$level]); + + $result = $this->Tree->findByName('1.2.1'); + $this->assertEquals(2, $result[$modelClass][$level]); + + // Save with parent_id not set + $this->Tree->save(array('id' => $result[$modelClass]['id'], 'name' => 'foo')); + $result = $this->Tree->findByName('foo'); + $this->assertEquals(2, $result[$modelClass][$level]); + + // Save with parent_id not changed + $this->Tree->save(array( + 'id' => $result[$modelClass]['id'], + 'parent_id' => $result[$modelClass]['parent_id'], + 'name' => 'foo2' + )); + $result = $this->Tree->findByName('foo2'); + $this->assertEquals(2, $result[$modelClass][$level]); + + // Save with parent_id changed + $result = $this->Tree->findByName('1.1'); + $this->Tree->save(array( + 'id' => $result[$modelClass]['id'], + 'parent_id' => '' + )); + $result = $this->Tree->findByName('1.1'); + $this->assertEquals(0, $result[$modelClass][$level]); + + $result = $this->Tree->findByName('1.1.2'); + $this->assertEquals(1, $result[$modelClass][$level]); + + $parent = $this->Tree->findByName('1.1.2'); + $result = $this->Tree->findByName('1.2'); + $this->Tree->save(array( + 'id' => $result[$modelClass]['id'], + 'parent_id' => $parent[$modelClass]['id'] + )); + $result = $this->Tree->findByName('1.2'); + $this->assertEquals(2, $result[$modelClass][$level]); + + $result = $this->Tree->findByName('1.2.2'); + $this->assertEquals(3, $result[$modelClass][$level]); + } } diff --git a/lib/Cake/Test/Fixture/NumberTreeFixture.php b/lib/Cake/Test/Fixture/NumberTreeFixture.php index cea90492175..8d6a9495ecf 100644 --- a/lib/Cake/Test/Fixture/NumberTreeFixture.php +++ b/lib/Cake/Test/Fixture/NumberTreeFixture.php @@ -37,6 +37,7 @@ class NumberTreeFixture extends CakeTestFixture { 'name' => array('type' => 'string', 'null' => false), 'parent_id' => 'integer', 'lft' => array('type' => 'integer', 'null' => false), - 'rght' => array('type' => 'integer', 'null' => false) + 'rght' => array('type' => 'integer', 'null' => false), + 'level' => array('type' => 'integer', 'null' => false) ); } From e095885dc4803ec88d75d35b479720961a8602f8 Mon Sep 17 00:00:00 2001 From: ADmad Date: Sun, 15 Feb 2015 22:35:42 +0530 Subject: [PATCH 087/336] Fix test case --- lib/Cake/Test/Case/Model/ModelIntegrationTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php index 8f941b05921..fce6067b917 100644 --- a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php +++ b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php @@ -226,7 +226,8 @@ public function testDynamicBehaviorAttachment() { 'scope' => '1 = 1', 'type' => 'nested', '__parentChange' => false, - 'recursive' => -1 + 'recursive' => -1, + 'level' => null ); $this->assertEquals($expected, $TestModel->Behaviors->Tree->settings['Apple']); From 204f50bb97d17aa9efc51ab3cfaa2349dfb1a45f Mon Sep 17 00:00:00 2001 From: ADmad Date: Sun, 15 Feb 2015 23:04:13 +0530 Subject: [PATCH 088/336] Allow level field to be null for pqsql and sqlite. --- lib/Cake/Test/Fixture/NumberTreeFixture.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Test/Fixture/NumberTreeFixture.php b/lib/Cake/Test/Fixture/NumberTreeFixture.php index 8d6a9495ecf..78d34cf21c7 100644 --- a/lib/Cake/Test/Fixture/NumberTreeFixture.php +++ b/lib/Cake/Test/Fixture/NumberTreeFixture.php @@ -38,6 +38,6 @@ class NumberTreeFixture extends CakeTestFixture { 'parent_id' => 'integer', 'lft' => array('type' => 'integer', 'null' => false), 'rght' => array('type' => 'integer', 'null' => false), - 'level' => array('type' => 'integer', 'null' => false) + 'level' => array('type' => 'integer', 'null' => true) ); } From 5fd7396e479753b5c967ecffc45e52eac62ca9cc Mon Sep 17 00:00:00 2001 From: David Steinsland Date: Sun, 15 Feb 2015 19:32:33 +0100 Subject: [PATCH 089/336] Fixed downloading of files with dots --- lib/Cake/Network/CakeResponse.php | 2 +- .../Test/Case/Network/CakeResponseTest.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index b2890b7f12a..26bfb83be19 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -1336,7 +1336,7 @@ public function file($path, $options = array()) { 'download' => null ); - if (strpos($path, '..') !== false) { + if (strpos($path, '../') !== false || strpos($path, '..\\') !== false) { throw new NotFoundException(__d( 'cake_dev', 'The requested file contains `..` and will not be read.' diff --git a/lib/Cake/Test/Case/Network/CakeResponseTest.php b/lib/Cake/Test/Case/Network/CakeResponseTest.php index 801f08664de..22dd7f985cb 100644 --- a/lib/Cake/Test/Case/Network/CakeResponseTest.php +++ b/lib/Cake/Test/Case/Network/CakeResponseTest.php @@ -1170,6 +1170,7 @@ public function testFileNotFound() { * test file with .. * * @expectedException NotFoundException + * @expectedExceptionMessage The requested file contains `..` and will not be read. * @return void */ public function testFileWithPathTraversal() { @@ -1177,6 +1178,24 @@ public function testFileWithPathTraversal() { $response->file('my/../cat.gif'); } + public function testFileWithDotsInFilename() { + $ok = false; + $file = 'my/Some..cat.gif'; + + try { + $response = new CakeResponse(); + $response->file($file); + } catch (NotFoundException $e) { + if (Configure::read('debug') > 0) { + $ok = $e->getMessage() === sprintf('The requested file %s was not found or not readable', APP . $file); + } else { + $ok = $e->getMessage() === 'The requested file was not found'; + } + } + + $this->assertTrue($ok); + } + /** * testFile method * From 960ddd0eb89e2cc139d8b8865ce93d0fd0546533 Mon Sep 17 00:00:00 2001 From: David Steinsland Date: Sun, 15 Feb 2015 19:34:28 +0100 Subject: [PATCH 090/336] Added DocBlock --- lib/Cake/Test/Case/Network/CakeResponseTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Cake/Test/Case/Network/CakeResponseTest.php b/lib/Cake/Test/Case/Network/CakeResponseTest.php index 22dd7f985cb..7960a7c9fcc 100644 --- a/lib/Cake/Test/Case/Network/CakeResponseTest.php +++ b/lib/Cake/Test/Case/Network/CakeResponseTest.php @@ -1178,6 +1178,12 @@ public function testFileWithPathTraversal() { $response->file('my/../cat.gif'); } +/** + * Although unlikely, file's may contain dots in their filenames. + * This should be allowed, as long as the dots doesn't specify a path (../ or ..\) + * + * @return void + */ public function testFileWithDotsInFilename() { $ok = false; $file = 'my/Some..cat.gif'; From e3b530652117e606d6c3f648d821e07055520c8d Mon Sep 17 00:00:00 2001 From: Jan Dorsman Date: Wed, 28 Jan 2015 14:33:42 +0100 Subject: [PATCH 091/336] Fixing issue #5764 --- lib/Cake/Network/Email/CakeEmail.php | 4 ++++ .../Test/Case/Network/Email/CakeEmailTest.php | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index 41b83032bb5..7150bb4175c 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -353,6 +353,10 @@ public function __construct($config = null) { if ($config) { $this->config($config); + } elseif (config('email')) { + if (property_exists($this->_configClass, 'default')) { + $this->config('default'); + } } if (empty($this->headerCharset)) { $this->headerCharset = $this->charset; diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index 1dc125fead6..7668baad79b 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -2449,4 +2449,23 @@ public function assertLineLengths($message) { } } +/** + * Test if the EmailConfig::$default configuration is read when present + * + * @return void + */ + public function testDefaultConfig() { + $defaultConfig = new File(APP . 'Config' . DS . 'email.php.default'); + $emailConfig = new File(APP . 'Config' . DS . 'email.php'); + $hasConfig = $emailConfig->exists(); + $this->skipIf(!$defaultConfig->copy(APP . 'Config' . DS . 'email.php', false)); + + $Email = new CakeEmail(); + $this->skipIf(!property_exists('EmailConfig', 'default')); + $this->assertEquals('you@localhost', current($Email->from())); + if (!$hasConfig) { + $emailConfig->delete(); + } + } + } From 3fee5b9eaafdcca986f776129aef7c2c04c427df Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 19 Feb 2015 07:34:27 -0500 Subject: [PATCH 092/336] Update version number to 2.6.2 --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index 8ede76ab154..4c3efdfeb59 100644 --- a/lib/Cake/VERSION.txt +++ b/lib/Cake/VERSION.txt @@ -17,4 +17,4 @@ // @license http://www.opensource.org/licenses/mit-license.php MIT License // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -2.6.1 +2.6.2 From 463fa660bc26fad8e15e0f8bc11355dbc1520500 Mon Sep 17 00:00:00 2001 From: David Steinsland Date: Thu, 19 Feb 2015 17:28:32 +0100 Subject: [PATCH 093/336] Updated test --- .../Test/Case/Network/CakeResponseTest.php | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/lib/Cake/Test/Case/Network/CakeResponseTest.php b/lib/Cake/Test/Case/Network/CakeResponseTest.php index 7960a7c9fcc..a811b89e52f 100644 --- a/lib/Cake/Test/Case/Network/CakeResponseTest.php +++ b/lib/Cake/Test/Case/Network/CakeResponseTest.php @@ -1179,27 +1179,16 @@ public function testFileWithPathTraversal() { } /** - * Although unlikely, file's may contain dots in their filenames. + * Although unlikely, a file may contain dots in its filename. * This should be allowed, as long as the dots doesn't specify a path (../ or ..\) * + * @expectedException NotFoundException + * @execptedExceptionMessageRegExp #The requested file .+my/Some..cat.gif was not found or not readable# * @return void */ public function testFileWithDotsInFilename() { - $ok = false; - $file = 'my/Some..cat.gif'; - - try { - $response = new CakeResponse(); - $response->file($file); - } catch (NotFoundException $e) { - if (Configure::read('debug') > 0) { - $ok = $e->getMessage() === sprintf('The requested file %s was not found or not readable', APP . $file); - } else { - $ok = $e->getMessage() === 'The requested file was not found'; - } - } - - $this->assertTrue($ok); + $response = new CakeResponse(); + $response->file('my/Some..cat.gif'); } /** From 2a57d9b65f5f899a28638241b1d44c24801f7140 Mon Sep 17 00:00:00 2001 From: ADmad Date: Thu, 19 Feb 2015 12:25:17 +0530 Subject: [PATCH 094/336] Avoid reloading config file and recreating config instance. --- lib/Cake/Network/Email/CakeEmail.php | 24 +++++--- .../Test/Case/Network/Email/CakeEmailTest.php | 59 +++++++++++-------- 2 files changed, 53 insertions(+), 30 deletions(-) diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index 7150bb4175c..4f860db6173 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -336,6 +336,13 @@ class CakeEmail { */ protected $_configClass = 'EmailConfig'; +/** + * An instance of the EmailConfig class can be set here + * + * @var string + */ + protected $_configInstance; + /** * Constructor * @@ -353,8 +360,9 @@ public function __construct($config = null) { if ($config) { $this->config($config); - } elseif (config('email')) { - if (property_exists($this->_configClass, 'default')) { + } elseif (class_exists($this->_configClass) && config('email')) { + $this->_configInstance = new $this->_configClass(); + if (isset($this->_configInstance->default)) { $this->config('default'); } } @@ -1227,14 +1235,16 @@ public static function deliver($to = null, $subject = null, $message = null, $tr */ protected function _applyConfig($config) { if (is_string($config)) { - if (!class_exists($this->_configClass) && !config('email')) { - throw new ConfigureException(__d('cake_dev', '%s not found.', APP . 'Config' . DS . 'email.php')); + if (!$this->_configInstance) { + if (!class_exists($this->_configClass) && !config('email')) { + throw new ConfigureException(__d('cake_dev', '%s not found.', APP . 'Config' . DS . 'email.php')); + } + $this->_configInstance = new $this->_configClass(); } - $configs = new $this->_configClass(); - if (!isset($configs->{$config})) { + if (!isset($this->_configInstance->{$config})) { throw new ConfigureException(__d('cake_dev', 'Unknown email configuration "%s".', $config)); } - $config = $configs->{$config}; + $config = $this->_configInstance->{$config}; } $this->_config = $config + $this->_config; if (!empty($config['charset'])) { diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index 7668baad79b..66b36dcd608 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -17,6 +17,7 @@ */ App::uses('CakeEmail', 'Network/Email'); +App::uses('File', 'Utility'); /** * Help to test CakeEmail @@ -92,6 +93,15 @@ public function render($content) { */ class TestEmailConfig { +/** + * default config + * + * @var array + */ + public $default = array( + 'subject' => 'Default Subject', + ); + /** * test config * @@ -145,6 +155,14 @@ class CakeEmailTest extends CakeTestCase { */ public function setUp() { parent::setUp(); + + $this->_configFileExists = true; + $emailConfig = new File(APP . 'Config' . DS . 'email.php'); + if (!$emailConfig->exists()) { + $this->_configFileExists = false; + $emailConfig->create(); + } + $this->CakeEmail = new TestCakeEmail(); App::build(array( @@ -160,6 +178,19 @@ public function setUp() { public function tearDown() { parent::tearDown(); App::build(); + + if (!$this->_configFileExists) { + unlink(APP . 'Config' . DS . 'email.php'); + } + } + +/** + * Test if the EmailConfig::$default configuration is read when present + * + * @return void + */ + public function testDefaultConfig() { + $this->assertEquals('Default Subject', $this->CakeEmail->subject()); } /** @@ -860,16 +891,17 @@ public function testConfig() { $config = array('test' => 'ok', 'test2' => true); $this->CakeEmail->config($config); $this->assertSame($config, $transportClass->config()); - $this->assertSame($config, $this->CakeEmail->config()); + $expected = $config + array('subject' => 'Default Subject'); + $this->assertSame($expected, $this->CakeEmail->config()); $this->CakeEmail->config(array()); $this->assertSame($config, $transportClass->config()); - $config = array('test' => 'test@example.com'); + $config = array('test' => 'test@example.com', 'subject' => 'my test subject'); $this->CakeEmail->config($config); - $expected = array('test' => 'test@example.com', 'test2' => true); + $expected = array('test' => 'test@example.com', 'subject' => 'my test subject', 'test2' => true); $this->assertSame($expected, $this->CakeEmail->config()); - $this->assertSame($expected, $transportClass->config()); + $this->assertSame(array('test' => 'test@example.com', 'test2' => true), $transportClass->config()); } /** @@ -2449,23 +2481,4 @@ public function assertLineLengths($message) { } } -/** - * Test if the EmailConfig::$default configuration is read when present - * - * @return void - */ - public function testDefaultConfig() { - $defaultConfig = new File(APP . 'Config' . DS . 'email.php.default'); - $emailConfig = new File(APP . 'Config' . DS . 'email.php'); - $hasConfig = $emailConfig->exists(); - $this->skipIf(!$defaultConfig->copy(APP . 'Config' . DS . 'email.php', false)); - - $Email = new CakeEmail(); - $this->skipIf(!property_exists('EmailConfig', 'default')); - $this->assertEquals('you@localhost', current($Email->from())); - if (!$hasConfig) { - $emailConfig->delete(); - } - } - } From 4f2ed156121d01be9c0d3e685cbcae71b3db06c2 Mon Sep 17 00:00:00 2001 From: Michael Houghton Date: Sat, 21 Feb 2015 10:21:37 +0000 Subject: [PATCH 095/336] fix for confirm message on the bake templates --- lib/Cake/Console/Templates/default/views/index.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Console/Templates/default/views/index.ctp b/lib/Cake/Console/Templates/default/views/index.ctp index d3d4caaf302..28d5bcc60e2 100644 --- a/lib/Cake/Console/Templates/default/views/index.ctp +++ b/lib/Cake/Console/Templates/default/views/index.ctp @@ -48,7 +48,7 @@ echo "\t\t\n"; echo "\t\t\tHtml->link(__('View'), array('action' => 'view', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; echo "\t\t\tHtml->link(__('Edit'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; - echo "\t\t\tForm->postLink(__('Delete'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), array(), __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; + echo "\t\t\tForm->postLink(__('Delete'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), array('confirm' => __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; echo "\t\t\n"; echo "\t\n"; From 831fe53f793e13fbef42633ed85ee6da5a3ba928 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 22 Feb 2015 22:39:38 -0500 Subject: [PATCH 096/336] Ignore LC_TIME category when extracting messages. Given that we use the specific LC_TIME file format, it doesn't make much sense to extract translated strings into a PO file that cannot be used later on. Refs #5933 --- lib/Cake/Console/Command/Task/ExtractTask.php | 6 +++++- .../Console/Command/Task/ExtractTaskTest.php | 16 ++++++++++------ lib/Cake/Test/test_app/View/Pages/extract.ctp | 2 ++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ExtractTask.php b/lib/Cake/Console/Command/Task/ExtractTask.php index 57064917050..c9f5712cc93 100644 --- a/lib/Cake/Console/Command/Task/ExtractTask.php +++ b/lib/Cake/Console/Command/Task/ExtractTask.php @@ -432,6 +432,7 @@ protected function _parse($functionName, $map) { $category = isset($category) ? $category : 6; $category = (int)$category; $categoryName = $categories[$category]; + $domain = isset($domain) ? $domain : 'default'; $details = array( 'file' => $this->_file, @@ -443,7 +444,10 @@ protected function _parse($functionName, $map) { if (isset($context)) { $details['msgctxt'] = $context; } - $this->_addTranslation($categoryName, $domain, $singular, $details); + // Skip LC_TIME files as we use a special file format for them. + if ($categoryName !== 'LC_TIME') { + $this->_addTranslation($categoryName, $domain, $singular, $details); + } } else { $this->_markerError($this->_file, $line, $functionName, $count); } diff --git a/lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php index 238803acf74..363afb2ffe4 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php @@ -162,19 +162,19 @@ public function testExecute() { $this->assertContains('msgid "double \\"quoted\\""', $result, 'Strings with quotes not handled correctly'); $this->assertContains("msgid \"single 'quoted'\"", $result, 'Strings with quotes not handled correctly'); - $pattern = '/\#: (\\\\|\/)extract\.ctp:34\nmsgid "letter"/'; + $pattern = '/\#: (\\\\|\/)extract\.ctp:36\nmsgid "letter"/'; $this->assertRegExp($pattern, $result, 'Strings with context should not overwrite strings without context'); - $pattern = '/\#: (\\\\|\/)extract\.ctp:35;37\nmsgctxt "A"\nmsgid "letter"/'; + $pattern = '/\#: (\\\\|\/)extract\.ctp:37;39\nmsgctxt "A"\nmsgid "letter"/'; $this->assertRegExp($pattern, $result, 'Should contain string with context "A"'); - $pattern = '/\#: (\\\\|\/)extract\.ctp:36\nmsgctxt "B"\nmsgid "letter"/'; + $pattern = '/\#: (\\\\|\/)extract\.ctp:38\nmsgctxt "B"\nmsgid "letter"/'; $this->assertRegExp($pattern, $result, 'Should contain string with context "B"'); - $pattern = '/\#: (\\\\|\/)extract\.ctp:38\nmsgid "%d letter"\nmsgid_plural "%d letters"/'; + $pattern = '/\#: (\\\\|\/)extract\.ctp:40\nmsgid "%d letter"\nmsgid_plural "%d letters"/'; $this->assertRegExp($pattern, $result, 'Plural strings with context should not overwrite strings without context'); - $pattern = '/\#: (\\\\|\/)extract\.ctp:39\nmsgctxt "A"\nmsgid "%d letter"\nmsgid_plural "%d letters"/'; + $pattern = '/\#: (\\\\|\/)extract\.ctp:41\nmsgctxt "A"\nmsgid "%d letter"\nmsgid_plural "%d letters"/'; $this->assertRegExp($pattern, $result, 'Should contain plural string with context "A"'); // extract.ctp - reading the domain.pot @@ -209,12 +209,16 @@ public function testExtractCategory() { $this->Task->expects($this->never())->method('_stop'); $this->Task->execute(); - $this->assertTrue(file_exists($this->path . DS . 'LC_TIME' . DS . 'default.pot')); + $this->assertTrue(file_exists($this->path . DS . 'LC_NUMERIC' . DS . 'default.pot')); + $this->assertFalse(file_exists($this->path . DS . 'LC_TIME' . DS . 'default.pot')); $result = file_get_contents($this->path . DS . 'default.pot'); $pattern = '/\#: .*extract\.ctp:31\n/'; $this->assertNotRegExp($pattern, $result); + + $pattern = '/\#: .*extract\.ctp:33\n/'; + $this->assertNotRegExp($pattern, $result); } /** diff --git a/lib/Cake/Test/test_app/View/Pages/extract.ctp b/lib/Cake/Test/test_app/View/Pages/extract.ctp index 3331f2fd4da..63e8c73a573 100644 --- a/lib/Cake/Test/test_app/View/Pages/extract.ctp +++ b/lib/Cake/Test/test_app/View/Pages/extract.ctp @@ -28,6 +28,8 @@ __('Hot features!' . ' Join us #cakephp on IRC. We\'d love to help you get started'); // Category +echo __c('You have a new message (category: LC_NUMERIC).', 4); +// LC_TIME is skipped. echo __c('You have a new message (category: LC_TIME).', 5); // Context From 5342605d9200bc04b3acc43292221b108163ca35 Mon Sep 17 00:00:00 2001 From: AD7six Date: Mon, 23 Feb 2015 15:21:39 +0000 Subject: [PATCH 097/336] The parentheses were unbalanced --- lib/Cake/Console/Templates/default/views/index.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Console/Templates/default/views/index.ctp b/lib/Cake/Console/Templates/default/views/index.ctp index 28d5bcc60e2..375edc6826a 100644 --- a/lib/Cake/Console/Templates/default/views/index.ctp +++ b/lib/Cake/Console/Templates/default/views/index.ctp @@ -48,7 +48,7 @@ echo "\t\t\n"; echo "\t\t\tHtml->link(__('View'), array('action' => 'view', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; echo "\t\t\tHtml->link(__('Edit'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; - echo "\t\t\tForm->postLink(__('Delete'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), array('confirm' => __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; + echo "\t\t\tForm->postLink(__('Delete'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), array('confirm' => __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}']))); ?>\n"; echo "\t\t\n"; echo "\t\n"; From b151295f1b63a41fdd462d7cd130073fa4d02e7a Mon Sep 17 00:00:00 2001 From: AD7six Date: Mon, 23 Feb 2015 16:45:02 +0000 Subject: [PATCH 098/336] Add a better test for the index being correct --- .../Console/Command/Task/ViewTaskTest.php | 4 +- lib/Cake/Test/bake_compare/View/index.ctp | 58 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 lib/Cake/Test/bake_compare/View/index.ctp diff --git a/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php index 6b02d12bac4..086a2b8b838 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php @@ -323,12 +323,14 @@ public function testBakeEdit() { public function testBakeIndex() { $this->Task->controllerName = 'ViewTaskComments'; + $expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'View' . DS . 'index.ctp'); $this->Task->expects($this->at(0))->method('createFile') ->with( TMP . 'ViewTaskComments' . DS . 'index.ctp', - $this->stringContains("\$viewTaskComment['Article']['title']") + $expected ); $this->Task->bake('index', true); + } /** diff --git a/lib/Cake/Test/bake_compare/View/index.ctp b/lib/Cake/Test/bake_compare/View/index.ctp new file mode 100644 index 00000000000..d7bb6898294 --- /dev/null +++ b/lib/Cake/Test/bake_compare/View/index.ctp @@ -0,0 +1,58 @@ +
+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Paginator->sort('id'); ?>Paginator->sort('article_id'); ?>Paginator->sort('user_id'); ?>Paginator->sort('comment'); ?>Paginator->sort('published'); ?>Paginator->sort('created'); ?>Paginator->sort('updated'); ?>
  + Html->link($viewTaskComment['Article']['title'], array('controller' => 'view_task_articles', 'action' => 'view', $viewTaskComment['Article']['id'])); ?> +       + Html->link(__('View'), array('action' => 'view', $viewTaskComment['ViewTaskComment']['id'])); ?> + Html->link(__('Edit'), array('action' => 'edit', $viewTaskComment['ViewTaskComment']['id'])); ?> + Form->postLink(__('Delete'), array('action' => 'delete', $viewTaskComment['ViewTaskComment']['id']), array('confirm' => __('Are you sure you want to delete # %s?', $viewTaskComment['ViewTaskComment']['id']))); ?> +
+

+ Paginator->counter(array( + 'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}') + )); + ?>

+
+ Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled')); + echo $this->Paginator->numbers(array('separator' => '')); + echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled')); + ?> +
+
+
+

+
    +
  • Html->link(__('New View Task Comment'), array('action' => 'add')); ?>
  • +
  • Html->link(__('List View Task Articles'), array('controller' => 'view_task_articles', 'action' => 'index')); ?>
  • +
  • Html->link(__('New Article'), array('controller' => 'view_task_articles', 'action' => 'add')); ?>
  • +
+
From 5066bc33b4a06333ba1325f047115fa33f5995c2 Mon Sep 17 00:00:00 2001 From: AD7six Date: Mon, 23 Feb 2015 16:46:43 +0000 Subject: [PATCH 099/336] Fix whitespace for paginator counter call --- lib/Cake/Console/Templates/default/views/index.ctp | 2 +- lib/Cake/Test/bake_compare/View/index.ctp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Console/Templates/default/views/index.ctp b/lib/Cake/Console/Templates/default/views/index.ctp index 375edc6826a..cf77c0ed9a7 100644 --- a/lib/Cake/Console/Templates/default/views/index.ctp +++ b/lib/Cake/Console/Templates/default/views/index.ctp @@ -59,7 +59,7 @@

Paginator->counter(array( - 'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}') + 'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}') )); ?>"; ?>

diff --git a/lib/Cake/Test/bake_compare/View/index.ctp b/lib/Cake/Test/bake_compare/View/index.ctp index d7bb6898294..b2738e4b3bc 100644 --- a/lib/Cake/Test/bake_compare/View/index.ctp +++ b/lib/Cake/Test/bake_compare/View/index.ctp @@ -37,7 +37,7 @@

Paginator->counter(array( - 'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}') + 'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}') )); ?>

From d7d2516dc1b1e724607b7cb01b113bdc487a35b8 Mon Sep 17 00:00:00 2001 From: AD7six Date: Mon, 23 Feb 2015 17:22:55 +0000 Subject: [PATCH 100/336] Remove unwanted whitespace --- lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php index 086a2b8b838..c5ab4762f84 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php @@ -330,7 +330,6 @@ public function testBakeIndex() { $expected ); $this->Task->bake('index', true); - } /** From b80a8947d7f2cc0396a256ecc711b10961b4f8ae Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 23 Feb 2015 21:37:49 -0500 Subject: [PATCH 101/336] Check line length to account for fence post. When we have exactly 998 bytes CakeEmail should not emit an error. Refs #5948 --- lib/Cake/Network/Email/CakeEmail.php | 2 +- .../Test/Case/Network/Email/CakeEmailTest.php | 19 +++++++++++++++++++ .../test_app/View/Emails/html/long_line.ctp | 14 ++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 lib/Cake/Test/test_app/View/Emails/html/long_line.ctp diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index 4cae10499fb..b9d557cf3fe 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -1421,7 +1421,7 @@ protected function _wrap($message, $wrapLength = CakeEmail::LINE_LENGTH_MUST) { $tmpLine .= $char; $tmpLineLength++; if ($tmpLineLength === $wrapLength) { - $nextChar = $line[$i + 1]; + $nextChar = isset($line[$i + 1]) ? $line[$i + 1] : ''; if ($nextChar === ' ' || $nextChar === '<') { $formatted[] = trim($tmpLine); $tmpLine = ''; diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index 1dc125fead6..c6bed1d73a9 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -2435,6 +2435,25 @@ public function testZeroOnlyLinesNotBeingEmptied() { $this->assertEquals($expected, $result['message']); } +/** + * Test that really long lines don't cause errors. + * + * @return void + */ + public function testReallyLongLine() { + $this->CakeEmail->reset(); + $this->CakeEmail->config(array('empty')); + $this->CakeEmail->transport('Debug'); + $this->CakeEmail->from('cake@cakephp.org'); + $this->CakeEmail->to('cake@cakephp.org'); + $this->CakeEmail->subject('Wordwrap Test'); + $this->CakeEmail->emailFormat('html'); + $this->CakeEmail->template('long_line', null); + $result = $this->CakeEmail->send(); + $this->assertContains('', $result['message'], 'First bits are included'); + $this->assertContains('x', $result['message'], 'Last byte are included'); + } + /** * CakeEmailTest::assertLineLengths() * diff --git a/lib/Cake/Test/test_app/View/Emails/html/long_line.ctp b/lib/Cake/Test/test_app/View/Emails/html/long_line.ctp new file mode 100644 index 00000000000..4bf8bbdab53 --- /dev/null +++ b/lib/Cake/Test/test_app/View/Emails/html/long_line.ctp @@ -0,0 +1,14 @@ +34567890123456789012345678901234567890123456789012345678901234567890' . +'12345678901234567890123456789012345678901234567890123456789012345678901234567890' . +'12345678901234567890123456789012345678901234567890123456789012345678901234567890' . +'12345678901234567890123456789012345678901234567890123456789012345678901234567890' . +'12345678901234567890123456789012345678901234567890123456789012345678901234567890' . +'12345678901234567890123456789012345678901234567890123456789012345678901234567890' . +'12345678901234567890123456789012345678901234567890123456789012345678901234567890' . +'12345678901234567890123456789012345678901234567890123456789012345678901234567890' . +'12345678901234567890123456789012345678901234567890123456789012345678901234567890' . +'12345678901234567890123456789012345678901234567890123456789012345678901234567890' . +'12345678901234567890123456789012345678901234567890123456789012345678901234567890' . +'12345678901234567890123456789012345678901234567890123456789012345678901234567890' . +'1234567890123456789012345678901234567890123456x'; From ea79cf5d137fb3c78bdc3009256764c2849caea5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 25 Feb 2015 20:52:35 -0500 Subject: [PATCH 102/336] Fix words with WWW in them being autolinked. Don't autolink words that don't have `www.` in them. Fixes #5968 --- lib/Cake/Test/Case/View/Helper/TextHelperTest.php | 4 ++++ lib/Cake/View/Helper/TextHelper.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/View/Helper/TextHelperTest.php b/lib/Cake/Test/Case/View/Helper/TextHelperTest.php index 87d81b14a0a..a38fa38f188 100644 --- a/lib/Cake/Test/Case/View/Helper/TextHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/TextHelperTest.php @@ -117,6 +117,10 @@ public function testEngineOverride() { * @return void */ public function testAutoLink() { + $text = 'The AWWWARD show happened today'; + $result = $this->Text->autoLink($text); + $this->assertEquals($text, $result); + $text = 'This is a test text'; $expected = 'This is a test text'; $result = $this->Text->autoLink($text); diff --git a/lib/Cake/View/Helper/TextHelper.php b/lib/Cake/View/Helper/TextHelper.php index 2a2a536b49d..753434cc51f 100644 --- a/lib/Cake/View/Helper/TextHelper.php +++ b/lib/Cake/View/Helper/TextHelper.php @@ -114,7 +114,7 @@ public function autoLinkUrls($text, $options = array()) { $text ); $text = preg_replace_callback( - '#(?)(?)(? Date: Wed, 25 Feb 2015 21:34:15 -0500 Subject: [PATCH 103/336] Allow numeric sorts in PaginatorComponent. When paginating data, we should not ignore numerically indexed order conditions. Instead they should be handled similar to Model::find(). This creates a slightly different behavior when model's have default sorting applied as more default sort options forms will be honoured. Refs #5964 --- .../Controller/Component/PaginatorComponent.php | 4 ++++ .../Component/PaginatorComponentTest.php | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Controller/Component/PaginatorComponent.php b/lib/Cake/Controller/Component/PaginatorComponent.php index 94a6065521c..e0203acef0d 100644 --- a/lib/Cake/Controller/Component/PaginatorComponent.php +++ b/lib/Cake/Controller/Component/PaginatorComponent.php @@ -388,6 +388,10 @@ public function validateSort(Model $object, array $options, array $whitelist = a if (!empty($options['order']) && is_array($options['order'])) { $order = array(); foreach ($options['order'] as $key => $value) { + if (is_int($key)) { + $key = $value; + $value = 'asc'; + } $field = $key; $alias = $object->alias; if (strpos($key, '.') !== false) { diff --git a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php index 5fa098314e9..4ce1ffe9972 100644 --- a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php @@ -454,6 +454,13 @@ public function testPaginateExtraParams() { $this->assertEquals(array(1, 2, 3), Hash::extract($result, '{n}.PaginatorControllerPost.id')); $this->assertTrue(!isset($Controller->PaginatorControllerPost->lastQueries[1]['contain'])); + $Controller->Paginator->settings = array( + 'order' => array('PaginatorControllerPost.author_id') + ); + $result = $Controller->Paginator->paginate('PaginatorControllerPost'); + $this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']); + $this->assertEquals(array(1, 3, 2), Hash::extract($result, '{n}.PaginatorControllerPost.id')); + $Controller->request->params['named'] = array('page' => '-1'); $Controller->Paginator->settings = array( 'PaginatorControllerPost' => array( @@ -606,7 +613,7 @@ public function testPaginateOrderModelDefault() { $Controller->PaginatorControllerPost->order = array('PaginatorControllerPost.id'); $result = $Controller->Paginator->validateSort($Controller->PaginatorControllerPost, array()); - $this->assertEmpty($result['order']); + $this->assertEquals(array('PaginatorControllerPost.id' => 'asc'), $result['order']); $Controller->PaginatorControllerPost->order = 'PaginatorControllerPost.id'; $result = $Controller->Paginator->validateSort($Controller->PaginatorControllerPost, array()); @@ -617,7 +624,10 @@ public function testPaginateOrderModelDefault() { 'PaginatorControllerPost.created' => 'asc' ); $result = $Controller->Paginator->validateSort($Controller->PaginatorControllerPost, array()); - $expected = array('PaginatorControllerPost.created' => 'asc'); + $expected = array( + 'PaginatorControllerPost.id' => 'asc', + 'PaginatorControllerPost.created' => 'asc' + ); $this->assertEquals($expected, $result['order']); } From aec0241a4cbad40ff80f4de46aeff679cddac7b5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 26 Feb 2015 12:49:04 -0500 Subject: [PATCH 104/336] Make global paths for vendors and plugins based on ROOT. Using CAKE means that composer installed CakePHP will generate incorrect 'global' paths. Refs #5838 --- lib/Cake/Core/App.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index ff8fe4c9e3f..dd72b9048e7 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -874,11 +874,11 @@ protected static function _packageFormat() { ), 'Vendor' => array( '%s' . 'Vendor' . DS, - dirname(dirname(CAKE)) . DS . 'vendors' . DS, + ROOT . DS . 'vendors' . DS, ), 'Plugin' => array( APP . 'Plugin' . DS, - dirname(dirname(CAKE)) . DS . 'plugins' . DS + ROOT . DS . 'plugins' . DS ) ); } From a7c2f26599e57d24b4294f5464014eaff5c71e1c Mon Sep 17 00:00:00 2001 From: KullTC Date: Fri, 27 Feb 2015 15:25:23 +0100 Subject: [PATCH 105/336] Make sure default datasource is not used for mock When a non-default datasource is used for a model and no test_ version of that datasource is available, the getMockForModel method used the models standard datasource, rahter than 'test'. --- lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php | 2 +- lib/Cake/TestSuite/CakeTestCase.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php b/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php index d6c4fc1f05a..d5cee102e06 100644 --- a/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php +++ b/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php @@ -414,7 +414,7 @@ public function testGetMockForModel() { ) ), App::RESET); $Post = $this->getMockForModel('Post'); - + $this->assertEquals('test', $Post->useDbConfig); $this->assertInstanceOf('Post', $Post); $this->assertNull($Post->save(array())); $this->assertNull($Post->find('all')); diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index e457a033b51..491a0f0aaaf 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -732,12 +732,12 @@ public function getMockForModel($model, $methods = array(), $config = array()) { $mock = $this->getMock($name, $methods, array($config)); $availableDs = array_keys(ConnectionManager::enumConnectionObjects()); - if ($mock->useDbConfig === 'default') { - $mock->useDbConfig = null; - $mock->setDataSource('test'); - } + if ($mock->useDbConfig !== 'test' && in_array('test_' . $mock->useDbConfig, $availableDs)) { $mock->setDataSource('test_' . $mock->useDbConfig); + } else { + $mock->useDbConfig = 'test'; + $mock->setDataSource('test'); } ClassRegistry::removeObject($name); From 8dba9879d4c84e434adf4282c68379c2bf07b200 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 27 Feb 2015 21:08:54 -0500 Subject: [PATCH 106/336] Don't generate maxlength properties for decimal columns. Int casting the decimal scale isn't going to work in a number of situations as users may end up trying to include decimal points, commas or spaces in larger amounts. Fixes #5977 --- lib/Cake/Test/Case/View/Helper/FormHelperTest.php | 1 - lib/Cake/View/Helper/FormHelper.php | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 0a4e8f004df..30d25eacccf 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -782,7 +782,6 @@ public function testTextFieldGenerationForDecimalAsText() { 'type' => 'text', 'name' => 'data[ValidateUser][cost_decimal]', 'id' => 'ValidateUserCostDecimal', - 'maxlength' => 6, )), '/div' ); diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 21e86e93d97..22fb6551da7 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -1287,6 +1287,7 @@ protected function _maxLength($options) { isset($fieldDef['length']) && is_scalar($fieldDef['length']) && $fieldDef['length'] < 1000000 && + $fieldDef['type'] !== 'decimal' && $options['type'] !== 'select' ); if ($autoLength && From 02c9dda9a7740c871ee33aa035953215e0da1e32 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 27 Feb 2015 22:35:52 -0500 Subject: [PATCH 107/336] Make maxLimit and limit settings independent. Having maxLimit infer what it should be based on limit was not a very transparent default behavior. The documentation states that maxLimit will default to 100, but the code would default it to 'limit' if set. This created confusing behavior when only one setting was defined. Refs #5973 --- .../Controller/Component/PaginatorComponent.php | 14 ++++++-------- .../Component/PaginatorComponentTest.php | 4 ++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/Cake/Controller/Component/PaginatorComponent.php b/lib/Cake/Controller/Component/PaginatorComponent.php index e0203acef0d..6e34fa6d784 100644 --- a/lib/Cake/Controller/Component/PaginatorComponent.php +++ b/lib/Cake/Controller/Component/PaginatorComponent.php @@ -333,15 +333,13 @@ public function getDefaults($alias) { if (isset($this->settings[$alias])) { $defaults = $this->settings[$alias]; } - if (isset($defaults['limit']) && - (empty($defaults['maxLimit']) || $defaults['limit'] > $defaults['maxLimit']) - ) { - $defaults['maxLimit'] = $defaults['limit']; - } - return array_merge( - array('page' => 1, 'limit' => 20, 'maxLimit' => 100, 'paramType' => 'named'), - $defaults + $defaults += array( + 'page' => 1, + 'limit' => 20, + 'maxLimit' => 100, + 'paramType' => 'named' ); + return $defaults; } /** diff --git a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php index 4ce1ffe9972..234d2dac3b8 100644 --- a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php @@ -853,7 +853,7 @@ public function testMergeOptionsMaxLimit() { 'paramType' => 'named', ); $result = $this->Paginator->mergeOptions('Post'); - $expected = array('page' => 1, 'limit' => 200, 'maxLimit' => 200, 'paramType' => 'named'); + $expected = array('page' => 1, 'limit' => 200, 'maxLimit' => 100, 'paramType' => 'named'); $this->assertEquals($expected, $result); $this->Paginator->settings = array( @@ -872,7 +872,7 @@ public function testMergeOptionsMaxLimit() { 'paramType' => 'named', ); $result = $this->Paginator->mergeOptions('Post'); - $expected = array('page' => 1, 'limit' => 500, 'maxLimit' => 150, 'paramType' => 'named'); + $expected = array('page' => 1, 'limit' => 500, 'maxLimit' => 100, 'paramType' => 'named'); $this->assertEquals($expected, $result); } From ed5da19d10ab2bd06deb12d3b98ea8dca17f8507 Mon Sep 17 00:00:00 2001 From: Mark van Driel Date: Mon, 2 Mar 2015 12:08:11 +0100 Subject: [PATCH 108/336] Fixed return type of toQuarter in CakeTime and TimeHelper --- lib/Cake/Test/Case/Utility/CakeTimeTest.php | 6 +++--- lib/Cake/Utility/CakeTime.php | 4 ++-- lib/Cake/View/Helper/TimeHelper.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/CakeTimeTest.php b/lib/Cake/Test/Case/Utility/CakeTimeTest.php index a76ffb6b07b..54fcc789bd1 100644 --- a/lib/Cake/Test/Case/Utility/CakeTimeTest.php +++ b/lib/Cake/Test/Case/Utility/CakeTimeTest.php @@ -72,13 +72,13 @@ protected function _restoreSystemTimezone() { */ public function testToQuarter() { $result = $this->Time->toQuarter('2007-12-25'); - $this->assertEquals(4, $result); + $this->assertSame(4, $result); $result = $this->Time->toQuarter('2007-9-25'); - $this->assertEquals(3, $result); + $this->assertSame(3, $result); $result = $this->Time->toQuarter('2007-3-25'); - $this->assertEquals(1, $result); + $this->assertSame(1, $result); $result = $this->Time->toQuarter('2007-3-25', true); $this->assertEquals(array('2007-01-01', '2007-03-31'), $result); diff --git a/lib/Cake/Utility/CakeTime.php b/lib/Cake/Utility/CakeTime.php index 38c22196a33..b22082320b7 100644 --- a/lib/Cake/Utility/CakeTime.php +++ b/lib/Cake/Utility/CakeTime.php @@ -575,12 +575,12 @@ public static function isTomorrow($dateString, $timezone = null) { * * @param int|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object * @param bool $range if true returns a range in Y-m-d format - * @return mixed 1, 2, 3, or 4 quarter of year or array if $range true + * @return int|array 1, 2, 3, or 4 quarter of year or array if $range true * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::toQuarter */ public static function toQuarter($dateString, $range = false) { $time = self::fromString($dateString); - $date = ceil(date('m', $time) / 3); + $date = (int)ceil(date('m', $time) / 3); if ($range === false) { return $date; } diff --git a/lib/Cake/View/Helper/TimeHelper.php b/lib/Cake/View/Helper/TimeHelper.php index 45ce699bdfc..5e91705bd93 100644 --- a/lib/Cake/View/Helper/TimeHelper.php +++ b/lib/Cake/View/Helper/TimeHelper.php @@ -316,7 +316,7 @@ public function isTomorrow($dateString, $timezone = null) { * * @param int|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object * @param bool $range if true returns a range in Y-m-d format - * @return mixed 1, 2, 3, or 4 quarter of year or array if $range true + * @return int|array 1, 2, 3, or 4 quarter of year or array if $range true * @see CakeTime::toQuarter() * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting */ From a1286e9e7d9c3f653ede9c9c253508db85346c34 Mon Sep 17 00:00:00 2001 From: ADmad Date: Wed, 4 Mar 2015 21:11:18 +0530 Subject: [PATCH 109/336] Prefix fields with model alias --- lib/Cake/Model/Behavior/TreeBehavior.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index bb3d81ba7cd..af12fe6b644 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -132,8 +132,8 @@ protected function _setChildrenLevel($Model, $id) { $depths[$node[$Model->alias][$primaryKey]] = $depth; $Model->updateAll( - array($settings['level'] => $depth), - array($primaryKey => $node[$Model->alias][$primaryKey]) + array($Model->escapeField($settings['level']) => $depth), + array($Model->escapeField($primaryKey) => $node[$Model->alias][$primaryKey]) ); } } From 7173f21dc8fdf793f8eb69d82db424486aef86a2 Mon Sep 17 00:00:00 2001 From: ADmad Date: Wed, 4 Mar 2015 21:15:24 +0530 Subject: [PATCH 110/336] Type hint model param --- lib/Cake/Model/Behavior/TreeBehavior.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index af12fe6b644..e982c9796b1 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -111,7 +111,7 @@ public function afterSave(Model $Model, $created, $options = array()) { * @param int|string $id Record ID * @return void */ - protected function _setChildrenLevel($Model, $id) { + protected function _setChildrenLevel(Model $Model, $id) { $settings = $Model->Behaviors->Tree->settings[$Model->alias]; $primaryKey = $Model->primaryKey; $depths = array($id => (int)$Model->data[$Model->alias][$settings['level']]); From 0dca5c8877449fb7d86352bab7a0f634ffa2d311 Mon Sep 17 00:00:00 2001 From: Chris Valliere Date: Fri, 6 Mar 2015 13:41:40 -0500 Subject: [PATCH 111/336] Using App::uses('CakeLog', 'Log') twice I think this was accidentally added twice? --- lib/Cake/Core/Object.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Cake/Core/Object.php b/lib/Cake/Core/Object.php index 1c754375088..59ec9e3efb5 100644 --- a/lib/Cake/Core/Object.php +++ b/lib/Cake/Core/Object.php @@ -18,7 +18,6 @@ App::uses('Dispatcher', 'Routing'); App::uses('Router', 'Routing'); App::uses('Set', 'Utility'); -App::uses('CakeLog', 'Log'); /** * Object class provides a few generic methods used in several subclasses. From a9519d39f7dbe5d26808868533fae1617978d2a2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 8 Mar 2015 13:51:46 -0400 Subject: [PATCH 112/336] Fix whitelist being empty during afterSave. whitelist should only be reset after afterSave event. Refs #6028 --- lib/Cake/Model/Model.php | 4 +-- lib/Cake/Test/Case/Model/ModelWriteTest.php | 32 +++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 72d4361b73a..0bdbf2cab55 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -1941,9 +1941,8 @@ protected function _doSave($data = null, $options = array()) { $this->_saveMulti($joined, $this->id, $db); } - $this->whitelist = $_whitelist; - if (!$success) { + $this->whitelist = $_whitelist; return $success; } @@ -1964,6 +1963,7 @@ protected function _doSave($data = null, $options = array()) { $this->_clearCache(); $this->validationErrors = array(); + $this->whitelist = $_whitelist; $this->data = false; return $success; diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index 529d62902ec..c0349ed4890 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -387,6 +387,38 @@ public function testSaveFieldListResetsWhitelistOnFailedSave() { $this->assertEquals($whitelist, $model->whitelist); } +/** + * Test save() resets the whitelist after afterSave + * + * @return void + */ + public function testSaveResetWhitelistOnSuccess() { + $this->loadFixtures('Post'); + + $callback = array($this, 'callbackForWhitelistReset'); + $model = ClassRegistry::init('Post'); + $model->whitelist = array('author_id', 'title', 'body'); + $model->getEventManager()->attach($callback, 'Model.afterSave'); + $data = array( + 'title' => 'New post', + 'body' => 'Post body', + 'author_id' => 1 + ); + $result = $model->save($data); + $this->assertNotEmpty($result); + } + +/** + * Callback for testing whitelist in afterSave + * + * @param Model $model The model having save called. + * @return void + */ + public function callbackForWhitelistReset($event) { + $expected = array('author_id', 'title', 'body', 'updated', 'created'); + $this->assertEquals($expected, $event->subject()->whitelist); + } + /** * testSaveWithCounterCache method * From cad57dcc28ed9996b52e681ae06d62bc7b5c79c0 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 9 Mar 2015 21:55:07 -0400 Subject: [PATCH 113/336] Use DS instead of checking both slash styles. Refs #5905 --- 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 26bfb83be19..6c8bc2a7ec6 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -1336,7 +1336,7 @@ public function file($path, $options = array()) { 'download' => null ); - if (strpos($path, '../') !== false || strpos($path, '..\\') !== false) { + if (strpos($path, '..' . DS) !== false) { throw new NotFoundException(__d( 'cake_dev', 'The requested file contains `..` and will not be read.' From 4f9d764fc2b8a730e79d86c4a3930a3ad0e2d5e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Wed, 11 Mar 2015 11:27:30 +0100 Subject: [PATCH 114/336] Fixed link to cookbook --- lib/Cake/Model/Model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 0bdbf2cab55..c46f81160f9 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -2652,7 +2652,7 @@ public function validateAssociated(&$data, $options = array()) { * Fields are treated as SQL snippets, to insert literal values manually escape your data. * @param mixed $conditions Conditions to match, true for all records * @return bool True on success, false on failure - * @link http://book.cakephp.org/2.0/en/models/saving-your-data.html#model-updateall-array-fields-array-conditions + * @link http://book.cakephp.org/2.0/en/models/saving-your-data.html#model-updateall-array-fields-mixed-conditions */ public function updateAll($fields, $conditions = true) { return $this->getDataSource()->update($this, $fields, null, $conditions); From 24edae5792d457ff06bf3455bd9d359c99727351 Mon Sep 17 00:00:00 2001 From: David Yell Date: Thu, 12 Mar 2015 15:26:59 +0000 Subject: [PATCH 115/336] Update App.php Add a missing apostrophe --- lib/Cake/Core/App.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index dd72b9048e7..361d36e42d0 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -259,7 +259,7 @@ public static function paths() { * * Usage: * - * `App::build(array(Model' => array('/a/full/path/to/models/'))); will setup a new search path for the Model package` + * `App::build(array('Model' => array('/a/full/path/to/models/'))); will setup a new search path for the Model package` * * `App::build(array('Model' => array('/path/to/models/')), App::RESET); will setup the path as the only valid path for searching models` * From 8e735c2db0a6148bc650d0cd73f93c9dd1aa5ed8 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 12 Mar 2015 21:59:38 -0400 Subject: [PATCH 116/336] Fix class name in scaffold error. Fixes #6061 --- lib/Cake/Controller/Scaffold.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Controller/Scaffold.php b/lib/Cake/Controller/Scaffold.php index 459b87fd87c..af6f6a969db 100644 --- a/lib/Cake/Controller/Scaffold.php +++ b/lib/Cake/Controller/Scaffold.php @@ -399,7 +399,7 @@ protected function _scaffold(CakeRequest $request) { } } else { throw new MissingActionException(array( - 'controller' => $this->controller->name, + 'controller' => get_class($this->controller), 'action' => $request->action )); } From 05aba7afb6190c04bad9201655bacf6e06509b9b Mon Sep 17 00:00:00 2001 From: Rob McVey Date: Fri, 13 Mar 2015 15:52:22 +0000 Subject: [PATCH 117/336] Assert CakeException throw when json_encode fails --- lib/Cake/Test/Case/View/JsonViewTest.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/Cake/Test/Case/View/JsonViewTest.php b/lib/Cake/Test/Case/View/JsonViewTest.php index 5a661c78bad..5fc9ff08873 100644 --- a/lib/Cake/Test/Case/View/JsonViewTest.php +++ b/lib/Cake/Test/Case/View/JsonViewTest.php @@ -306,4 +306,25 @@ public function testRenderWithViewAndNamed() { $this->assertSame($expected, $output); $this->assertSame('application/javascript', $Response->type()); } + +/** + * JsonViewTest::testRenderInvalidJSON() + * + * @expectedException CakeException + * @return void + */ + public function testRenderInvalidJSON() { + $Request = new CakeRequest(); + $Response = new CakeResponse(); + $Controller = new Controller($Request, $Response); + + // non utf-8 stuff + $data = array('data' => array('foo' => 'bar' . chr('0x97'))); + + $Controller->set($data); + $Controller->set('_serialize', 'data'); + $View = new JsonView($Controller); + $output = $View->render(); + } + } From 08620704bef31dc9baeda4d0eec4d16a461f2999 Mon Sep 17 00:00:00 2001 From: Rob McVey Date: Fri, 13 Mar 2015 16:12:21 +0000 Subject: [PATCH 118/336] Handle json_encode failure --- lib/Cake/Test/Case/View/JsonViewTest.php | 20 ++++++++++++++++++++ lib/Cake/View/JsonView.php | 20 ++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/View/JsonViewTest.php b/lib/Cake/Test/Case/View/JsonViewTest.php index 5fc9ff08873..ed974c0d94c 100644 --- a/lib/Cake/Test/Case/View/JsonViewTest.php +++ b/lib/Cake/Test/Case/View/JsonViewTest.php @@ -326,5 +326,25 @@ public function testRenderInvalidJSON() { $View = new JsonView($Controller); $output = $View->render(); } + +/** + * JsonViewTest::testRenderJSONBoolFalse() + * + * @return void + */ + public function testRenderJSONBoolFalse() { + $Request = new CakeRequest(); + $Response = new CakeResponse(); + $Controller = new Controller($Request, $Response); + + // non utf-8 stuff + $data = false; + + $Controller->set($data); + $Controller->set('_serialize', 'data'); + $View = new JsonView($Controller); + $output = $View->render(); + $this->assertSame('null', $output); + } } diff --git a/lib/Cake/View/JsonView.php b/lib/Cake/View/JsonView.php index 2f184139dab..eb8eb911460 100644 --- a/lib/Cake/View/JsonView.php +++ b/lib/Cake/View/JsonView.php @@ -124,6 +124,10 @@ public function render($view = null, $layout = null) { /** * Serialize view vars + * For JSON documents, any errors are output using; + * PHP 5 >= 5.5.0 : json_last_error_msg() + * PHP 5 >= 5.3.0 : json_last_error() + * PHP 5 <= 5.2.9 : Generic fall back error * * @param array $serialize The viewVars that need to be serialized * @return string The serialized data @@ -145,10 +149,22 @@ protected function _serialize($serialize) { } if (version_compare(PHP_VERSION, '5.4.0', '>=') && Configure::read('debug')) { - return json_encode($data, JSON_PRETTY_PRINT); + $json = json_encode($data, JSON_PRETTY_PRINT); + } else { + $json = json_encode($data); } - return json_encode($data); + if (function_exists('json_last_error') && json_last_error() !== JSON_ERROR_NONE) { + if (function_exists('json_last_error_msg')) { + $error = json_last_error_msg(); + } else { + $error = __('JSON encoding failed: Error code %s', json_last_error()); + } + throw new CakeException($error); + } else if ($json === false) { + throw new CakeException(__('Failed to parse JSON')); + } + return $json; } } From ddfcb06d023f7596816c35452f655f6e05eca599 Mon Sep 17 00:00:00 2001 From: Rob McVey Date: Fri, 13 Mar 2015 16:13:29 +0000 Subject: [PATCH 119/336] Coding standards --- lib/Cake/Test/Case/View/JsonViewTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/View/JsonViewTest.php b/lib/Cake/Test/Case/View/JsonViewTest.php index ed974c0d94c..cd9d6728ac1 100644 --- a/lib/Cake/Test/Case/View/JsonViewTest.php +++ b/lib/Cake/Test/Case/View/JsonViewTest.php @@ -345,6 +345,6 @@ public function testRenderJSONBoolFalse() { $View = new JsonView($Controller); $output = $View->render(); $this->assertSame('null', $output); - } - + } + } From 2ba9f3b8fb906d1d392e6ca11b09df32003a39c2 Mon Sep 17 00:00:00 2001 From: Rob McVey Date: Fri, 13 Mar 2015 16:21:54 +0000 Subject: [PATCH 120/336] Encoding false is OK - should return string null --- lib/Cake/Test/Case/View/JsonViewTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/View/JsonViewTest.php b/lib/Cake/Test/Case/View/JsonViewTest.php index cd9d6728ac1..11a11f994a8 100644 --- a/lib/Cake/Test/Case/View/JsonViewTest.php +++ b/lib/Cake/Test/Case/View/JsonViewTest.php @@ -337,7 +337,7 @@ public function testRenderJSONBoolFalse() { $Response = new CakeResponse(); $Controller = new Controller($Request, $Response); - // non utf-8 stuff + // encoding a false, ensure this doesn't trigger exception $data = false; $Controller->set($data); From b880714231fdb1c9b23770f66cb6c267fee67f69 Mon Sep 17 00:00:00 2001 From: Rob McVey Date: Fri, 13 Mar 2015 16:27:24 +0000 Subject: [PATCH 121/336] coding standards elseif --- lib/Cake/View/JsonView.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/View/JsonView.php b/lib/Cake/View/JsonView.php index eb8eb911460..edfa926da67 100644 --- a/lib/Cake/View/JsonView.php +++ b/lib/Cake/View/JsonView.php @@ -161,7 +161,7 @@ protected function _serialize($serialize) { $error = __('JSON encoding failed: Error code %s', json_last_error()); } throw new CakeException($error); - } else if ($json === false) { + } elseif ($json === false) { throw new CakeException(__('Failed to parse JSON')); } return $json; From 3b01c5f8423437104d1adb8fa4ac4f527bdbdbd4 Mon Sep 17 00:00:00 2001 From: Rob McVey Date: Fri, 13 Mar 2015 16:58:29 +0000 Subject: [PATCH 122/336] suppress warnings so test runner doesn't fart --- lib/Cake/View/JsonView.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/View/JsonView.php b/lib/Cake/View/JsonView.php index edfa926da67..3aa97f5a37b 100644 --- a/lib/Cake/View/JsonView.php +++ b/lib/Cake/View/JsonView.php @@ -149,9 +149,9 @@ protected function _serialize($serialize) { } if (version_compare(PHP_VERSION, '5.4.0', '>=') && Configure::read('debug')) { - $json = json_encode($data, JSON_PRETTY_PRINT); + $json = @json_encode($data, JSON_PRETTY_PRINT); } else { - $json = json_encode($data); + $json = @json_encode($data); } if (function_exists('json_last_error') && json_last_error() !== JSON_ERROR_NONE) { From 5f40161e24e55fe4649d0b972e520650b6f4dc1b Mon Sep 17 00:00:00 2001 From: Jonas Date: Fri, 13 Mar 2015 21:35:12 +0100 Subject: [PATCH 123/336] 2.6.2: cake bake / ModelTask should respect decimal PR for https://github.com/cakephp/cakephp/issues/6066 --- lib/Cake/Console/Command/Task/ModelTask.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index 89756170f78..6979ed44e73 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -460,6 +460,8 @@ public function fieldValidation($fieldName, $metaData, $primaryKey = 'id') { $guess = $methods['datetime']; } elseif ($metaData['type'] === 'inet') { $guess = $methods['ip']; + } elseif ($metaData['type'] === 'decimal') { + $guess = $methods['decimal']; } } From 842cdf58f8208bdc33df1610dd11874a82085c2c Mon Sep 17 00:00:00 2001 From: Rob McVey Date: Sat, 14 Mar 2015 08:34:06 +0000 Subject: [PATCH 124/336] Don't translate errors --- lib/Cake/View/JsonView.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/View/JsonView.php b/lib/Cake/View/JsonView.php index 3aa97f5a37b..631054b4419 100644 --- a/lib/Cake/View/JsonView.php +++ b/lib/Cake/View/JsonView.php @@ -158,11 +158,11 @@ protected function _serialize($serialize) { if (function_exists('json_last_error_msg')) { $error = json_last_error_msg(); } else { - $error = __('JSON encoding failed: Error code %s', json_last_error()); + $error = sprintf('JSON encoding failed: Error code %s', json_last_error()); } throw new CakeException($error); } elseif ($json === false) { - throw new CakeException(__('Failed to parse JSON')); + throw new CakeException('Failed to parse JSON'); } return $json; } From bcb6549565760bb1fcaf6140448c82416b8ba74f Mon Sep 17 00:00:00 2001 From: Rob McVey Date: Sat, 14 Mar 2015 08:45:18 +0000 Subject: [PATCH 125/336] add throws tag to function comment --- lib/Cake/View/JsonView.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Cake/View/JsonView.php b/lib/Cake/View/JsonView.php index 631054b4419..c501fae6615 100644 --- a/lib/Cake/View/JsonView.php +++ b/lib/Cake/View/JsonView.php @@ -130,6 +130,7 @@ public function render($view = null, $layout = null) { * PHP 5 <= 5.2.9 : Generic fall back error * * @param array $serialize The viewVars that need to be serialized + * @throws CakeException * @return string The serialized data */ protected function _serialize($serialize) { From 10cfb878be2b2195aa914ea3b341255896e0f5d4 Mon Sep 17 00:00:00 2001 From: Rob McVey Date: Sat, 14 Mar 2015 09:13:31 +0000 Subject: [PATCH 126/336] fallback implementation of json_last_error_msg --- lib/Cake/View/JsonView.php | 4 ++-- lib/Cake/basics.php | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/Cake/View/JsonView.php b/lib/Cake/View/JsonView.php index c501fae6615..d7d75e82d78 100644 --- a/lib/Cake/View/JsonView.php +++ b/lib/Cake/View/JsonView.php @@ -150,9 +150,9 @@ protected function _serialize($serialize) { } if (version_compare(PHP_VERSION, '5.4.0', '>=') && Configure::read('debug')) { - $json = @json_encode($data, JSON_PRETTY_PRINT); + $json = json_encode($data, JSON_PRETTY_PRINT); } else { - $json = @json_encode($data); + $json = json_encode($data); } if (function_exists('json_last_error') && json_last_error() !== JSON_ERROR_NONE) { diff --git a/lib/Cake/basics.php b/lib/Cake/basics.php index 8dc20a01529..9ca5a93dbad 100644 --- a/lib/Cake/basics.php +++ b/lib/Cake/basics.php @@ -1061,3 +1061,25 @@ function convertSlash($string) { } } + +if (!function_exists('json_last_error_msg')) { + +/** + * Provides the fallback implementation of json_last_error_msg() available in PHP 5.5 and above. + * + * @return string Error message. + */ + function json_last_error_msg() { + static $errors = array( + JSON_ERROR_NONE => '', + JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', + JSON_ERROR_STATE_MISMATCH => 'Invalid or malformed JSON', + JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded', + JSON_ERROR_SYNTAX => 'Syntax error', + JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded' + ); + $error = json_last_error(); + return array_key_exists($error, $errors) ? $errors[$error] : "Unknown error ({$error})"; + } + +} From 5002bd4dbecae6c8782728476c08b1de08827eb2 Mon Sep 17 00:00:00 2001 From: Rob McVey Date: Sat, 14 Mar 2015 09:21:15 +0000 Subject: [PATCH 127/336] Use fall back json_last_error_msg --- lib/Cake/View/JsonView.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/lib/Cake/View/JsonView.php b/lib/Cake/View/JsonView.php index d7d75e82d78..fb25a34a16e 100644 --- a/lib/Cake/View/JsonView.php +++ b/lib/Cake/View/JsonView.php @@ -124,10 +124,6 @@ public function render($view = null, $layout = null) { /** * Serialize view vars - * For JSON documents, any errors are output using; - * PHP 5 >= 5.5.0 : json_last_error_msg() - * PHP 5 >= 5.3.0 : json_last_error() - * PHP 5 <= 5.2.9 : Generic fall back error * * @param array $serialize The viewVars that need to be serialized * @throws CakeException @@ -156,12 +152,7 @@ protected function _serialize($serialize) { } if (function_exists('json_last_error') && json_last_error() !== JSON_ERROR_NONE) { - if (function_exists('json_last_error_msg')) { - $error = json_last_error_msg(); - } else { - $error = sprintf('JSON encoding failed: Error code %s', json_last_error()); - } - throw new CakeException($error); + throw new CakeException(sprintf('JSON_ERROR: %s', json_last_error_msg())); } elseif ($json === false) { throw new CakeException('Failed to parse JSON'); } From d3c24be84b38cabef19892f4b2dbf6d838a4fc2c Mon Sep 17 00:00:00 2001 From: Rob McVey Date: Sat, 14 Mar 2015 13:12:09 +0000 Subject: [PATCH 128/336] add a custom error handler for tests of json_encode --- lib/Cake/Test/Case/View/JsonViewTest.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/View/JsonViewTest.php b/lib/Cake/Test/Case/View/JsonViewTest.php index 11a11f994a8..3a772b85309 100644 --- a/lib/Cake/Test/Case/View/JsonViewTest.php +++ b/lib/Cake/Test/Case/View/JsonViewTest.php @@ -156,6 +156,20 @@ public static function renderWithoutViewProvider() { ); } +/** + * Custom error handler for use while testing methods that use json_encode + * @param int $errno + * @param string $errstr + * @param string $errfile + * @param int $errline + * @param array $errcontext + * @return void + * @throws CakeException + **/ + public function jsonEncodeErrorHandler($errno, $errstr, $errfile, $errline, $errcontext) { + throw new CakeException($errstr, 0, $errno, $errfile, $errline); + } + /** * Test render with a valid string in _serialize. * @@ -310,7 +324,7 @@ public function testRenderWithViewAndNamed() { /** * JsonViewTest::testRenderInvalidJSON() * - * @expectedException CakeException + * expectedException CakeException * @return void */ public function testRenderInvalidJSON() { @@ -320,6 +334,9 @@ public function testRenderInvalidJSON() { // non utf-8 stuff $data = array('data' => array('foo' => 'bar' . chr('0x97'))); + + // Use a custom error handler + $phpUnitErrorHandler = set_error_handler(array($this, 'jsonEncodeErrorHandler')); $Controller->set($data); $Controller->set('_serialize', 'data'); From 56c6f02efc34e59dcf3625ce1c57eedf920b7c4b Mon Sep 17 00:00:00 2001 From: Rob McVey Date: Sat, 14 Mar 2015 13:16:05 +0000 Subject: [PATCH 129/336] Remove tabs --- lib/Cake/Test/Case/View/JsonViewTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/View/JsonViewTest.php b/lib/Cake/Test/Case/View/JsonViewTest.php index 3a772b85309..fb7955c1a8c 100644 --- a/lib/Cake/Test/Case/View/JsonViewTest.php +++ b/lib/Cake/Test/Case/View/JsonViewTest.php @@ -334,7 +334,7 @@ public function testRenderInvalidJSON() { // non utf-8 stuff $data = array('data' => array('foo' => 'bar' . chr('0x97'))); - + // Use a custom error handler $phpUnitErrorHandler = set_error_handler(array($this, 'jsonEncodeErrorHandler')); From fe0ddf21711042b8eea435e18024493bdc677fb6 Mon Sep 17 00:00:00 2001 From: Rob McVey Date: Sat, 14 Mar 2015 13:27:34 +0000 Subject: [PATCH 130/336] Assert exception is thrown, reset error handler in tearDown --- lib/Cake/Test/Case/View/JsonViewTest.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/View/JsonViewTest.php b/lib/Cake/Test/Case/View/JsonViewTest.php index fb7955c1a8c..06c4f020897 100644 --- a/lib/Cake/Test/Case/View/JsonViewTest.php +++ b/lib/Cake/Test/Case/View/JsonViewTest.php @@ -28,11 +28,26 @@ */ class JsonViewTest extends CakeTestCase { +/** + * setUp method + * + * @return void + **/ public function setUp() { parent::setUp(); Configure::write('debug', 0); } +/** + * tearDown method + * + * @return void + **/ + public function tearDown() { + parent::tearDown(); + restore_error_handler(); + } + /** * Generates testRenderWithoutView data. * @@ -324,7 +339,7 @@ public function testRenderWithViewAndNamed() { /** * JsonViewTest::testRenderInvalidJSON() * - * expectedException CakeException + * @expectedException CakeException * @return void */ public function testRenderInvalidJSON() { @@ -336,7 +351,7 @@ public function testRenderInvalidJSON() { $data = array('data' => array('foo' => 'bar' . chr('0x97'))); // Use a custom error handler - $phpUnitErrorHandler = set_error_handler(array($this, 'jsonEncodeErrorHandler')); + set_error_handler(array($this, 'jsonEncodeErrorHandler')); $Controller->set($data); $Controller->set('_serialize', 'data'); From b3c961bc9e2b8760fa0d10336819c12d0794fefc Mon Sep 17 00:00:00 2001 From: Rob McVey Date: Sat, 14 Mar 2015 13:45:50 +0000 Subject: [PATCH 131/336] Tickle Travis From c32e5559bb01c043ec45ab8e25b2307de721cff3 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 14 Mar 2015 22:23:17 -0400 Subject: [PATCH 132/336] Add test to ensure column was converted to integer. Refs #5512 --- lib/Cake/Model/Datasource/Database/Postgres.php | 2 -- .../Case/Model/Datasource/Database/PostgresTest.php | 12 ++++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Model/Datasource/Database/Postgres.php b/lib/Cake/Model/Datasource/Database/Postgres.php index acac1ff17ae..21d82b1910f 100644 --- a/lib/Cake/Model/Datasource/Database/Postgres.php +++ b/lib/Cake/Model/Datasource/Database/Postgres.php @@ -1,7 +1,5 @@ 'integer', 'null' => true); $New = new CakeSchema($modified); - $query = $this->Dbo->alterSchema($New->compare($Old)); - $result = $this->Dbo->query($query); + $this->Dbo->query($this->Dbo->alterSchema($New->compare($Old))); + $result = $this->Dbo->describe('text_fields'); + $this->Dbo->query($this->Dbo->dropSchema($Old)); + $expected = array( + 'type' => 'integer', + 'null' => true, + 'default' => null, + 'length' => null, + ); + $this->assertEquals($expected, $result['active']); } /** From a59a05713301e2038d54d623d521763ba58f5a36 Mon Sep 17 00:00:00 2001 From: Rob McVey Date: Sun, 15 Mar 2015 10:36:06 +0000 Subject: [PATCH 133/336] assert correct exception msg thrown --- lib/Cake/Test/Case/View/JsonViewTest.php | 33 +++++++++++++----------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/Cake/Test/Case/View/JsonViewTest.php b/lib/Cake/Test/Case/View/JsonViewTest.php index 06c4f020897..8317ac5b5fb 100644 --- a/lib/Cake/Test/Case/View/JsonViewTest.php +++ b/lib/Cake/Test/Case/View/JsonViewTest.php @@ -38,16 +38,6 @@ public function setUp() { Configure::write('debug', 0); } -/** - * tearDown method - * - * @return void - **/ - public function tearDown() { - parent::tearDown(); - restore_error_handler(); - } - /** * Generates testRenderWithoutView data. * @@ -339,7 +329,6 @@ public function testRenderWithViewAndNamed() { /** * JsonViewTest::testRenderInvalidJSON() * - * @expectedException CakeException * @return void */ public function testRenderInvalidJSON() { @@ -350,13 +339,27 @@ public function testRenderInvalidJSON() { // non utf-8 stuff $data = array('data' => array('foo' => 'bar' . chr('0x97'))); - // Use a custom error handler - set_error_handler(array($this, 'jsonEncodeErrorHandler')); - $Controller->set($data); $Controller->set('_serialize', 'data'); $View = new JsonView($Controller); - $output = $View->render(); + + // Use a custom error handler + set_error_handler(array($this, 'jsonEncodeErrorHandler')); + + try { + $View->render(); + restore_error_handler(); + $this->fail('Failed asserting that exception of type "CakeException" is thrown.'); + } catch (CakeException $e) { + $expected = array( + 'Failed to parse JSON', + 'Malformed UTF-8 characters, possibly incorrectly encoded' + ); + $this->assertContains($e->getMessage(), $expected); + restore_error_handler(); + return; + + } } /** From d94e05cf7683bd89067b9b440592108b98e1ff78 Mon Sep 17 00:00:00 2001 From: Rob McVey Date: Sun, 15 Mar 2015 11:01:51 +0000 Subject: [PATCH 134/336] Assert exception msg contains UTF-8 The different versions of PHP throw several various messages for UTF-8 sequences, so this just performs a basic regex check --- lib/Cake/Test/Case/View/JsonViewTest.php | 6 +----- lib/Cake/View/JsonView.php | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/Cake/Test/Case/View/JsonViewTest.php b/lib/Cake/Test/Case/View/JsonViewTest.php index 8317ac5b5fb..f3a5902d517 100644 --- a/lib/Cake/Test/Case/View/JsonViewTest.php +++ b/lib/Cake/Test/Case/View/JsonViewTest.php @@ -351,12 +351,8 @@ public function testRenderInvalidJSON() { restore_error_handler(); $this->fail('Failed asserting that exception of type "CakeException" is thrown.'); } catch (CakeException $e) { - $expected = array( - 'Failed to parse JSON', - 'Malformed UTF-8 characters, possibly incorrectly encoded' - ); - $this->assertContains($e->getMessage(), $expected); restore_error_handler(); + $this->assertRegExp('/UTF-8/', $e->getMessage()); return; } diff --git a/lib/Cake/View/JsonView.php b/lib/Cake/View/JsonView.php index fb25a34a16e..7953803de85 100644 --- a/lib/Cake/View/JsonView.php +++ b/lib/Cake/View/JsonView.php @@ -152,7 +152,7 @@ protected function _serialize($serialize) { } if (function_exists('json_last_error') && json_last_error() !== JSON_ERROR_NONE) { - throw new CakeException(sprintf('JSON_ERROR: %s', json_last_error_msg())); + throw new CakeException(json_last_error_msg()); } elseif ($json === false) { throw new CakeException('Failed to parse JSON'); } From 4741abcd63b75a9e842773727c9dcaeb72882390 Mon Sep 17 00:00:00 2001 From: Rob McVey Date: Sun, 15 Mar 2015 11:14:49 +0000 Subject: [PATCH 135/336] Remove whitespace --- lib/Cake/Test/Case/View/JsonViewTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Cake/Test/Case/View/JsonViewTest.php b/lib/Cake/Test/Case/View/JsonViewTest.php index f3a5902d517..4e4eb25742d 100644 --- a/lib/Cake/Test/Case/View/JsonViewTest.php +++ b/lib/Cake/Test/Case/View/JsonViewTest.php @@ -354,7 +354,6 @@ public function testRenderInvalidJSON() { restore_error_handler(); $this->assertRegExp('/UTF-8/', $e->getMessage()); return; - } } From 02c40d5ca5f5b839c056f250fd9036b2e09de571 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 15 Mar 2015 22:06:30 -0400 Subject: [PATCH 136/336] Update version number to 2.6.3 --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index 4c3efdfeb59..9706040e1d8 100644 --- a/lib/Cake/VERSION.txt +++ b/lib/Cake/VERSION.txt @@ -17,4 +17,4 @@ // @license http://www.opensource.org/licenses/mit-license.php MIT License // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -2.6.2 +2.6.3 From b444fe7b81cf03a508872b7629231c4d88a1dc11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgaras=20Janu=C5=A1auskas?= Date: Mon, 16 Mar 2015 23:16:50 +0200 Subject: [PATCH 137/336] Do not warn about i18n functions definitions on extract task --- lib/Cake/Console/Command/Task/ExtractTask.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Console/Command/Task/ExtractTask.php b/lib/Cake/Console/Command/Task/ExtractTask.php index c9f5712cc93..913c5680e6a 100644 --- a/lib/Cake/Console/Command/Task/ExtractTask.php +++ b/lib/Cake/Console/Command/Task/ExtractTask.php @@ -448,7 +448,7 @@ protected function _parse($functionName, $map) { if ($categoryName !== 'LC_TIME') { $this->_addTranslation($categoryName, $domain, $singular, $details); } - } else { + } elseif (!is_array($this->_tokens[$count - 1]) || $this->_tokens[$count - 1][0] != T_FUNCTION) { $this->_markerError($this->_file, $line, $functionName, $count); } } From 6df7bf9c2161d600c0d4da6712cd68932171e9c8 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 17 Mar 2015 22:18:50 -0400 Subject: [PATCH 138/336] Fix notice errors in pagination link generation. No errors should be emitted when creating links for models that were not paginated. Refs #6090 --- .../Case/View/Helper/PaginatorHelperTest.php | 41 +++++++++++++++++++ lib/Cake/View/Helper/PaginatorHelper.php | 11 ++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php b/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php index 8c59e5bf863..5b37bf4f074 100644 --- a/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php @@ -1260,6 +1260,14 @@ public function testPagingLinksNotDefaultModel() { 'paramType' => 'named' ) ); + $result = $this->Paginator->sort('title', 'Title', array('model' => 'Client')); + $expected = array( + 'a' => array('href' => '/index/sort:title/direction:asc'), + 'Title', + '/a' + ); + $this->assertTags($result, $expected); + $result = $this->Paginator->next('Next', array('model' => 'Client')); $expected = array( 'span' => array('class' => 'next'), @@ -1277,6 +1285,39 @@ public function testPagingLinksNotDefaultModel() { $this->assertTags($result, $expected); } +/** + * Test creating paging links for missing models. + * + * @return void + */ + public function testPagingLinksMissingModel() { + $result = $this->Paginator->sort('title', 'Title', array('model' => 'Missing')); + $expected = array( + 'a' => array('href' => '/index/sort:title/direction:asc'), + 'Title', + '/a' + ); + $this->assertTags($result, $expected); + + $result = $this->Paginator->next('Next', array('model' => 'Missing')); + $expected = array( + 'span' => array('class' => 'next'), + 'a' => array('href' => '/index/page:2', 'rel' => 'next'), + 'Next', + '/a', + '/span' + ); + $this->assertTags($result, $expected); + + $result = $this->Paginator->prev('Prev', array('model' => 'Missing')); + $expected = array( + 'span' => array('class' => 'prev'), + 'Prev', + '/span' + ); + $this->assertTags($result, $expected); + } + /** * testGenericLinks method * diff --git a/lib/Cake/View/Helper/PaginatorHelper.php b/lib/Cake/View/Helper/PaginatorHelper.php index f79e09e7ed2..f5e3e72f2ac 100644 --- a/lib/Cake/View/Helper/PaginatorHelper.php +++ b/lib/Cake/View/Helper/PaginatorHelper.php @@ -120,7 +120,7 @@ public function beforeRender($viewFile) { * Gets the current paging parameters from the resultset for the given model * * @param string $model Optional model name. Uses the default if none is specified. - * @return array|null The array of paging parameters for the paginated resultset. + * @return array The array of paging parameters for the paginated resultset. * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::params */ public function params($model = null) { @@ -128,7 +128,14 @@ public function params($model = null) { $model = $this->defaultModel(); } if (!isset($this->request->params['paging']) || empty($this->request->params['paging'][$model])) { - return null; + return array( + 'prevPage' => false, + 'nextPage' => true, + 'paramType' => 'named', + 'pageCount' => 1, + 'options' => array(), + 'page' => 1 + ); } return $this->request->params['paging'][$model]; } From 359c0ab816f62eaa6d4e590dbe9ccbcef099f3ed Mon Sep 17 00:00:00 2001 From: Walther Lalk Date: Thu, 19 Mar 2015 11:42:14 +0200 Subject: [PATCH 139/336] Fix issue with memcache and domains starting with letter "u" --- lib/Cake/Cache/Engine/MemcacheEngine.php | 2 +- lib/Cake/Cache/Engine/MemcachedEngine.php | 2 +- .../Test/Case/Cache/Engine/MemcacheEngineTest.php | 11 +++++++++++ .../Test/Case/Cache/Engine/MemcachedEngineTest.php | 11 +++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Cache/Engine/MemcacheEngine.php b/lib/Cake/Cache/Engine/MemcacheEngine.php index 2f7e5e1f467..250f02ad8ae 100644 --- a/lib/Cake/Cache/Engine/MemcacheEngine.php +++ b/lib/Cake/Cache/Engine/MemcacheEngine.php @@ -104,7 +104,7 @@ public function init($settings = array()) { * @return array Array containing host, port */ protected function _parseServerString($server) { - if ($server[0] === 'u') { + if (strpos($server, 'unix://') === 0) { return array($server, 0); } if (substr($server, 0, 1) === '[') { diff --git a/lib/Cake/Cache/Engine/MemcachedEngine.php b/lib/Cake/Cache/Engine/MemcachedEngine.php index 74ea7c1c39c..a2611396a7d 100644 --- a/lib/Cake/Cache/Engine/MemcachedEngine.php +++ b/lib/Cake/Cache/Engine/MemcachedEngine.php @@ -185,7 +185,7 @@ protected function _setOptions() { * @return array Array containing host, port */ protected function _parseServerString($server) { - if ($server[0] === 'u') { + if (strpos($server, 'unix://') === 0) { return array($server, 0); } if (substr($server, 0, 1) === '[') { diff --git a/lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php index fbe99dbbb9a..36f8f0d8bd3 100644 --- a/lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php @@ -161,6 +161,17 @@ public function testConnectIpv6() { $this->assertTrue($result); } +/** + * test domain starts with u + * + * @return void + */ + public function testParseServerStringWithU() { + $Memcached = new TestMemcachedEngine(); + $result = $Memcached->parseServerString('udomain.net:13211'); + $this->assertEquals(array('udomain.net', '13211'), $result); + } + /** * test non latin domains. * diff --git a/lib/Cake/Test/Case/Cache/Engine/MemcachedEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/MemcachedEngineTest.php index 4f940ef41d3..17f1f99727d 100644 --- a/lib/Cake/Test/Case/Cache/Engine/MemcachedEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/MemcachedEngineTest.php @@ -400,6 +400,17 @@ public function testConnectIpv6() { $this->assertTrue($result); } +/** + * test domain starts with u + * + * @return void + */ + public function testParseServerStringWithU() { + $Memcached = new TestMemcachedEngine(); + $result = $Memcached->parseServerString('udomain.net:13211'); + $this->assertEquals(array('udomain.net', '13211'), $result); + } + /** * test non latin domains. * From 744952e3442652d8fa49ef0d0c926a36156ebfa8 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 19 Mar 2015 21:15:20 -0400 Subject: [PATCH 140/336] Fix FormHelper::create() dropping 0 value parameter. When 0 is the first passed parameter we shouldn't drop it. Fixes #6107 --- lib/Cake/Test/Case/View/Helper/FormHelperTest.php | 7 ++++--- lib/Cake/View/Helper/FormHelper.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 30d25eacccf..4b6cfb7e1c7 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -8642,6 +8642,7 @@ public function testCreatePassedArgs() { 'escape' => false, 'url' => array( 'action' => 'edit', + '0', 'myparam' ) )); @@ -8649,7 +8650,7 @@ public function testCreatePassedArgs() { 'form' => array( 'id' => 'ContactAddForm', 'method' => 'post', - 'action' => '/contacts/edit/myparam', + 'action' => '/contacts/edit/0/myparam', 'accept-charset' => $encoding ), 'div' => array('style' => 'display:none;'), @@ -8667,8 +8668,8 @@ public function testCreatePassedArgs() { public function testCreateNoErrorsWithMockModel() { $encoding = strtolower(Configure::read('App.encoding')); $ContactMock = $this->getMockBuilder('Contact') - ->disableOriginalConstructor() - ->getMock(); + ->disableOriginalConstructor() + ->getMock(); ClassRegistry::removeObject('Contact'); ClassRegistry::addObject('Contact', $ContactMock); $result = $this->Form->create('Contact', array('type' => 'GET')); diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 22fb6551da7..880f5fd3fc1 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -408,7 +408,7 @@ public function create($model = null, $options = array()) { 'action' => $options['action'], ); $options['action'] = array_merge($actionDefaults, (array)$options['url']); - if (empty($options['action'][0]) && !empty($id)) { + if (!isset($options['action'][0]) && !empty($id)) { $options['action'][0] = $id; } } elseif (is_string($options['url'])) { From 0003296f4262e9c292680582551d75d143e47e7b Mon Sep 17 00:00:00 2001 From: Dave Hensley Date: Fri, 20 Mar 2015 17:35:19 -0400 Subject: [PATCH 141/336] Add CAKE directory fallthrough for plugins/vendors Fixes issue #6124. --- lib/Cake/Core/App.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 361d36e42d0..f31bfc9377d 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -875,10 +875,12 @@ protected static function _packageFormat() { 'Vendor' => array( '%s' . 'Vendor' . DS, ROOT . DS . 'vendors' . DS, + dirname(dirname(CAKE)) . DS . 'vendors' . DS ), 'Plugin' => array( APP . 'Plugin' . DS, - ROOT . DS . 'plugins' . DS + ROOT . DS . 'plugins' . DS, + dirname(dirname(CAKE)) . DS . 'plugins' . DS ) ); } From 5a6a74e2f8bbc329eb25926fce61ef55596604b1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 20 Mar 2015 20:35:30 -0400 Subject: [PATCH 142/336] Fix failing tests. The test was taking the wrong index when creating mock path choices. Refs #6125 --- lib/Cake/Console/Command/Task/PluginTask.php | 2 -- .../Case/Console/Command/Task/PluginTaskTest.php | 16 +++++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/Cake/Console/Command/Task/PluginTask.php b/lib/Cake/Console/Command/Task/PluginTask.php index 95c3b30397b..7cd50794281 100644 --- a/lib/Cake/Console/Command/Task/PluginTask.php +++ b/lib/Cake/Console/Command/Task/PluginTask.php @@ -1,7 +1,5 @@ _testPath = array_push($paths, TMP . 'tests' . DS); + $this->_testPath = array_push($paths, TMP . 'tests' . DS) - 1; App::build(array('plugins' => $paths)); } @@ -80,17 +80,23 @@ public function tearDown() { * @return void */ public function testBakeFoldersAndFiles() { - $this->Task->expects($this->at(0))->method('in')->will($this->returnValue($this->_testPath)); - $this->Task->expects($this->at(1))->method('in')->will($this->returnValue('y')); + $this->Task->expects($this->at(0)) + ->method('in') + ->will($this->returnValue($this->_testPath)); + $this->Task->expects($this->at(1)) + ->method('in') + ->will($this->returnValue('y')); $path = $this->Task->path . 'BakeTestPlugin'; $file = $path . DS . 'Controller' . DS . 'BakeTestPluginAppController.php'; - $this->Task->expects($this->at(2))->method('createFile') + $this->Task->expects($this->at(2)) + ->method('createFile') ->with($file, new PHPUnit_Framework_Constraint_IsAnything()); $file = $path . DS . 'Model' . DS . 'BakeTestPluginAppModel.php'; - $this->Task->expects($this->at(3))->method('createFile') + $this->Task->expects($this->at(3)) + ->method('createFile') ->with($file, new PHPUnit_Framework_Constraint_IsAnything()); $this->Task->bake('BakeTestPlugin'); From 54a3f8724b63c8dad46a35baad9f11f997cc3c62 Mon Sep 17 00:00:00 2001 From: Richard van den Berg Date: Tue, 17 Mar 2015 13:40:36 +0100 Subject: [PATCH 143/336] Addapted quick hack from issue #2057 for 2.6.3 --- lib/Cake/Network/CakeSocket.php | 30 +++++++++++++++++++++++++++- lib/Cake/Network/Http/HttpSocket.php | 1 + 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Network/CakeSocket.php b/lib/Cake/Network/CakeSocket.php index d428a74cb64..8b3c92e5f0b 100644 --- a/lib/Cake/Network/CakeSocket.php +++ b/lib/Cake/Network/CakeSocket.php @@ -130,7 +130,7 @@ public function connect() { } $scheme = null; - if (!empty($this->config['protocol']) && strpos($this->config['host'], '://') === false) { + if (!empty($this->config['protocol']) && strpos($this->config['host'], '://') === false && empty($this->config['proxy'])) { $scheme = $this->config['protocol'] . '://'; } @@ -170,6 +170,34 @@ public function connect() { if ($this->connected) { stream_set_timeout($this->connection, $this->config['timeout']); } + + + if (!empty($this->config['request']) && $this->config['request']['uri']['scheme'] == 'https' && !empty($this->config['proxy'])) { + $req = array(); + $req[] = 'CONNECT '. $this->config['request']['uri']['host'] . ':' . $this->config['request']['uri']['port'] . ' HTTP/1.1'; + $req[] = 'Host: ' . $this->config['host']; + $req[] = 'User-Agent: php proxy'; + + fwrite($this->connection, implode("\r\n", $req)."\r\n\r\n"); + + while(true) { + $s = rtrim(fgets($this->connection, 4096)); + if(preg_match('/^$/', $s)) { + break; + } + } + + $modes = array(STREAM_CRYPTO_METHOD_TLS_CLIENT, + STREAM_CRYPTO_METHOD_SSLv3_CLIENT, + STREAM_CRYPTO_METHOD_SSLv23_CLIENT, + STREAM_CRYPTO_METHOD_SSLv2_CLIENT); + $success = false; + foreach($modes as $mode) { + $success = stream_socket_enable_crypto($this->connection, true, $mode); + if ($success) break; + } + } + return $this->connected; } diff --git a/lib/Cake/Network/Http/HttpSocket.php b/lib/Cake/Network/Http/HttpSocket.php index 16fc0edcfc2..ff176359f92 100644 --- a/lib/Cake/Network/Http/HttpSocket.php +++ b/lib/Cake/Network/Http/HttpSocket.php @@ -652,6 +652,7 @@ protected function _setProxy() { } $this->config['host'] = $this->_proxy['host']; $this->config['port'] = $this->_proxy['port']; + $this->config['proxy'] = true; if (empty($this->_proxy['method']) || !isset($this->_proxy['user'], $this->_proxy['pass'])) { return; From bb8e0ae83524f2ab7ffbd9b330cb39f34ed640a7 Mon Sep 17 00:00:00 2001 From: Richard van den Berg Date: Wed, 18 Mar 2015 16:10:04 +0100 Subject: [PATCH 144/336] Use enableCrypto() --- lib/Cake/Network/CakeSocket.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/lib/Cake/Network/CakeSocket.php b/lib/Cake/Network/CakeSocket.php index 8b3c92e5f0b..7ded1456901 100644 --- a/lib/Cake/Network/CakeSocket.php +++ b/lib/Cake/Network/CakeSocket.php @@ -171,7 +171,6 @@ public function connect() { stream_set_timeout($this->connection, $this->config['timeout']); } - if (!empty($this->config['request']) && $this->config['request']['uri']['scheme'] == 'https' && !empty($this->config['proxy'])) { $req = array(); $req[] = 'CONNECT '. $this->config['request']['uri']['host'] . ':' . $this->config['request']['uri']['port'] . ' HTTP/1.1'; @@ -187,15 +186,7 @@ public function connect() { } } - $modes = array(STREAM_CRYPTO_METHOD_TLS_CLIENT, - STREAM_CRYPTO_METHOD_SSLv3_CLIENT, - STREAM_CRYPTO_METHOD_SSLv23_CLIENT, - STREAM_CRYPTO_METHOD_SSLv2_CLIENT); - $success = false; - foreach($modes as $mode) { - $success = stream_socket_enable_crypto($this->connection, true, $mode); - if ($success) break; - } + $this->enableCrypto('tls', 'client'); } return $this->connected; From 3995c70046537f53b5530537de5140676b06ee38 Mon Sep 17 00:00:00 2001 From: Richard van den Berg Date: Wed, 18 Mar 2015 19:27:57 +0100 Subject: [PATCH 145/336] Strict === and space --- lib/Cake/Network/CakeSocket.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Network/CakeSocket.php b/lib/Cake/Network/CakeSocket.php index 7ded1456901..01e074589e7 100644 --- a/lib/Cake/Network/CakeSocket.php +++ b/lib/Cake/Network/CakeSocket.php @@ -171,7 +171,7 @@ public function connect() { stream_set_timeout($this->connection, $this->config['timeout']); } - if (!empty($this->config['request']) && $this->config['request']['uri']['scheme'] == 'https' && !empty($this->config['proxy'])) { + if (!empty($this->config['request']) && $this->config['request']['uri']['scheme'] === 'https' && !empty($this->config['proxy'])) { $req = array(); $req[] = 'CONNECT '. $this->config['request']['uri']['host'] . ':' . $this->config['request']['uri']['port'] . ' HTTP/1.1'; $req[] = 'Host: ' . $this->config['host']; @@ -181,7 +181,7 @@ public function connect() { while(true) { $s = rtrim(fgets($this->connection, 4096)); - if(preg_match('/^$/', $s)) { + if (preg_match('/^$/', $s)) { break; } } From 7704efdb282cf7742a93f002fec561f2ad58196e Mon Sep 17 00:00:00 2001 From: Richard van den Berg Date: Thu, 19 Mar 2015 09:03:26 +0100 Subject: [PATCH 146/336] Use feof() in while loop --- lib/Cake/Network/CakeSocket.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Network/CakeSocket.php b/lib/Cake/Network/CakeSocket.php index 01e074589e7..8b134a9f36b 100644 --- a/lib/Cake/Network/CakeSocket.php +++ b/lib/Cake/Network/CakeSocket.php @@ -177,9 +177,9 @@ public function connect() { $req[] = 'Host: ' . $this->config['host']; $req[] = 'User-Agent: php proxy'; - fwrite($this->connection, implode("\r\n", $req)."\r\n\r\n"); + fwrite($this->connection, implode("\r\n", $req) . "\r\n\r\n"); - while(true) { + while (!feof($this->connection)) { $s = rtrim(fgets($this->connection, 4096)); if (preg_match('/^$/', $s)) { break; From 15c80f7c3d5214a7312fe8d71297f69b1dd63d6d Mon Sep 17 00:00:00 2001 From: Richard van den Berg Date: Thu, 19 Mar 2015 09:13:14 +0100 Subject: [PATCH 147/336] Move proxy code inside if (->connected) --- lib/Cake/Network/CakeSocket.php | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/Cake/Network/CakeSocket.php b/lib/Cake/Network/CakeSocket.php index 8b134a9f36b..02b9b317f46 100644 --- a/lib/Cake/Network/CakeSocket.php +++ b/lib/Cake/Network/CakeSocket.php @@ -169,26 +169,25 @@ public function connect() { $this->connected = is_resource($this->connection); if ($this->connected) { stream_set_timeout($this->connection, $this->config['timeout']); - } - if (!empty($this->config['request']) && $this->config['request']['uri']['scheme'] === 'https' && !empty($this->config['proxy'])) { - $req = array(); - $req[] = 'CONNECT '. $this->config['request']['uri']['host'] . ':' . $this->config['request']['uri']['port'] . ' HTTP/1.1'; - $req[] = 'Host: ' . $this->config['host']; - $req[] = 'User-Agent: php proxy'; + if (!empty($this->config['request']) && $this->config['request']['uri']['scheme'] === 'https' && !empty($this->config['proxy'])) { + $req = array(); + $req[] = 'CONNECT '. $this->config['request']['uri']['host'] . ':' . $this->config['request']['uri']['port'] . ' HTTP/1.1'; + $req[] = 'Host: ' . $this->config['host']; + $req[] = 'User-Agent: php proxy'; - fwrite($this->connection, implode("\r\n", $req) . "\r\n\r\n"); + fwrite($this->connection, implode("\r\n", $req) . "\r\n\r\n"); - while (!feof($this->connection)) { - $s = rtrim(fgets($this->connection, 4096)); - if (preg_match('/^$/', $s)) { - break; + while (!feof($this->connection)) { + $s = rtrim(fgets($this->connection, 4096)); + if (preg_match('/^$/', $s)) { + break; + } } - } - $this->enableCrypto('tls', 'client'); + $this->enableCrypto('tls', 'client'); + } } - return $this->connected; } From 23d4d1155adeb5470625fe8ce9052476e4d53917 Mon Sep 17 00:00:00 2001 From: Richard van den Berg Date: Thu, 19 Mar 2015 16:19:49 +0100 Subject: [PATCH 148/336] Do not use full uri in request line for HTTPS requests via proxy --- lib/Cake/Network/Http/HttpSocket.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Network/Http/HttpSocket.php b/lib/Cake/Network/Http/HttpSocket.php index ff176359f92..92ed5612119 100644 --- a/lib/Cake/Network/Http/HttpSocket.php +++ b/lib/Cake/Network/Http/HttpSocket.php @@ -927,7 +927,7 @@ protected function _buildRequestLine($request = array()) { $request['uri'] = $this->_parseUri($request['uri']); $request += array('method' => 'GET'); - if (!empty($this->_proxy['host'])) { + if (!empty($this->_proxy['host']) && $request['uri']['scheme'] !== 'https') { $request['uri'] = $this->_buildUri($request['uri'], '%scheme://%host:%port/%path?%query'); } else { $request['uri'] = $this->_buildUri($request['uri'], '/%path?%query'); From 9e6b1b6930faf73573d135efab5fa90280967d97 Mon Sep 17 00:00:00 2001 From: Richard van den Berg Date: Fri, 20 Mar 2015 11:27:27 +0100 Subject: [PATCH 149/336] Support for SSL Server Name Indication --- lib/Cake/Network/Http/HttpSocket.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/Cake/Network/Http/HttpSocket.php b/lib/Cake/Network/Http/HttpSocket.php index 92ed5612119..fe1d2bccc35 100644 --- a/lib/Cake/Network/Http/HttpSocket.php +++ b/lib/Cake/Network/Http/HttpSocket.php @@ -718,6 +718,20 @@ protected function _configContext($host) { } unset($this->config[$key]); } + if (version_compare(PHP_VERSION, '5.3.2', '>=')) { + if (empty($this->config['context']['ssl']['SNI_enabled'])) { + $this->config['context']['ssl']['SNI_enabled'] = true; + } + if (version_compare(PHP_VERSION, '5.6.0', '>=')) { + if (empty($this->config['context']['ssl']['peer_name'])) { + $this->config['context']['ssl']['peer_name'] = $this->request['uri']['host']; + } + } else { + if (empty($this->config['context']['ssl']['SNI_server_name'])) { + $this->config['context']['ssl']['SNI_server_name'] = $this->request['uri']['host']; + } + } + } if (empty($this->config['context']['ssl']['cafile'])) { $this->config['context']['ssl']['cafile'] = CAKE . 'Config' . DS . 'cacert.pem'; } From 1f7b78723650a189a631ac32bdc9deba89be04e7 Mon Sep 17 00:00:00 2001 From: Richard van den Berg Date: Fri, 20 Mar 2015 11:30:15 +0100 Subject: [PATCH 150/336] Use $host parameter --- lib/Cake/Network/Http/HttpSocket.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Network/Http/HttpSocket.php b/lib/Cake/Network/Http/HttpSocket.php index fe1d2bccc35..44b514d9f41 100644 --- a/lib/Cake/Network/Http/HttpSocket.php +++ b/lib/Cake/Network/Http/HttpSocket.php @@ -724,11 +724,11 @@ protected function _configContext($host) { } if (version_compare(PHP_VERSION, '5.6.0', '>=')) { if (empty($this->config['context']['ssl']['peer_name'])) { - $this->config['context']['ssl']['peer_name'] = $this->request['uri']['host']; + $this->config['context']['ssl']['peer_name'] = $host; } } else { if (empty($this->config['context']['ssl']['SNI_server_name'])) { - $this->config['context']['ssl']['SNI_server_name'] = $this->request['uri']['host']; + $this->config['context']['ssl']['SNI_server_name'] = $host; } } } From 1d0d20e974f327e2c6ef3582a844f96c6dcd9f7a Mon Sep 17 00:00:00 2001 From: Richard van den Berg Date: Mon, 23 Mar 2015 23:10:32 +0100 Subject: [PATCH 151/336] Account for SNI changes in HttpSocketTest --- lib/Cake/Test/Case/Network/Http/HttpSocketTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php index 6456a0c21fc..de04f18edc0 100644 --- a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php +++ b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php @@ -317,11 +317,18 @@ public function testRequest() { 'verify_peer' => true, 'allow_self_signed' => false, 'verify_depth' => 5, + 'SNI_enabled' => true, 'CN_match' => 'www.cakephp.org', 'cafile' => CAKE . 'Config' . DS . 'cacert.pem' ) ); + if (version_compare(PHP_VERSION, '5.6.0', '>=')) { + $context['ssl']['peer_name'] = 'www.cakephp.org'; + } else { + $context['ssl']['SNI_server_name'] = 'www.cakephp.org'; + } + $tests = array( array( 'request' => 'http://www.cakephp.org/?foo=bar', From b80e02c11435dc15977e2325b234380b2fa83cc2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 23 Mar 2015 22:28:16 -0400 Subject: [PATCH 152/336] Fix coding standards errors. * Line lengths * Whitespace. Refs #2057 --- lib/Cake/Network/CakeSocket.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Network/CakeSocket.php b/lib/Cake/Network/CakeSocket.php index 02b9b317f46..b4c378900a1 100644 --- a/lib/Cake/Network/CakeSocket.php +++ b/lib/Cake/Network/CakeSocket.php @@ -170,9 +170,13 @@ public function connect() { if ($this->connected) { stream_set_timeout($this->connection, $this->config['timeout']); - if (!empty($this->config['request']) && $this->config['request']['uri']['scheme'] === 'https' && !empty($this->config['proxy'])) { + if (!empty($this->config['request']) && + $this->config['request']['uri']['scheme'] === 'https' && + !empty($this->config['proxy']) + ) { $req = array(); - $req[] = 'CONNECT '. $this->config['request']['uri']['host'] . ':' . $this->config['request']['uri']['port'] . ' HTTP/1.1'; + $req[] = 'CONNECT ' . $this->config['request']['uri']['host'] . ':' . + $this->config['request']['uri']['port'] . ' HTTP/1.1'; $req[] = 'Host: ' . $this->config['host']; $req[] = 'User-Agent: php proxy'; From 446dd408bba767313f46235712e19a5aa7921544 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 29 Mar 2015 21:42:43 -0400 Subject: [PATCH 153/336] Renew the session even the session id is '0'. This fixes AuthComponent not being able to log a user in when they inadvertently change their session id to 0. Refs #6053 --- lib/Cake/Model/Datasource/CakeSession.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index 3d5a3976287..44659bcbaf9 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -721,7 +721,7 @@ protected static function _writeConfig() { * @return void */ public static function renew() { - if (!session_id()) { + if (session_id() === '') { return; } if (isset($_COOKIE[session_name()])) { From 69971505a2491a3858c0d2372a9479f86054b8be Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 31 Mar 2015 22:21:15 -0400 Subject: [PATCH 154/336] Fix maxDimensions() for empty/1 dimensional arrays. maxDimensions() should not emit warnings or mis-calculate an array's dimensions. Fixes #6224 --- lib/Cake/Test/Case/Utility/HashTest.php | 8 ++++++++ lib/Cake/Utility/Hash.php | 8 ++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index 5580315cd5b..bfb8632795a 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -275,6 +275,14 @@ public function testDimensions() { * @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/Utility/Hash.php b/lib/Cake/Utility/Hash.php index 70485195b30..9462efcb494 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -763,10 +763,14 @@ public static function maxDimensions(array $data) { $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); } /** From f32d1c1362c164bd39d1e6e4b6d3b0d9ab5fd9db Mon Sep 17 00:00:00 2001 From: Justin Yost Date: Tue, 31 Mar 2015 21:16:23 -0700 Subject: [PATCH 155/336] Updates Inflector For Irregular Case Sieves Sieves incorrectly singualrized as sief. Adds sieve, sieves as an irregular case and test cases to match for the Inflector class. Closes Issue #6240 in CakePHP 2.6 Branch Signed-off-by: Justin Yost --- lib/Cake/Test/Case/Utility/InflectorTest.php | 2 ++ lib/Cake/Utility/Inflector.php | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Utility/InflectorTest.php b/lib/Cake/Test/Case/Utility/InflectorTest.php index f600ae75776..caf085ad102 100644 --- a/lib/Cake/Test/Case/Utility/InflectorTest.php +++ b/lib/Cake/Test/Case/Utility/InflectorTest.php @@ -177,6 +177,7 @@ public function testInflectingSingulars() { $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 @@ public function testInflectingPlurals() { $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/Utility/Inflector.php b/lib/Cake/Utility/Inflector.php index 6e7b4d4934b..33e4ecf1c93 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' ) ); From b2958dad79926f46c366a28ce5e4d31028a1d782 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 1 Apr 2015 20:37:06 -0400 Subject: [PATCH 156/336] Re-add call to parent destructor. In 762ebd4 a destructor was added to DboSource, this accidentally removed the rollback on destruct that Datasource provides. Restoring this via a parent call allows pending transactions to be rolled back at the end of a request. Fixes #6251 --- lib/Cake/Model/Datasource/DboSource.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index b94d9eb6cd6..80c35120246 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -3563,6 +3563,7 @@ public function __destruct() { if ($this->_methodCacheChange) { Cache::write('method_cache', self::$methodCache, '_cake_core_'); } + parent::__destruct(); } } From f55111bdc1579c0c7db54e3666d40d3e28b68866 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 8 Apr 2015 16:33:28 -0400 Subject: [PATCH 157/336] Allow empty headers to be read. Allow headers with '' and '0' as their values to be read. Fixes #6299 --- lib/Cake/Network/CakeRequest.php | 2 +- lib/Cake/Test/Case/Network/CakeRequestTest.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index d46dbce9cae..a51a74c6531 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -648,7 +648,7 @@ public function here($base = true) { */ 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 8216d5e2bbe..88bbbba6aa6 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -1069,12 +1069,14 @@ public function detectCallback($request) { * @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')); } /** From 900fd3e7e5e41b2fdcb867507a6908978f95e8fd Mon Sep 17 00:00:00 2001 From: Mark van Driel Date: Wed, 8 Apr 2015 17:25:44 +0200 Subject: [PATCH 158/336] Test to demonstrate issue with non-string paths in Hash::get --- lib/Cake/Test/Case/Utility/HashTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index bfb8632795a..cd53af692b4 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -239,6 +239,25 @@ public function testGetInvalidPath() { Hash::get(array('one' => 'two'), true); } +/** + * Test testGetNonStringPath() + * + * @return void + */ + public function testGetNonStringPath() { + $result = Hash::get(array(1.1 => 'one.one'), 1.1); + $this->assertEquals('one.one', $result); + + $result = Hash::get(array('1' => array('1' => 'one.one')), 1.1); + $this->assertNull($result); + + $result = Hash::get(array(true => 'true'), true); + $this->assertEquals('true', $result); + + $result = Hash::get(array('one' => 'two'), null, '-'); + $this->assertEquals('-', $result); + } + /** * Test dimensions. * From 4a7344ae80ad84fba50b95bc8fc832c6ae225436 Mon Sep 17 00:00:00 2001 From: Mark van Driel Date: Thu, 9 Apr 2015 11:59:00 +0200 Subject: [PATCH 159/336] Keep only test for null value as path --- lib/Cake/Test/Case/Utility/HashTest.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index cd53af692b4..dcde12e4f47 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -240,20 +240,11 @@ public function testGetInvalidPath() { } /** - * Test testGetNonStringPath() + * Test testGetNullPath() * * @return void */ - public function testGetNonStringPath() { - $result = Hash::get(array(1.1 => 'one.one'), 1.1); - $this->assertEquals('one.one', $result); - - $result = Hash::get(array('1' => array('1' => 'one.one')), 1.1); - $this->assertNull($result); - - $result = Hash::get(array(true => 'true'), true); - $this->assertEquals('true', $result); - + public function testGetNullPath() { $result = Hash::get(array('one' => 'two'), null, '-'); $this->assertEquals('-', $result); } From a6aefdd4d330259626f9b65e9019b96fc6b68707 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 9 Apr 2015 07:50:29 -0400 Subject: [PATCH 160/336] Fix null path in Hash::get() causing exceptions. This was a regression introduced in 2.6.x Refs #6297 --- lib/Cake/Test/Case/Utility/HashTest.php | 3 +++ lib/Cake/Utility/Hash.php | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index dcde12e4f47..43f40e5d601 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -247,6 +247,9 @@ public function testGetInvalidPath() { public function testGetNullPath() { $result = Hash::get(array('one' => 'two'), null, '-'); $this->assertEquals('-', $result); + + $result = Hash::get(array('one' => 'two'), '', '-'); + $this->assertEquals('-', $result); } /** diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index 9462efcb494..2a18b7e3d08 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 @@ public static function get(array $data, $path, $default = null) { $path )); } - $parts = $path; } From 5f2aa4c307006b587220ce24196dfe9663f55d87 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 9 Apr 2015 20:38:37 -0400 Subject: [PATCH 161/336] Fix errors when testing controllers that use file() Fix errors related to ob_end_clean() closing PHPUnit's output buffer when testing controller methods that use response->file(). --- .../Test/Case/TestSuite/ControllerTestCaseTest.php | 12 ++++++++++++ .../Test/test_app/Controller/TestsAppsController.php | 4 ++++ lib/Cake/TestSuite/ControllerTestCase.php | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php b/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php index bb2df1d3194..e502886d1c2 100644 --- a/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php +++ b/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php @@ -300,6 +300,18 @@ public function testTestAction() { $this->assertSame(302, $Controller->response->statusCode()); } +/** + * 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/test_app/Controller/TestsAppsController.php b/lib/Cake/Test/test_app/Controller/TestsAppsController.php index 8cd847c5dcf..35783548d00 100644 --- a/lib/Cake/Test/test_app/Controller/TestsAppsController.php +++ b/lib/Cake/Test/test_app/Controller/TestsAppsController.php @@ -44,6 +44,10 @@ public function set_action() { $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 8ed11c7da66..fa81bcc6fab 100644 --- a/lib/Cake/TestSuite/ControllerTestCase.php +++ b/lib/Cake/TestSuite/ControllerTestCase.php @@ -271,7 +271,7 @@ protected function _testAction($url, $options = array()) { $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; From b19b76b9f27c874b1eb91a8805782d7f40f3d443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Mon, 13 Apr 2015 18:20:16 +0200 Subject: [PATCH 162/336] Fix parameter type annotation https://github.com/cakephp/cakephp/blob/2.6.3/lib/Cake/Utility/Hash.php#L265 https://github.com/cakephp/cakephp/blob/2.6.3/lib/Cake/Utility/Hash.php#L293 --- lib/Cake/Utility/Hash.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index 2a18b7e3d08..73b60067d8e 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -249,7 +249,7 @@ protected static function _matches(array $data, $selector) { * * @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 */ From f925511a5453d30b15baa103d416bb6e652c8570 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Apr 2015 21:10:15 -0400 Subject: [PATCH 163/336] Update version number to 2.6.4 --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index 9706040e1d8..0a2a95a2b92 100644 --- a/lib/Cake/VERSION.txt +++ b/lib/Cake/VERSION.txt @@ -17,4 +17,4 @@ // @license http://www.opensource.org/licenses/mit-license.php MIT License // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -2.6.3 +2.6.4 From a9ae7fd5bbae6f7c373e65febda1eff375edd9a1 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Mon, 20 Apr 2015 18:31:00 +0200 Subject: [PATCH 164/336] Fix year form field when magic input wrapper is used. s --- lib/Cake/View/Helper/FormHelper.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 880f5fd3fc1..b9a49614b15 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2213,6 +2213,11 @@ public function day($fieldName = null, $attributes = array()) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::year */ public function year($fieldName, $minYear = null, $maxYear = null, $attributes = array()) { + if (is_array($minYear)) { + $attributes = $minYear; + $minYear = null; + } + $attributes += array('empty' => true, 'value' => null); if ((empty($attributes['value']) || $attributes['value'] === true) && $value = $this->value($fieldName)) { if (is_array($value)) { From c71a478876b606f800e509f0e9dbdbac78b5c4fb Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Mon, 20 Apr 2015 18:38:19 +0200 Subject: [PATCH 165/336] Add test case. --- .../Test/Case/View/Helper/FormHelperTest.php | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 4b6cfb7e1c7..598690d30fa 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -7430,6 +7430,53 @@ public function testInputDate() { $this->assertNotContains('value="' . date('d') . '" selected="selected"', $result); } +/** + * testInputDate method + * + * Test various inputs with type date and different option attributes. + * + * @return void + */ + public function testInputDateOptions() { + $this->Form->create('User'); + + $result = $this->Form->input('date', + array( + 'label' => false, + 'type' => 'day', + 'class' => 'form-control' + ) + ); + $this->assertContains('class="form-control"', $result); + + $result = $this->Form->input('date', + array( + 'label' => false, + 'type' => 'month', + 'class' => 'form-control' + ) + ); + $this->assertContains('class="form-control"', $result); + + $result = $this->Form->input('date', + array( + 'label' => false, + 'type' => 'year', + 'class' => 'form-control' + ) + ); + $this->assertContains('class="form-control"', $result); + + $result = $this->Form->input('date', + array( + 'label' => false, + 'type' => 'year', + 'class' => 'form-control' + ) + ); + $this->assertContains('class="form-control"', $result); + } + /** * testInputDateMaxYear method * From 3ba430835648f5f98db1e054422b2d01b18d7e6f Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Mon, 20 Apr 2015 18:39:54 +0200 Subject: [PATCH 166/336] Use hour as field name. --- lib/Cake/Test/Case/View/Helper/FormHelperTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 598690d30fa..bd0dbb2c875 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -7470,7 +7470,7 @@ public function testInputDateOptions() { $result = $this->Form->input('date', array( 'label' => false, - 'type' => 'year', + 'type' => 'hour', 'class' => 'form-control' ) ); From 8cdf222cc045accc661759be3894bb1a8f492dfc Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Mon, 20 Apr 2015 22:04:33 +0200 Subject: [PATCH 167/336] Also fix hour() --- lib/Cake/View/Helper/FormHelper.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index b9a49614b15..032040c99ca 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2315,6 +2315,11 @@ public function month($fieldName, $attributes = array()) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::hour */ public function hour($fieldName, $format24Hours = false, $attributes = array()) { + if (is_array($format24Hours)) { + $attributes = $format24Hours; + $format24Hours = null; + } + $attributes += array('empty' => true, 'value' => null); $attributes = $this->_dateTimeSelected('hour', $fieldName, $attributes); From c31fcd6f3993ad12d366567e03c357358bde40e3 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Tue, 21 Apr 2015 14:32:34 +0200 Subject: [PATCH 168/336] Correct default value to false. --- lib/Cake/View/Helper/FormHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 032040c99ca..2a9f5be6c19 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2317,7 +2317,7 @@ public function month($fieldName, $attributes = array()) { public function hour($fieldName, $format24Hours = false, $attributes = array()) { if (is_array($format24Hours)) { $attributes = $format24Hours; - $format24Hours = null; + $format24Hours = false; } $attributes += array('empty' => true, 'value' => null); From 92455f86e9871899a8a4c776dfafeee476e4a716 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Thu, 30 Apr 2015 14:56:50 +0200 Subject: [PATCH 169/336] Update requirements to what we actually test. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 35e4052ab48..e92b8f69d24 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "source": "https://github.com/cakephp/cakephp" }, "require": { - "php": ">=5.2.8", + "php": ">=5.3.0", "ext-mcrypt": "*" }, "require-dev": { From 309aee9fe5d45dd85e01c30352529fd25e333111 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Thu, 30 Apr 2015 15:18:28 +0200 Subject: [PATCH 170/336] Backport #6431 --- lib/Cake/Network/CakeResponse.php | 1 + lib/Cake/Test/Case/Network/CakeResponseTest.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index 6c8bc2a7ec6..e6d0bf2b3f9 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -68,6 +68,7 @@ class CakeResponse { 415 => 'Unsupported Media Type', 416 => 'Requested range not satisfiable', 417 => 'Expectation Failed', + 429 => 'Too Many Requests', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', diff --git a/lib/Cake/Test/Case/Network/CakeResponseTest.php b/lib/Cake/Test/Case/Network/CakeResponseTest.php index a811b89e52f..82a2f04196c 100644 --- a/lib/Cake/Test/Case/Network/CakeResponseTest.php +++ b/lib/Cake/Test/Case/Network/CakeResponseTest.php @@ -404,7 +404,7 @@ public function testCompress() { public function testHttpCodes() { $response = new CakeResponse(); $result = $response->httpCodes(); - $this->assertEquals(40, count($result)); + $this->assertEquals(41, count($result)); $result = $response->httpCodes(100); $expected = array(100 => 'Continue'); @@ -417,7 +417,7 @@ public function testHttpCodes() { $result = $response->httpCodes($codes); $this->assertTrue($result); - $this->assertEquals(42, count($response->httpCodes())); + $this->assertEquals(43, count($response->httpCodes())); $result = $response->httpCodes(381); $expected = array(381 => 'Unicorn Moved'); @@ -426,7 +426,7 @@ public function testHttpCodes() { $codes = array(404 => 'Sorry Bro'); $result = $response->httpCodes($codes); $this->assertTrue($result); - $this->assertEquals(42, count($response->httpCodes())); + $this->assertEquals(43, count($response->httpCodes())); $result = $response->httpCodes(404); $expected = array(404 => 'Sorry Bro'); From adf2eb03f27f04f49b9151105daa265b24008bc1 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Thu, 30 Apr 2015 15:51:13 +0200 Subject: [PATCH 171/336] Backport jsonOptions --- lib/Cake/Test/Case/View/JsonViewTest.php | 25 ++++++++++++++++++++++++ lib/Cake/View/JsonView.php | 21 ++++++++++++++++---- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Test/Case/View/JsonViewTest.php b/lib/Cake/Test/Case/View/JsonViewTest.php index 4e4eb25742d..aa5027ae11f 100644 --- a/lib/Cake/Test/Case/View/JsonViewTest.php +++ b/lib/Cake/Test/Case/View/JsonViewTest.php @@ -194,6 +194,31 @@ public function testRenderWithoutView($data, $serialize, $expected) { $this->assertSame($expected, $output); } +/** + * Test render with _jsonOptions setting. + * + * @return void + */ + public function testRenderWithoutViewJsonOptions() { + $this->skipIf(!version_compare(PHP_VERSION, '5.3.0', '>='), 'Needs PHP5.3+ for these constants to be tested'); + + $Request = new CakeRequest(); + $Response = new CakeResponse(); + $Controller = new Controller($Request, $Response); + + // Test render with encode <, >, ', &, and " for RFC4627-compliant to be serialized. + $data = array('rfc4627_escape' => ' \'quote\' "double-quote" &'); + $serialize = 'rfc4627_escape'; + $expected = json_encode(' \'quote\' "double-quote" &', JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT); + + $Controller->set($data); + $Controller->set('_serialize', $serialize); + $Controller->set('_jsonOptions', JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT); + $View = new JsonView($Controller); + $output = $View->render(false); + + $this->assertSame($expected, $output); + } /** * Test that rendering with _serialize does not load helpers. * diff --git a/lib/Cake/View/JsonView.php b/lib/Cake/View/JsonView.php index 7953803de85..26d7e004920 100644 --- a/lib/Cake/View/JsonView.php +++ b/lib/Cake/View/JsonView.php @@ -125,6 +125,10 @@ public function render($view = null, $layout = null) { /** * Serialize view vars * + * ### Special parameters + * `_jsonOptions` You can set custom options for json_encode() this way, + * e.g. `JSON_HEX_TAG | JSON_HEX_APOS`. + * * @param array $serialize The viewVars that need to be serialized * @throws CakeException * @return string The serialized data @@ -145,15 +149,24 @@ protected function _serialize($serialize) { $data = isset($this->viewVars[$serialize]) ? $this->viewVars[$serialize] : null; } + $jsonOptions = 0; + if (isset($this->viewVars['_jsonOptions'])) { + if ($this->viewVars['_jsonOptions'] === false) { + $jsonOptions = 0; + } else { + $jsonOptions = $this->viewVars['_jsonOptions']; + } + } if (version_compare(PHP_VERSION, '5.4.0', '>=') && Configure::read('debug')) { - $json = json_encode($data, JSON_PRETTY_PRINT); - } else { - $json = json_encode($data); + $jsonOptions = $jsonOptions | JSON_PRETTY_PRINT; } + $json = json_encode($data, $jsonOptions); + if (function_exists('json_last_error') && json_last_error() !== JSON_ERROR_NONE) { throw new CakeException(json_last_error_msg()); - } elseif ($json === false) { + } + if ($json === false) { throw new CakeException('Failed to parse JSON'); } return $json; From 5e9d4893a8c91233d93727f538ea126d34d92bd3 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 1 May 2015 22:01:45 -0400 Subject: [PATCH 172/336] Add the {*} matcher to Hash::extract() This matcher will match anything and is useful when you just want to traverse through data and you're not too picky. I've also refactored the conditions to use a case as it is slightly more readable and uses fewer lines of code. Refs #6447 --- lib/Cake/Test/Case/Utility/HashTest.php | 22 ++++++++++++++++++++++ lib/Cake/Utility/Hash.php | 19 ++++++++++--------- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index 43f40e5d601..0212885eb1a 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -836,6 +836,28 @@ public function testExtractStringKey() { $this->assertEquals(array('foo'), $result); } +/** + * Test wildcard matcher + * + * @return void + */ + public function testExtractWildcard() { + $data = array( + '02000009C5560001' => array('name' => 'Mr. Alphanumeric'), + '2300000918020101' => array('name' => 'Mr. Numeric'), + '390000096AB30001' => array('name' => 'Mrs. Alphanumeric'), + 'stuff' => array('name' => 'Ms. Word'), + ); + $result = Hash::extract($data, '{*}.name'); + $expected = array( + 'Mr. Alphanumeric', + 'Mr. Numeric', + 'Mrs. Alphanumeric', + 'Ms. Word', + ); + $this->assertEquals($expected, $result); + } + /** * Test the attribute presense selector. * diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index 897ab64c614..142c72b0a26 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -76,6 +76,7 @@ public static function get(array $data, $path, $default = null) { * * - `{n}` Matches any numeric key, or integer. * - `{s}` Matches any string key. + * - `{*}` Matches any value. * - `Foo` Matches any key with the exact same value. * * There are a number of attribute operators: @@ -171,16 +172,16 @@ protected static function _splitConditions($token) { * @return bool */ protected static function _matchToken($key, $token) { - if ($token === '{n}') { - return is_numeric($key); + switch ($token) { + case '{n}': + return is_numeric($key); + case '{s}': + return is_string($key); + case '{*}': + return true; + default: + return is_numeric($token) ? ($key == $token) : $key === $token; } - if ($token === '{s}') { - return is_string($key); - } - if (is_numeric($token)) { - return ($key == $token); - } - return ($key === $token); } /** From 032c01d18cbb9961d544bc4b24f8f81120748112 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 1 May 2015 22:41:41 -0400 Subject: [PATCH 173/336] Add other key types to {*} test. --- lib/Cake/Test/Case/Utility/HashTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index 0212885eb1a..419a7f71ae1 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -847,6 +847,8 @@ public function testExtractWildcard() { '2300000918020101' => array('name' => 'Mr. Numeric'), '390000096AB30001' => array('name' => 'Mrs. Alphanumeric'), 'stuff' => array('name' => 'Ms. Word'), + 123 => array('name' => 'Mr. Number'), + true => array('name' => 'Ms. Bool'), ); $result = Hash::extract($data, '{*}.name'); $expected = array( @@ -854,6 +856,8 @@ public function testExtractWildcard() { 'Mr. Numeric', 'Mrs. Alphanumeric', 'Ms. Word', + 'Mr. Number', + 'Ms. Bool', ); $this->assertEquals($expected, $result); } From ed21f8423658eff738629b351e0896cfed89d1ff Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Sat, 2 May 2015 14:24:02 +0200 Subject: [PATCH 174/336] Backport _xmlOptions --- lib/Cake/Test/Case/View/XmlViewTest.php | 71 +++++++++++++++++++++++++ lib/Cake/View/XmlView.php | 7 +++ 2 files changed, 78 insertions(+) diff --git a/lib/Cake/Test/Case/View/XmlViewTest.php b/lib/Cake/Test/Case/View/XmlViewTest.php index 89399beef32..d90c057aec5 100644 --- a/lib/Cake/Test/Case/View/XmlViewTest.php +++ b/lib/Cake/Test/Case/View/XmlViewTest.php @@ -96,7 +96,78 @@ public function testRenderSerializeNoHelpers() { $this->assertFalse(isset($View->Html), 'No helper loaded.'); } + +/** + * Test that rendering with _serialize respects XML options. + * + * @return void + */ + public function testRenderSerializeWithOptions() { + $Request = new CakeRequest(); + $Response = new CakeResponse(); + $Controller = new Controller($Request, $Response); + $data = [ + '_serialize' => ['tags'], + '_xmlOptions' => ['format' => 'attributes'], + 'tags' => [ + 'tag' => [ + [ + 'id' => '1', + 'name' => 'defect' + ], + [ + 'id' => '2', + 'name' => 'enhancement' + ] + ] + ] + ]; + $Controller->set($data); + $Controller->viewClass = 'Xml'; + $View = new XmlView($Controller); + $result = $View->render(); + + $expected = Xml::build(['response' => ['tags' => $data['tags']]], $data['_xmlOptions'])->asXML(); + $this->assertSame($expected, $result); + } + /** + * Test that rendering with _serialize can work with string setting. + * + * @return void + */ + public function testRenderSerializeWithString() { + $Request = new CakeRequest(); + $Response = new CakeResponse(); + $Controller = new Controller($Request, $Response); + $data = [ + '_serialize' => 'tags', + '_xmlOptions' => ['format' => 'attributes'], + 'tags' => [ + 'tags' => [ + 'tag' => [ + [ + 'id' => '1', + 'name' => 'defect' + ], + [ + 'id' => '2', + 'name' => 'enhancement' + ] + ] + ] + ] + ]; + $Controller->set($data); + $Controller->viewClass = 'Xml'; + $View = new XmlView($Controller); + $result = $View->render(); + + $expected = Xml::build($data['tags'], $data['_xmlOptions'])->asXML(); + $this->assertSame($expected, $result); + } + + /** * Test render with an array in _serialize * * @return void diff --git a/lib/Cake/View/XmlView.php b/lib/Cake/View/XmlView.php index 385543373cb..021854fc4f2 100644 --- a/lib/Cake/View/XmlView.php +++ b/lib/Cake/View/XmlView.php @@ -109,6 +109,10 @@ public function render($view = null, $layout = null) { /** * Serialize view vars. * + * ### Special parameters + * `_xmlOptions` You can set an array of custom options for Xml::fromArray() this way, e.g. + * 'format' as 'attributes' instead of 'tags'. + * * @param array $serialize The viewVars that need to be serialized. * @return string The serialized data */ @@ -131,6 +135,9 @@ protected function _serialize($serialize) { } $options = array(); + if (isset($this->viewVars['_xmlOptions'])) { + $options = $this->viewVars['_xmlOptions']; + } if (Configure::read('debug')) { $options['pretty'] = true; } From cdbf5a0decb26531330d1549d9746fb7022b8d71 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Sat, 2 May 2015 14:26:57 +0200 Subject: [PATCH 175/336] Correct brackets. --- lib/Cake/Test/Case/View/XmlViewTest.php | 52 ++++++++++++------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/Cake/Test/Case/View/XmlViewTest.php b/lib/Cake/Test/Case/View/XmlViewTest.php index d90c057aec5..48b2b6741a4 100644 --- a/lib/Cake/Test/Case/View/XmlViewTest.php +++ b/lib/Cake/Test/Case/View/XmlViewTest.php @@ -106,28 +106,28 @@ public function testRenderSerializeWithOptions() { $Request = new CakeRequest(); $Response = new CakeResponse(); $Controller = new Controller($Request, $Response); - $data = [ - '_serialize' => ['tags'], - '_xmlOptions' => ['format' => 'attributes'], - 'tags' => [ - 'tag' => [ - [ + $data = array( + '_serialize' => array('tags'), + '_xmlOptions' => array('format' => 'attributes'), + 'tags' => array( + 'tag' => array( + array( 'id' => '1', 'name' => 'defect' - ], - [ + ), + array( 'id' => '2', 'name' => 'enhancement' - ] - ] - ] - ]; + ) + ) + ) + ); $Controller->set($data); $Controller->viewClass = 'Xml'; $View = new XmlView($Controller); $result = $View->render(); - $expected = Xml::build(['response' => ['tags' => $data['tags']]], $data['_xmlOptions'])->asXML(); + $expected = Xml::build(array('response' => array('tags' => $data['tags'])), $data['_xmlOptions'])->asXML(); $this->assertSame($expected, $result); } @@ -140,24 +140,24 @@ public function testRenderSerializeWithString() { $Request = new CakeRequest(); $Response = new CakeResponse(); $Controller = new Controller($Request, $Response); - $data = [ + $data = array( '_serialize' => 'tags', - '_xmlOptions' => ['format' => 'attributes'], - 'tags' => [ - 'tags' => [ - 'tag' => [ - [ + '_xmlOptions' => array('format' => 'attributes'), + 'tags' => array( + 'tags' => array( + 'tag' => array( + array( 'id' => '1', 'name' => 'defect' - ], - [ + ), + array( 'id' => '2', 'name' => 'enhancement' - ] - ] - ] - ] - ]; + ) + ) + ) + ) + ); $Controller->set($data); $Controller->viewClass = 'Xml'; $View = new XmlView($Controller); From 8e618ed9e6d2b4bba5fc9faa525f6efe181b6286 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Sat, 2 May 2015 14:31:38 +0200 Subject: [PATCH 176/336] Fix documentation regarding attributes --- lib/Cake/Utility/Xml.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Utility/Xml.php b/lib/Cake/Utility/Xml.php index e3bb4282da4..0cd5e891b5c 100644 --- a/lib/Cake/Utility/Xml.php +++ b/lib/Cake/Utility/Xml.php @@ -156,7 +156,7 @@ protected static function _loadXml($input, $options) { * * ### Options * - * - `format` If create childs ('tags') or attributes ('attribute'). + * - `format` If create childs ('tags') or attributes ('attributes'). * - `pretty` Returns formatted Xml when set to `true`. Defaults to `false` * - `version` Version of XML document. Default is 1.0. * - `encoding` Encoding of XML document. If null remove from XML header. Default is the some of application. @@ -180,7 +180,7 @@ protected static function _loadXml($input, $options) { * * `1defectdescription` * - * And calling `Xml::fromArray($value, 'attribute');` Will generate: + * And calling `Xml::fromArray($value, 'attributes');` Will generate: * * `description` * @@ -229,7 +229,7 @@ public static function fromArray($input, $options = array()) { * @param DOMDocument $dom Handler to DOMDocument * @param DOMElement $node Handler to DOMElement (child) * @param array &$data Array of data to append to the $node. - * @param string $format Either 'attribute' or 'tags'. This determines where nested keys go. + * @param string $format Either 'attributes' or 'tags'. This determines where nested keys go. * @return void * @throws XmlException */ From f510dac32afa69cf6463919ece2093fdd5134037 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Sat, 2 May 2015 16:16:27 +0200 Subject: [PATCH 177/336] fix cs --- lib/Cake/Test/Case/View/XmlViewTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/View/XmlViewTest.php b/lib/Cake/Test/Case/View/XmlViewTest.php index 48b2b6741a4..5498137307d 100644 --- a/lib/Cake/Test/Case/View/XmlViewTest.php +++ b/lib/Cake/Test/Case/View/XmlViewTest.php @@ -96,7 +96,6 @@ public function testRenderSerializeNoHelpers() { $this->assertFalse(isset($View->Html), 'No helper loaded.'); } - /** * Test that rendering with _serialize respects XML options. * @@ -167,7 +166,7 @@ public function testRenderSerializeWithString() { $this->assertSame($expected, $result); } - /** +/** * Test render with an array in _serialize * * @return void From 4915e802c15a189bcb371d282c9dd881bf46dd6a Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Sat, 2 May 2015 16:52:51 +0200 Subject: [PATCH 178/336] Fix tableCells() --- lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php | 15 +++++++++++++++ lib/Cake/View/Helper/HtmlHelper.php | 11 +++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php b/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php index 873f6a955b5..5de35170182 100644 --- a/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php @@ -1926,6 +1926,21 @@ public function testTableCells() { $result = $this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'), false, false); $expected = "td content 1 td content 2 td content 3\ntd content 1 td content 2 td content 3\ntd content 1 td content 2 td content 3"; $this->assertEquals($expected, $result); + + $tr = array( + 'td content 1', + 'td content 2', + array('td content 3', array('class' => 'foo')) + ); + $result = $this->Html->tableCells($tr, null, null, true); + $expected = array( + ' array('class' => 'column-1')), 'td content 1', '/td', + array('td' => array('class' => 'column-2')), 'td content 2', '/td', + array('td' => array('class' => 'foo column-3')), 'td content 3', '/td', + '/tr' + ); + $this->assertTags($result, $expected); } /** diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index adb6220d51e..9f54094469f 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -901,9 +901,16 @@ public function tableCells($data, $oddTrOptions = null, $evenTrOptions = null, $ if (is_array($cell)) { $cellOptions = $cell[1]; $cell = $cell[0]; - } elseif ($useCount) { - $cellOptions['class'] = 'column-' . ++$i; } + + if ($useCount) { + if (isset($cellOptions['class'])) { + $cellOptions['class'] .= ' column-' . ++$i; + } else { + $cellOptions['class'] = 'column-' . ++$i; + } + } + $cellsOut[] = sprintf($this->_tags['tablecell'], $this->_parseAttributes($cellOptions), $cell); } $options = $this->_parseAttributes($count % 2 ? $oddTrOptions : $evenTrOptions); From 6cb21e6dc8b96d5f2e33a8692f4d18ab78dd2ad4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 10 May 2015 21:34:08 -0400 Subject: [PATCH 179/336] Change default value to allow code coverage on non-app files. Don't default to app, as it prevents generating code coverage for core and plugin files. Fixes #6533 --- lib/Cake/TestSuite/CakeTestSuiteDispatcher.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php index 8b8b1e3cad2..d61b232a46a 100644 --- a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php +++ b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php @@ -37,7 +37,7 @@ class CakeTestSuiteDispatcher { 'codeCoverage' => false, 'case' => null, 'core' => false, - 'app' => true, + 'app' => false, 'plugin' => null, 'output' => 'html', 'show' => 'groups', From 4b3386c16f29147bd4ed5c825ae61b1e664aa8c6 Mon Sep 17 00:00:00 2001 From: ovidiupruteanu Date: Mon, 11 May 2015 14:35:20 +0300 Subject: [PATCH 180/336] Replace rtrim with preg_replace in SchemaShell The second parameter of rtrim is a character mask, not a string to be replaced. It was breaking file names ending in one or more 'p' or 'h' characters. --- lib/Cake/Console/Command/SchemaShell.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Console/Command/SchemaShell.php b/lib/Cake/Console/Command/SchemaShell.php index 6f77220d89c..adb9ff4cd79 100644 --- a/lib/Cake/Console/Command/SchemaShell.php +++ b/lib/Cake/Console/Command/SchemaShell.php @@ -158,7 +158,7 @@ public function generate() { } if ($snapshot === true) { - $fileName = rtrim($this->params['file'], '.php'); + $fileName = preg_replace('`\.php$`', '', $this->params['file'], 1); $Folder = new Folder($this->Schema->path); $result = $Folder->read(); @@ -285,7 +285,7 @@ protected function _loadSchema() { 'connection' => $this->params['connection'], ); if (!empty($this->params['snapshot'])) { - $fileName = rtrim($this->Schema->file, '.php'); + $fileName = preg_replace('`\.php$`', '', $this->Schema->file, 1); $options['file'] = $fileName . '_' . $this->params['snapshot'] . '.php'; } From a55685c278ea2d7d035691be45534c68d41c6117 Mon Sep 17 00:00:00 2001 From: ovidiupruteanu Date: Mon, 11 May 2015 14:52:31 +0300 Subject: [PATCH 181/336] Replace preg_replace with basename in SchemaShell --- lib/Cake/Console/Command/SchemaShell.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Console/Command/SchemaShell.php b/lib/Cake/Console/Command/SchemaShell.php index adb9ff4cd79..7648d924ab3 100644 --- a/lib/Cake/Console/Command/SchemaShell.php +++ b/lib/Cake/Console/Command/SchemaShell.php @@ -158,7 +158,7 @@ public function generate() { } if ($snapshot === true) { - $fileName = preg_replace('`\.php$`', '', $this->params['file'], 1); + $fileName = basename($this->params['file'], '.php'); $Folder = new Folder($this->Schema->path); $result = $Folder->read(); @@ -285,7 +285,7 @@ protected function _loadSchema() { 'connection' => $this->params['connection'], ); if (!empty($this->params['snapshot'])) { - $fileName = preg_replace('`\.php$`', '', $this->Schema->file, 1); + $fileName = basename($this->Schema->file, '.php'); $options['file'] = $fileName . '_' . $this->params['snapshot'] . '.php'; } From d4740c9c09b622e1827a84d8e9d84a676b570d3b Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 11 May 2015 21:31:11 -0400 Subject: [PATCH 182/336] Fix incorrect handling of irregular values. When inflecting irregular values, both plural and singular forms were generated incorrectly. Fixes #6538 --- lib/Cake/Test/Case/Utility/InflectorTest.php | 3 +++ lib/Cake/Utility/Inflector.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/InflectorTest.php b/lib/Cake/Test/Case/Utility/InflectorTest.php index caf085ad102..34321509808 100644 --- a/lib/Cake/Test/Case/Utility/InflectorTest.php +++ b/lib/Cake/Test/Case/Utility/InflectorTest.php @@ -123,6 +123,7 @@ public function testInflectingSingulars() { $this->assertEquals(Inflector::singularize('fungi'), 'fungus'); $this->assertEquals(Inflector::singularize('nuclei'), 'nucleus'); $this->assertEquals(Inflector::singularize('octopuses'), 'octopus'); + $this->assertEquals(Inflector::singularize('octopuses'), 'octopus'); $this->assertEquals(Inflector::singularize('radii'), 'radius'); $this->assertEquals(Inflector::singularize('stimuli'), 'stimulus'); $this->assertEquals(Inflector::singularize('syllabi'), 'syllabus'); @@ -178,6 +179,7 @@ public function testInflectingSingulars() { $this->assertEquals(Inflector::singularize('metadata'), 'metadata'); $this->assertEquals(Inflector::singularize('files_metadata'), 'files_metadata'); $this->assertEquals(Inflector::singularize('sieves'), 'sieve'); + $this->assertEquals(Inflector::singularize('blue_octopuses'), 'blue_octopus'); $this->assertEquals(Inflector::singularize(''), ''); } @@ -250,6 +252,7 @@ public function testInflectingPlurals() { $this->assertEquals(Inflector::pluralize('files_metadata'), 'files_metadata'); $this->assertEquals(Inflector::pluralize('stadia'), 'stadia'); $this->assertEquals(Inflector::pluralize('sieve'), 'sieves'); + $this->assertEquals(Inflector::pluralize('blue_octopus'), 'blue_octopuses'); $this->assertEquals(Inflector::pluralize(''), ''); } diff --git a/lib/Cake/Utility/Inflector.php b/lib/Cake/Utility/Inflector.php index 33e4ecf1c93..0d245c517be 100644 --- a/lib/Cake/Utility/Inflector.php +++ b/lib/Cake/Utility/Inflector.php @@ -387,7 +387,7 @@ public static function pluralize($word) { } if (preg_match('/(.*)\\b(' . self::$_plural['cacheIrregular'] . ')$/i', $word, $regs)) { - self::$_cache['pluralize'][$word] = $regs[1] . substr($word, 0, 1) . substr(self::$_plural['merged']['irregular'][strtolower($regs[2])], 1); + self::$_cache['pluralize'][$word] = $regs[1] . substr($regs[2], 0, 1) . substr(self::$_plural['merged']['irregular'][strtolower($regs[2])], 1); return self::$_cache['pluralize'][$word]; } @@ -436,7 +436,7 @@ public static function singularize($word) { } if (preg_match('/(.*)\\b(' . self::$_singular['cacheIrregular'] . ')$/i', $word, $regs)) { - self::$_cache['singularize'][$word] = $regs[1] . substr($word, 0, 1) . substr(self::$_singular['merged']['irregular'][strtolower($regs[2])], 1); + self::$_cache['singularize'][$word] = $regs[1] . substr($regs[2], 0, 1) . substr(self::$_singular['merged']['irregular'][strtolower($regs[2])], 1); return self::$_cache['singularize'][$word]; } From 323e8d8d76af3d182b4c3ebe2ac3ae26f28d2b84 Mon Sep 17 00:00:00 2001 From: ndm2 Date: Tue, 12 May 2015 14:33:15 +0200 Subject: [PATCH 183/336] Add underscore support for multi word irregulars. Underscore separated words were not catched by the irregular regex, tests however didn't fail as the default rules matched the tested words too. The added test should ensure that this won't happen again. Fixes the gap left by the previous #6538 fix. --- lib/Cake/Test/Case/Utility/InflectorTest.php | 25 ++++++++++++++++++++ lib/Cake/Utility/Inflector.php | 4 ++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/InflectorTest.php b/lib/Cake/Test/Case/Utility/InflectorTest.php index 34321509808..b621a1920a1 100644 --- a/lib/Cake/Test/Case/Utility/InflectorTest.php +++ b/lib/Cake/Test/Case/Utility/InflectorTest.php @@ -256,6 +256,31 @@ public function testInflectingPlurals() { $this->assertEquals(Inflector::pluralize(''), ''); } +/** + * testInflectingMultiWordIrregulars + * + * @return void + */ + public function testInflectingMultiWordIrregulars() { + // unset the default rules in order to avoid them possibly matching + // the words in case the irregular regex won't match, the tests + // should fail in that case + Inflector::rules('plural', array( + 'rules' => array(), + )); + Inflector::rules('singular', array( + 'rules' => array(), + )); + + $this->assertEquals(Inflector::singularize('wisdom teeth'), 'wisdom tooth'); + $this->assertEquals(Inflector::singularize('wisdom-teeth'), 'wisdom-tooth'); + $this->assertEquals(Inflector::singularize('wisdom_teeth'), 'wisdom_tooth'); + + $this->assertEquals(Inflector::pluralize('sweet potato'), 'sweet potatoes'); + $this->assertEquals(Inflector::pluralize('sweet-potato'), 'sweet-potatoes'); + $this->assertEquals(Inflector::pluralize('sweet_potato'), 'sweet_potatoes'); + } + /** * testInflectorSlug method * diff --git a/lib/Cake/Utility/Inflector.php b/lib/Cake/Utility/Inflector.php index 0d245c517be..594556b60d0 100644 --- a/lib/Cake/Utility/Inflector.php +++ b/lib/Cake/Utility/Inflector.php @@ -386,7 +386,7 @@ public static function pluralize($word) { self::$_plural['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$_plural['merged']['irregular'])) . ')'; } - if (preg_match('/(.*)\\b(' . self::$_plural['cacheIrregular'] . ')$/i', $word, $regs)) { + if (preg_match('/(.*(?:\\b|_))(' . self::$_plural['cacheIrregular'] . ')$/i', $word, $regs)) { self::$_cache['pluralize'][$word] = $regs[1] . substr($regs[2], 0, 1) . substr(self::$_plural['merged']['irregular'][strtolower($regs[2])], 1); return self::$_cache['pluralize'][$word]; } @@ -435,7 +435,7 @@ public static function singularize($word) { self::$_singular['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$_singular['merged']['irregular'])) . ')'; } - if (preg_match('/(.*)\\b(' . self::$_singular['cacheIrregular'] . ')$/i', $word, $regs)) { + if (preg_match('/(.*(?:\\b|_))(' . self::$_singular['cacheIrregular'] . ')$/i', $word, $regs)) { self::$_cache['singularize'][$word] = $regs[1] . substr($regs[2], 0, 1) . substr(self::$_singular['merged']['irregular'][strtolower($regs[2])], 1); return self::$_cache['singularize'][$word]; } From 6ffc9670d2a238c57fca1bf84e6743967c210223 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 13 May 2015 22:34:46 -0400 Subject: [PATCH 184/336] Document missing option in loadAll(). --- lib/Cake/Core/CakePlugin.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Core/CakePlugin.php b/lib/Cake/Core/CakePlugin.php index 96ce894fd41..5f30887f40a 100644 --- a/lib/Cake/Core/CakePlugin.php +++ b/lib/Cake/Core/CakePlugin.php @@ -48,8 +48,13 @@ class CakePlugin { * * It is also possible to load multiple plugins at once. Examples: * - * `CakePlugin::load(array('DebugKit', 'ApiGenerator'))` will load the DebugKit and ApiGenerator plugins - * `CakePlugin::load(array('DebugKit', 'ApiGenerator'), array('bootstrap' => true))` will load bootstrap file for both plugins + * `CakePlugin::load(array('DebugKit', 'ApiGenerator'))` + * + * will load the DebugKit and ApiGenerator plugins + * + * `CakePlugin::load(array('DebugKit', 'ApiGenerator'), array('bootstrap' => true))` + * + * will load bootstrap file for both plugins * * ``` * CakePlugin::load(array( @@ -107,13 +112,26 @@ public static function load($plugin, $config = array()) { * * ``` * CakePlugin::loadAll(array( - * array('bootstrap' => true), + * array('bootstrap' => true), * 'DebugKit' => array('routes' => true, 'bootstrap' => false), * )) * ``` * * The above example will load the bootstrap file for all plugins, but for DebugKit it will only load - * the routes file and will not look for any bootstrap script. + * the routes file and will not look for any bootstrap script. If you are loading + * many plugins that inconsistently support routes/bootstrap files, instead of detailing + * each plugin you can use the `ignoreMissing` option: + * + * ``` + * CakePlugin::loadAll(array( + * 'ignoreMissing' => true, + * 'bootstrap' => true, + * 'routes' => true, + * )); + * ``` + * + * The ignoreMissing option will do additional file_exists() calls but is simpler + * to use. * * @param array $options Options list. See CakePlugin::load() for valid options. * @return void From 866242643f5ea4da2a567a618ebf7a5a8005b7ad Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Sun, 17 May 2015 22:13:04 +0200 Subject: [PATCH 185/336] Deprecate notEmpty in favor of notBlank. --- lib/Cake/Test/Case/Utility/ValidationTest.php | 34 +++++++++---------- lib/Cake/Utility/Validation.php | 17 ++++++++-- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index 7126f6ecf17..332b1b10b93 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -129,15 +129,15 @@ public function tearDown() { * @return void */ public function testNotEmpty() { - $this->assertTrue(Validation::notEmpty('abcdefg')); - $this->assertTrue(Validation::notEmpty('fasdf ')); - $this->assertTrue(Validation::notEmpty('fooo' . chr(243) . 'blabla')); - $this->assertTrue(Validation::notEmpty('abçďĕʑʘπй')); - $this->assertTrue(Validation::notEmpty('José')); - $this->assertTrue(Validation::notEmpty('é')); - $this->assertTrue(Validation::notEmpty('π')); - $this->assertFalse(Validation::notEmpty("\t ")); - $this->assertFalse(Validation::notEmpty("")); + $this->assertTrue(Validation::notBlank('abcdefg')); + $this->assertTrue(Validation::notBlank('fasdf ')); + $this->assertTrue(Validation::notBlank('fooo' . chr(243) . 'blabla')); + $this->assertTrue(Validation::notBlank('abçďĕʑʘπй')); + $this->assertTrue(Validation::notBlank('José')); + $this->assertTrue(Validation::notBlank('é')); + $this->assertTrue(Validation::notBlank('π')); + $this->assertFalse(Validation::notBlank("\t ")); + $this->assertFalse(Validation::notBlank("")); } /** @@ -147,14 +147,14 @@ public function testNotEmpty() { */ public function testNotEmptyISO88591AppEncoding() { Configure::write('App.encoding', 'ISO-8859-1'); - $this->assertTrue(Validation::notEmpty('abcdefg')); - $this->assertTrue(Validation::notEmpty('fasdf ')); - $this->assertTrue(Validation::notEmpty('fooo' . chr(243) . 'blabla')); - $this->assertTrue(Validation::notEmpty('abçďĕʑʘπй')); - $this->assertTrue(Validation::notEmpty('José')); - $this->assertTrue(Validation::notEmpty(utf8_decode('José'))); - $this->assertFalse(Validation::notEmpty("\t ")); - $this->assertFalse(Validation::notEmpty("")); + $this->assertTrue(Validation::notBlank('abcdefg')); + $this->assertTrue(Validation::notBlank('fasdf ')); + $this->assertTrue(Validation::notBlank('fooo' . chr(243) . 'blabla')); + $this->assertTrue(Validation::notBlank('abçďĕʑʘπй')); + $this->assertTrue(Validation::notBlank('José')); + $this->assertTrue(Validation::notBlank(utf8_decode('José'))); + $this->assertFalse(Validation::notBlank("\t ")); + $this->assertFalse(Validation::notBlank("")); } /** diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index a2243694d16..640f8b1ac54 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -48,6 +48,19 @@ class Validation { */ public static $errors = array(); +/** + * Backwards compatibility wrapper for Validation::notBlank(). + * + * @param string|array $check Value to check. + * @return bool Success. + * @deprecated 2.7.0 Use Validation::notBlank() instead. + * @see Validation::notBlank() + */ + public function notEmpty($check) { + trigger_error('Validation::notEmpty() is deprecated. Use Validation::notBlank() instead.', E_USER_DEPRECATED); + return self::notBlank($check); + } + /** * Checks that a string contains something other than whitespace * @@ -59,7 +72,7 @@ class Validation { * @param string|array $check Value to check * @return bool Success */ - public static function notEmpty($check) { + public static function notBlank($check) { if (is_array($check)) { extract(self::_defaults($check)); } @@ -143,7 +156,7 @@ public static function blank($check) { * Returns true if $check is in the proper credit card format. * * @param string|array $check credit card number to validate - * @param string|array $type 'all' may be passed as a sting, defaults to fast which checks format of most major credit + * @param string|array $type 'all' may be passed as a sting, defaults to fast which checks format of most major credit * cards * if an array is used only the values of the array are checked. * Example: array('amex', 'bankcard', 'maestro') From 4f3602ad5ffcd9a517054e2c41a3450ffaf545f0 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Sun, 17 May 2015 22:27:16 +0200 Subject: [PATCH 186/336] Adjust bake, docblocks and tests for notBlank. --- lib/Cake/Console/Command/Task/ModelTask.php | 4 +- lib/Cake/Model/Model.php | 2 +- lib/Cake/Model/ModelValidator.php | 2 +- .../Model/Validator/CakeValidationSet.php | 4 +- .../Console/Command/Task/ModelTaskTest.php | 22 ++-- .../Test/Case/Controller/ControllerTest.php | 2 +- .../Model/Behavior/TranslateBehaviorTest.php | 2 +- .../Test/Case/Model/ModelValidationTest.php | 104 +++++++++--------- lib/Cake/Test/Case/Model/ModelWriteTest.php | 80 +++++++------- .../Validator/CakeValidationRuleTest.php | 14 +-- .../Model/Validator/CakeValidationSetTest.php | 78 ++++++------- lib/Cake/Test/Case/Model/models.php | 24 ++-- .../Test/Case/View/Helper/FormHelperTest.php | 22 ++-- .../TestPlugin/Model/TestPluginAuthors.php | 4 +- 14 files changed, 182 insertions(+), 182 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index 6979ed44e73..15563dd3f8a 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -443,9 +443,9 @@ public function fieldValidation($fieldName, $metaData, $primaryKey = 'id') { } elseif ($metaData['type'] === 'string' && $metaData['length'] == 36) { $guess = $methods['uuid']; } elseif ($metaData['type'] === 'string') { - $guess = $methods['notEmpty']; + $guess = $methods['notBlank']; } elseif ($metaData['type'] === 'text') { - $guess = $methods['notEmpty']; + $guess = $methods['notBlank']; } elseif ($metaData['type'] === 'integer') { $guess = $methods['numeric']; } elseif ($metaData['type'] === 'float') { diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index f644e3d9c56..4acc36c6241 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -134,7 +134,7 @@ class Model extends Object implements CakeEventListener { * * ``` * public $validate = array( - * 'name' => 'notEmpty' + * 'name' => 'notBlank' * ); * ``` * diff --git a/lib/Cake/Model/ModelValidator.php b/lib/Cake/Model/ModelValidator.php index 474e24bb18e..061055e4efb 100644 --- a/lib/Cake/Model/ModelValidator.php +++ b/lib/Cake/Model/ModelValidator.php @@ -537,7 +537,7 @@ public function count() { * * ``` * $validator - * ->add('title', 'required', array('rule' => 'notEmpty', 'required' => true)) + * ->add('title', 'required', array('rule' => 'notBlank', 'required' => true)) * ->add('user_id', 'valid', array('rule' => 'numeric', 'message' => 'Invalid User')) * * $validator->add('password', array( diff --git a/lib/Cake/Model/Validator/CakeValidationSet.php b/lib/Cake/Model/Validator/CakeValidationSet.php index 7a8457c7e5c..f3420a96f49 100644 --- a/lib/Cake/Model/Validator/CakeValidationSet.php +++ b/lib/Cake/Model/Validator/CakeValidationSet.php @@ -185,7 +185,7 @@ public function getRules() { * * ``` * $set - * ->setRule('required', array('rule' => 'notEmpty', 'required' => true)) + * ->setRule('required', array('rule' => 'notBlank', 'required' => true)) * ->setRule('between', array('rule' => array('lengthBetween', 4, 10)) * ``` * @@ -227,7 +227,7 @@ public function removeRule($name) { * * ``` * $set->setRules(array( - * 'required' => array('rule' => 'notEmpty', 'required' => true), + * 'required' => array('rule' => 'notBlank', 'required' => true), * 'inRange' => array('rule' => array('between', 4, 10) * )); * ``` diff --git a/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php index ce2258bb878..22d6f8e5236 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php @@ -268,7 +268,7 @@ public function testGetTableOddTable() { */ public function testInitValidations() { $result = $this->Task->initValidations(); - $this->assertTrue(in_array('notEmpty', $result)); + $this->assertTrue(in_array('notBlank', $result)); } /** @@ -282,7 +282,7 @@ public function testFieldValidationGuessing() { $this->Task->initValidations(); $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); - $expected = array('notEmpty' => 'notEmpty'); + $expected = array('notBlank' => 'notBlank'); $this->assertEquals($expected, $result); $result = $this->Task->fieldValidation('text', array('type' => 'date', 'length' => 10, 'null' => false)); @@ -318,7 +318,7 @@ public function testInteractiveFieldValidation() { ->will($this->onConsecutiveCalls('25', 'y', '19', 'n')); $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); - $expected = array('notEmpty' => 'notEmpty', 'maxLength' => 'maxLength'); + $expected = array('notBlank' => 'notBlank', 'maxLength' => 'maxLength'); $this->assertEquals($expected, $result); } @@ -339,7 +339,7 @@ public function testInteractiveFieldValidationWithBogusResponse() { ->with($this->stringContains('make a valid')); $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); - $expected = array('notEmpty' => 'notEmpty'); + $expected = array('notBlank' => 'notBlank'); $this->assertEquals($expected, $result); } @@ -371,7 +371,7 @@ public function testSkippingChoiceInteractiveFieldValidation() { ->will($this->onConsecutiveCalls('25', 'y', 's')); $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); - $expected = array('notEmpty' => 'notEmpty', '_skipFields' => true); + $expected = array('notBlank' => 'notBlank', '_skipFields' => true); $this->assertEquals($expected, $result); } @@ -387,7 +387,7 @@ public function testSkippingAnotherInteractiveFieldValidation() { ->will($this->onConsecutiveCalls('25', 's')); $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); - $expected = array('notEmpty' => 'notEmpty', '_skipFields' => true); + $expected = array('notBlank' => 'notBlank', '_skipFields' => true); $this->assertEquals($expected, $result); } @@ -444,7 +444,7 @@ public function testInteractiveDoValidationWithSkipping() { $result = $this->Task->doValidation($Model); $expected = array( 'name' => array( - 'notEmpty' => 'notEmpty' + 'notBlank' => 'notBlank' ), 'email' => array( 'email' => 'email', @@ -502,7 +502,7 @@ public function testNonInteractiveDoValidation() { $result = $this->Task->doValidation($Model); $expected = array( 'name' => array( - 'notEmpty' => 'notEmpty' + 'notBlank' => 'notBlank' ), 'email' => array( 'email' => 'email', @@ -838,7 +838,7 @@ public function testInOptions() { public function testBakeValidation() { $validate = array( 'name' => array( - 'notempty' => 'notEmpty' + 'notBlank' => 'notBlank' ), 'email' => array( 'email' => 'email', @@ -855,8 +855,8 @@ public function testBakeValidation() { $this->assertRegExp('/\$validate \= array\(/', $result); $expected = <<< STRINGEND array( - 'notempty' => array( - 'rule' => array('notEmpty'), + 'notBlank' => array( + 'rule' => array('notBlank'), //'message' => 'Your custom message here', //'allowEmpty' => false, //'required' => false, diff --git a/lib/Cake/Test/Case/Controller/ControllerTest.php b/lib/Cake/Test/Case/Controller/ControllerTest.php index eae1e49b754..534825e3773 100644 --- a/lib/Cake/Test/Case/Controller/ControllerTest.php +++ b/lib/Cake/Test/Case/Controller/ControllerTest.php @@ -1106,7 +1106,7 @@ public function testValidateErrorsOnArbitraryModels() { $TestController = new TestController(); $Post = new ControllerPost(); - $Post->validate = array('title' => 'notEmpty'); + $Post->validate = array('title' => 'notBlank'); $Post->set('title', ''); $result = $TestController->validateErrors($Post); diff --git a/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php b/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php index 3c1fdfe7662..81737576a8a 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php @@ -942,7 +942,7 @@ public function testMultipleUpdate() { $TestModel = new TranslatedItem(); $TestModel->locale = 'eng'; - $TestModel->validate['title'] = 'notEmpty'; + $TestModel->validate['title'] = 'notBlank'; $data = array('TranslatedItem' => array( 'id' => 1, 'title' => array('eng' => 'New Title #1', 'deu' => 'Neue Titel #1', 'cze' => 'Novy Titulek #1'), diff --git a/lib/Cake/Test/Case/Model/ModelValidationTest.php b/lib/Cake/Test/Case/Model/ModelValidationTest.php index 9ec889f800d..ba81c7199f5 100644 --- a/lib/Cake/Test/Case/Model/ModelValidationTest.php +++ b/lib/Cake/Test/Case/Model/ModelValidationTest.php @@ -210,8 +210,8 @@ public function testValidates() { $TestModel->validate = array( 'user_id' => 'numeric', - 'title' => array('allowEmpty' => false, 'rule' => 'notEmpty'), - 'body' => 'notEmpty' + 'title' => array('allowEmpty' => false, 'rule' => 'notBlank'), + 'body' => 'notBlank' ); $data = array('TestValidate' => array( @@ -380,7 +380,7 @@ public function testValidates() { ), 'title' => array( 'allowEmpty' => false, - 'rule' => 'notEmpty' + 'rule' => 'notBlank' )); $data = array('TestValidate' => array( @@ -427,7 +427,7 @@ public function testValidates() { ), 'title' => array( 'allowEmpty' => false, - 'rule' => 'notEmpty' + 'rule' => 'notBlank' )); $data = array('TestValidate' => array( @@ -577,7 +577,7 @@ public function testValidatesWithAssociations() { $Something = new Something(); $JoinThing = $Something->JoinThing; - $JoinThing->validate = array('doomed' => array('rule' => 'notEmpty')); + $JoinThing->validate = array('doomed' => array('rule' => 'notBlank')); $expectedError = array('doomed' => array('This field cannot be left blank')); @@ -620,10 +620,10 @@ public function testValidateWithFieldListAndBehavior() { $TestModel = new ValidationTest1(); $TestModel->validate = array( 'title' => array( - 'rule' => 'notEmpty', + 'rule' => 'notBlank', ), 'name' => array( - 'rule' => 'notEmpty', + 'rule' => 'notBlank', )); $TestModel->Behaviors->attach('ValidationRule', array('fields' => array('name'))); @@ -659,7 +659,7 @@ public function testValidatesWithModelsAndSaveAll() { $Something = new Something(); $JoinThing = $Something->JoinThing; - $JoinThing->validate = array('doomed' => array('rule' => 'notEmpty')); + $JoinThing->validate = array('doomed' => array('rule' => 'notBlank')); $expectedError = array('doomed' => array('This field cannot be left blank')); $Something->create(); @@ -850,8 +850,8 @@ public function testStateValidation() { $Article->validate = array( 'title' => array( - 'notempty' => array( - 'rule' => 'notEmpty', + 'notBlank' => array( + 'rule' => 'notBlank', 'on' => 'create' ) ) @@ -868,8 +868,8 @@ public function testStateValidation() { unset($data['Article']['id']); $Article->validate = array( 'title' => array( - 'notempty' => array( - 'rule' => 'notEmpty', + 'notBlank' => array( + 'rule' => 'notBlank', 'on' => 'update' ) ) @@ -903,8 +903,8 @@ public function testStateRequiredValidation() { $Article->validate = array( 'title' => array( - 'notempty' => array( - 'rule' => 'notEmpty', + 'notBlank' => array( + 'rule' => 'notBlank', 'required' => 'create' ) ) @@ -921,8 +921,8 @@ public function testStateRequiredValidation() { unset($data['Article']['id']); $Article->validate = array( 'title' => array( - 'notempty' => array( - 'rule' => 'notEmpty', + 'notBlank' => array( + 'rule' => 'notBlank', 'required' => 'update' ) ) @@ -956,8 +956,8 @@ public function testOnRequiredConflictValidation() { $Article->validate = array( 'title' => array( - 'notempty' => array( - 'rule' => 'notEmpty', + 'notBlank' => array( + 'rule' => 'notBlank', 'required' => 'create', 'on' => 'create' ) @@ -969,8 +969,8 @@ public function testOnRequiredConflictValidation() { $Article->validate = array( 'title' => array( - 'notempty' => array( - 'rule' => 'notEmpty', + 'notBlank' => array( + 'rule' => 'notBlank', 'required' => 'update', 'on' => 'create' ) @@ -982,8 +982,8 @@ public function testOnRequiredConflictValidation() { $Article->validate = array( 'title' => array( - 'notempty' => array( - 'rule' => 'notEmpty', + 'notBlank' => array( + 'rule' => 'notBlank', 'required' => 'create', 'on' => 'update' ) @@ -995,8 +995,8 @@ public function testOnRequiredConflictValidation() { $Article->validate = array( 'title' => array( - 'notempty' => array( - 'rule' => 'notEmpty', + 'notBlank' => array( + 'rule' => 'notBlank', 'required' => 'update', 'on' => 'update' ) @@ -1008,8 +1008,8 @@ public function testOnRequiredConflictValidation() { $Article->validate = array( 'title' => array( - 'notempty' => array( - 'rule' => 'notEmpty', + 'notBlank' => array( + 'rule' => 'notBlank', 'required' => 'create', 'on' => 'create' ) @@ -1023,8 +1023,8 @@ public function testOnRequiredConflictValidation() { $Article->validate = array( 'title' => array( - 'notempty' => array( - 'rule' => 'notEmpty', + 'notBlank' => array( + 'rule' => 'notBlank', 'required' => 'update', 'on' => 'create' ) @@ -1036,8 +1036,8 @@ public function testOnRequiredConflictValidation() { $Article->validate = array( 'title' => array( - 'notempty' => array( - 'rule' => 'notEmpty', + 'notBlank' => array( + 'rule' => 'notBlank', 'required' => 'create', 'on' => 'update' ) @@ -1049,8 +1049,8 @@ public function testOnRequiredConflictValidation() { $Article->validate = array( 'title' => array( - 'notempty' => array( - 'rule' => 'notEmpty', + 'notBlank' => array( + 'rule' => 'notBlank', 'required' => 'update', 'on' => 'update' ) @@ -1072,8 +1072,8 @@ public function testSaveAllDeepValidateOnly() { $TestModel = new Article(); $TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC'); $TestModel->hasAndBelongsToMany = array(); - $TestModel->Comment->Attachment->validate['attachment'] = 'notEmpty'; - $TestModel->Comment->validate['comment'] = 'notEmpty'; + $TestModel->Comment->Attachment->validate['attachment'] = 'notBlank'; + $TestModel->Comment->validate['comment'] = 'notBlank'; $data = array( 'Article' => array('id' => 2), @@ -1400,8 +1400,8 @@ public function testSaveAllNotDeepValidateOnly() { $TestModel = new Article(); $TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC'); $TestModel->hasAndBelongsToMany = array(); - $TestModel->Comment->Attachment->validate['attachment'] = 'notEmpty'; - $TestModel->Comment->validate['comment'] = 'notEmpty'; + $TestModel->Comment->Attachment->validate['attachment'] = 'notBlank'; + $TestModel->Comment->validate['comment'] = 'notBlank'; $data = array( 'Article' => array('id' => 2, 'body' => ''), @@ -1550,7 +1550,7 @@ public function testSaveAllNotDeepValidateOnly() { public function testValidateAssociated() { $this->loadFixtures('Comment', 'Attachment', 'Article', 'User'); $TestModel = new Comment(); - $TestModel->Attachment->validate = array('attachment' => 'notEmpty'); + $TestModel->Attachment->validate = array('attachment' => 'notBlank'); $data = array( 'Comment' => array( @@ -1577,7 +1577,7 @@ public function testValidateAssociated() { $this->assertTrue($result); $this->assertEmpty($TestModel->validationErrors); - $TestModel->validate = array('comment' => 'notEmpty'); + $TestModel->validate = array('comment' => 'notBlank'); $record = array( 'Comment' => array( 'user_id' => 1, @@ -1608,7 +1608,7 @@ public function testValidateAssociated() { $TestModel = new Article(); $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array(); - $TestModel->Comment->validate = array('comment' => 'notEmpty'); + $TestModel->Comment->validate = array('comment' => 'notBlank'); $data = array( 'Article' => array('id' => 2), 'Comment' => array( @@ -1653,8 +1653,8 @@ public function testValidateAssociated() { $model = new Comment(); $model->deleteAll(true); - $model->validate = array('comment' => 'notEmpty'); - $model->Attachment->validate = array('attachment' => 'notEmpty'); + $model->validate = array('comment' => 'notBlank'); + $model->Attachment->validate = array('attachment' => 'notBlank'); $model->Attachment->bindModel(array('belongsTo' => array('Comment'))); $expected = array( 'comment' => array('This field cannot be left blank'), @@ -1682,7 +1682,7 @@ public function testValidateAssociated() { */ public function testValidateMany() { $TestModel = new Article(); - $TestModel->validate = array('title' => 'notEmpty'); + $TestModel->validate = array('title' => 'notBlank'); $data = array( 0 => array('title' => ''), 1 => array('title' => 'title 1'), @@ -1803,13 +1803,13 @@ public function testArrayAccessGet() { $this->assertEquals('title', $titleValidator->field); $this->assertCount(1, $titleValidator->getRules()); $rule = current($titleValidator->getRules()); - $this->assertEquals('notEmpty', $rule->rule); + $this->assertEquals('notBlank', $rule->rule); $titleValidator = $Validator['body']; $this->assertEquals('body', $titleValidator->field); $this->assertCount(1, $titleValidator->getRules()); $rule = current($titleValidator->getRules()); - $this->assertEquals('notEmpty', $rule->rule); + $this->assertEquals('notBlank', $rule->rule); $titleValidator = $Validator['user_id']; $this->assertEquals('user_id', $titleValidator->field); @@ -1996,8 +1996,8 @@ public function testValidateFirstWithBeforeValidate() { $model = new CustomArticle(); $model->validate = array( 'title' => array( - 'notempty' => array( - 'rule' => 'notEmpty', + 'notBlank' => array( + 'rule' => 'notBlank', 'required' => true, 'allowEmpty' => false ) @@ -2050,8 +2050,8 @@ public function testValidateFirstAssociatedWithBeforeValidate() { $model = new CustomArticle(); $model->validate = array( 'title' => array( - 'notempty' => array( - 'rule' => 'notEmpty', + 'notBlank' => array( + 'rule' => 'notBlank', 'required' => true ) ) @@ -2203,8 +2203,8 @@ public function testValidateFirstAssociatedWithBeforeValidate2() { $model = new CustomArticle(); $model->validate = array( 'title' => array( - 'notempty' => array( - 'rule' => 'notEmpty', + 'notBlank' => array( + 'rule' => 'notBlank', 'required' => true ) ) @@ -2294,7 +2294,7 @@ public function testValidateAssociatedAtomicFalseDeepTrueWithErrors() { $this->loadFixtures('Comment', 'Article', 'User', 'Attachment'); $Attachment = ClassRegistry::init('Attachment'); $Attachment->Comment->validator()->add('comment', array( - array('rule' => 'notEmpty') + array('rule' => 'notBlank') )); $Attachment->Comment->User->bindModel(array( 'hasMany' => array( @@ -2353,7 +2353,7 @@ public function testValidateManyAtomicFalseDeepTrueWithErrors() { $this->loadFixtures('Comment', 'Article', 'User'); $Article = ClassRegistry::init('Article'); $Article->Comment->validator()->add('comment', array( - array('rule' => 'notEmpty') + array('rule' => 'notBlank') )); $data = array( diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index c0349ed4890..f55fb503ce2 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -879,7 +879,7 @@ public function testSaveTransaction() { // Check if Database supports transactions - $PostModel->validate = array('title' => 'notEmpty'); + $PostModel->validate = array('title' => 'notBlank'); $data = array( array('author_id' => 1, 'title' => 'New Fourth Post'), array('author_id' => 1, 'title' => 'New Fifth Post'), @@ -3413,8 +3413,8 @@ public function testSaveAllHasOneValidation() { $model->Attachment->deleteAll(true); $this->assertEquals(array(), $model->Attachment->find('all')); - $model->validate = array('comment' => 'notEmpty'); - $model->Attachment->validate = array('attachment' => 'notEmpty'); + $model->validate = array('comment' => 'notBlank'); + $model->Attachment->validate = array('attachment' => 'notBlank'); $model->Attachment->bindModel(array('belongsTo' => array('Comment'))); $result = $model->saveAll( @@ -3496,7 +3496,7 @@ public function testSaveAllAtomic() { $this->assertSame($result, array('Article' => true, 'Comment' => array(true, true))); $TestModel->validate = array( - 'title' => 'notEmpty', + 'title' => 'notBlank', 'author_id' => 'numeric' ); $result = $TestModel->saveAll(array( @@ -3701,7 +3701,7 @@ public function testSaveAllDeepMany() { ) ) ); - $TestModel->Comment->validate['comment'] = 'notEmpty'; + $TestModel->Comment->validate['comment'] = 'notBlank'; $result = $TestModel->saveAll($data, array('deep' => true)); $this->assertFalse($result); @@ -3744,8 +3744,8 @@ public function testSaveAllDeepValidateOnly() { $TestModel = new Article(); $TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC'); $TestModel->hasAndBelongsToMany = array(); - $TestModel->Comment->Attachment->validate['attachment'] = 'notEmpty'; - $TestModel->Comment->validate['comment'] = 'notEmpty'; + $TestModel->Comment->Attachment->validate['attachment'] = 'notBlank'; + $TestModel->Comment->validate['comment'] = 'notBlank'; $result = $TestModel->saveAll( array( @@ -4155,7 +4155,7 @@ public function testSaveAllNotDeepMany() { ) ) ); - $TestModel->Comment->validate['comment'] = 'notEmpty'; + $TestModel->Comment->validate['comment'] = 'notBlank'; $result = $TestModel->saveAll($data, array('deep' => false)); $this->assertFalse($result); @@ -4195,8 +4195,8 @@ public function testSaveAllNotDeepValidateOnly() { $TestModel = new Article(); $TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC'); $TestModel->hasAndBelongsToMany = array(); - $TestModel->Comment->Attachment->validate['attachment'] = 'notEmpty'; - $TestModel->Comment->validate['comment'] = 'notEmpty'; + $TestModel->Comment->Attachment->validate['attachment'] = 'notBlank'; + $TestModel->Comment->validate['comment'] = 'notBlank'; $result = $TestModel->saveAll( array( @@ -4416,7 +4416,7 @@ public function testSaveAllHasManyValidation() { $this->loadFixtures('Article', 'Comment'); $TestModel = new Article(); $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array(); - $TestModel->Comment->validate = array('comment' => 'notEmpty'); + $TestModel->Comment->validate = array('comment' => 'notBlank'); $result = $TestModel->saveAll(array( 'Article' => array('id' => 2), @@ -4457,7 +4457,7 @@ public function testSaveAllManyRowsTransactionNoRollback() { $Post = new TestPost(); $Post->validate = array( - 'title' => array('rule' => array('notEmpty')) + 'title' => array('rule' => array('notBlank')) ); // If validation error occurs, rollback() should be called. @@ -4518,7 +4518,7 @@ public function testSaveAllAssociatedTransactionNoRollback() { $Post = new TestPost(); $Post->Author->validate = array( - 'user' => array('rule' => array('notEmpty')) + 'user' => array('rule' => array('notBlank')) ); // If validation error occurs, rollback() should be called. @@ -4618,7 +4618,7 @@ public function testSaveAllTransaction() { $this->loadFixtures('Post', 'Author', 'Comment', 'Attachment'); $TestModel = new Post(); - $TestModel->validate = array('title' => 'notEmpty'); + $TestModel->validate = array('title' => 'notBlank'); $data = array( array('author_id' => 1, 'title' => 'New Fourth Post'), array('author_id' => 1, 'title' => 'New Fifth Post'), @@ -4750,7 +4750,7 @@ public function testSaveAllTransaction() { } $this->assertEquals($expected, $result); - $TestModel->validate = array('title' => 'notEmpty'); + $TestModel->validate = array('title' => 'notBlank'); $data = array( array('author_id' => 1, 'title' => 'New Fourth Post'), array('author_id' => 1, 'title' => 'New Fifth Post'), @@ -4878,7 +4878,7 @@ public function testSaveAllValidation() { unset($result[3]['Post']['created'], $result[3]['Post']['updated']); $this->assertEquals($expected, $result); - $TestModel->validate = array('title' => 'notEmpty', 'author_id' => 'numeric'); + $TestModel->validate = array('title' => 'notBlank', 'author_id' => 'numeric'); $data = array( array( 'id' => '1', @@ -4904,7 +4904,7 @@ public function testSaveAllValidation() { $this->assertEquals($errors, $TestModel->validationErrors); - $TestModel->validate = array('title' => 'notEmpty', 'author_id' => 'numeric'); + $TestModel->validate = array('title' => 'notBlank', 'author_id' => 'numeric'); $data = array( array( 'id' => '1', @@ -5006,7 +5006,7 @@ public function testSaveAllValidation() { public function testSaveAllValidationOnly() { $this->loadFixtures('Comment', 'Attachment'); $TestModel = new Comment(); - $TestModel->Attachment->validate = array('attachment' => 'notEmpty'); + $TestModel->Attachment->validate = array('attachment' => 'notBlank'); $data = array( 'Comment' => array( @@ -5021,7 +5021,7 @@ public function testSaveAllValidationOnly() { $this->assertFalse($result); $TestModel = new Article(); - $TestModel->validate = array('title' => 'notEmpty'); + $TestModel->validate = array('title' => 'notBlank'); $result = $TestModel->saveAll( array( 0 => array('title' => ''), @@ -5061,7 +5061,7 @@ public function testSaveAllValidateFirst() { $model = new Article(); $model->deleteAll(true); - $model->Comment->validate = array('comment' => 'notEmpty'); + $model->Comment->validate = array('comment' => 'notBlank'); $result = $model->saveAll(array( 'Article' => array( 'title' => 'Post with Author', @@ -5198,7 +5198,7 @@ public function testSaveAllHasManyValidationOnly() { $this->loadFixtures('Article', 'Comment', 'Attachment'); $TestModel = new Article(); $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array(); - $TestModel->Comment->validate = array('comment' => 'notEmpty'); + $TestModel->Comment->validate = array('comment' => 'notBlank'); $result = $TestModel->saveAll( array( @@ -5406,7 +5406,7 @@ public function testSaveAssociatedAtomicFalseValidateFirstWithErrors() { $this->loadFixtures('Comment', 'Article', 'User'); $Article = ClassRegistry::init('Article'); $Article->Comment->validator()->add('comment', array( - array('rule' => 'notEmpty') + array('rule' => 'notBlank') )); $data = array( @@ -5694,8 +5694,8 @@ public function testSaveAssociatedHasOneValidation() { $model->Attachment->deleteAll(true); $this->assertEquals(array(), $model->Attachment->find('all')); - $model->validate = array('comment' => 'notEmpty'); - $model->Attachment->validate = array('attachment' => 'notEmpty'); + $model->validate = array('comment' => 'notBlank'); + $model->Attachment->validate = array('attachment' => 'notBlank'); $model->Attachment->bindModel(array('belongsTo' => array('Comment'))); $result = $model->saveAssociated( @@ -5789,7 +5789,7 @@ public function testSaveManyAtomic() { ), array('atomic' => false)); $this->assertSame($result, array(true, true, true)); - $TestModel->validate = array('title' => 'notEmpty', 'author_id' => 'numeric'); + $TestModel->validate = array('title' => 'notBlank', 'author_id' => 'numeric'); $result = $TestModel->saveMany(array( array( 'id' => '1', @@ -5892,7 +5892,7 @@ public function testSaveAssociatedHasManyEmpty() { $this->loadFixtures('Article', 'Comment'); $TestModel = new Article(); $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array(); - $TestModel->validate = $TestModel->Comment->validate = array('user_id' => array('notEmpty' => array('rule' => 'notEmpty', 'required' => true))); + $TestModel->validate = $TestModel->Comment->validate = array('user_id' => array('notBlank' => array('rule' => 'notBlank', 'required' => true))); //empty hasMany data is ignored in save $result = $TestModel->saveAssociated(array( @@ -5924,7 +5924,7 @@ public function testSaveAssociatedHasManyValidation() { $this->loadFixtures('Article', 'Comment'); $TestModel = new Article(); $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array(); - $TestModel->Comment->validate = array('comment' => 'notEmpty'); + $TestModel->Comment->validate = array('comment' => 'notBlank'); $result = $TestModel->saveAssociated(array( 'Article' => array('id' => 2), @@ -5965,7 +5965,7 @@ public function testSaveManyTransactionNoRollback() { $Post = new TestPost(); $Post->validate = array( - 'title' => array('rule' => array('notEmpty')) + 'title' => array('rule' => array('notBlank')) ); // If validation error occurs, rollback() should be called. @@ -6026,7 +6026,7 @@ public function testSaveAssociatedTransactionNoRollback() { $Post = new TestPost(); $Post->Author->validate = array( - 'user' => array('rule' => array('notEmpty')) + 'user' => array('rule' => array('notBlank')) ); // If validation error occurs, rollback() should be called. @@ -6126,7 +6126,7 @@ public function testSaveManyTransaction() { $this->loadFixtures('Post', 'Author', 'Comment', 'Attachment'); $TestModel = new Post(); - $TestModel->validate = array('title' => 'notEmpty'); + $TestModel->validate = array('title' => 'notBlank'); $data = array( array('author_id' => 1, 'title' => 'New Fourth Post'), array('author_id' => 1, 'title' => 'New Fifth Post'), @@ -6262,7 +6262,7 @@ public function testSaveManyTransaction() { } $this->assertEquals($expected, $result); - $TestModel->validate = array('title' => 'notEmpty'); + $TestModel->validate = array('title' => 'notBlank'); $data = array( array('author_id' => 1, 'title' => 'New Fourth Post'), array('author_id' => 1, 'title' => 'New Fifth Post'), @@ -6395,7 +6395,7 @@ public function testSaveManyValidation() { unset($result[3]['Post']['created'], $result[3]['Post']['updated']); $this->assertEquals($expected, $result); - $TestModel->validate = array('title' => 'notEmpty', 'author_id' => 'numeric'); + $TestModel->validate = array('title' => 'notBlank', 'author_id' => 'numeric'); $data = array( array( 'id' => '1', @@ -6421,7 +6421,7 @@ public function testSaveManyValidation() { $this->assertEquals($errors, $TestModel->validationErrors); - $TestModel->validate = array('title' => 'notEmpty', 'author_id' => 'numeric'); + $TestModel->validate = array('title' => 'notBlank', 'author_id' => 'numeric'); $data = array( array( 'id' => '1', @@ -6509,7 +6509,7 @@ public function testSaveManyValidation() { */ public function testValidateMany() { $TestModel = new Article(); - $TestModel->validate = array('title' => 'notEmpty'); + $TestModel->validate = array('title' => 'notBlank'); $data = array( 0 => array('title' => ''), 1 => array('title' => 'title 1'), @@ -6545,7 +6545,7 @@ public function testSaveAssociatedValidateFirst() { $model = new Article(); $model->deleteAll(true); - $model->Comment->validate = array('comment' => 'notEmpty'); + $model->Comment->validate = array('comment' => 'notBlank'); $result = $model->saveAssociated(array( 'Article' => array( 'title' => 'Post with Author', @@ -6680,7 +6680,7 @@ public function testSaveManyValidateFirstAtomicFalse() { public function testValidateAssociated() { $this->loadFixtures('Attachment', 'Article', 'Comment'); $TestModel = new Comment(); - $TestModel->Attachment->validate = array('attachment' => 'notEmpty'); + $TestModel->Attachment->validate = array('attachment' => 'notBlank'); $data = array( 'Comment' => array( @@ -6696,7 +6696,7 @@ public function testValidateAssociated() { $TestModel = new Article(); $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array(); - $TestModel->Comment->validate = array('comment' => 'notEmpty'); + $TestModel->Comment->validate = array('comment' => 'notBlank'); $data = array( 'Article' => array('id' => 2), @@ -7331,8 +7331,8 @@ public function testSaveAllFieldListHasOne() { $this->loadFixtures('Attachment', 'Comment', 'Article', 'User'); $TestModel = new Comment(); - $TestModel->validate = array('comment' => 'notEmpty'); - $TestModel->Attachment->validate = array('attachment' => 'notEmpty'); + $TestModel->validate = array('comment' => 'notBlank'); + $TestModel->Attachment->validate = array('attachment' => 'notBlank'); $record = array( 'Comment' => array( @@ -7367,7 +7367,7 @@ public function testSaveAllFieldListHasOneAddFkToWhitelist() { $this->loadFixtures('ArticleFeatured', 'Featured'); $Article = new ArticleFeatured(); $Article->belongsTo = $Article->hasMany = array(); - $Article->Featured->validate = array('end_date' => 'notEmpty'); + $Article->Featured->validate = array('end_date' => 'notBlank'); $record = array( 'ArticleFeatured' => array( diff --git a/lib/Cake/Test/Case/Model/Validator/CakeValidationRuleTest.php b/lib/Cake/Test/Case/Model/Validator/CakeValidationRuleTest.php index 970ca7a10ff..5b1a9caffb4 100644 --- a/lib/Cake/Test/Case/Model/Validator/CakeValidationRuleTest.php +++ b/lib/Cake/Test/Case/Model/Validator/CakeValidationRuleTest.php @@ -58,7 +58,7 @@ public function myTestRule3() { * @return void */ public function testIsValid() { - $def = array('rule' => 'notEmpty', 'message' => 'Can not be empty'); + $def = array('rule' => 'notBlank', 'message' => 'Can not be empty'); $data = array( 'fieldName' => '' ); @@ -122,19 +122,19 @@ public function testCustomMethodMissingError() { * @return void */ public function testIsRequired() { - $def = array('rule' => 'notEmpty', 'required' => true); + $def = array('rule' => 'notBlank', 'required' => true); $Rule = new CakeValidationRule($def); $this->assertTrue($Rule->isRequired()); - $def = array('rule' => 'notEmpty', 'required' => false); + $def = array('rule' => 'notBlank', 'required' => false); $Rule = new CakeValidationRule($def); $this->assertFalse($Rule->isRequired()); - $def = array('rule' => 'notEmpty', 'required' => 'create'); + $def = array('rule' => 'notBlank', 'required' => 'create'); $Rule = new CakeValidationRule($def); $this->assertTrue($Rule->isRequired()); - $def = array('rule' => 'notEmpty', 'required' => 'update'); + $def = array('rule' => 'notBlank', 'required' => 'update'); $Rule = new CakeValidationRule($def); $this->assertFalse($Rule->isRequired()); @@ -156,14 +156,14 @@ public function testIsEmptyAllowed() { $Rule = new CakeValidationRule($def); $this->assertFalse($Rule->isEmptyAllowed()); - $def = array('rule' => 'notEmpty', 'allowEmpty' => false, 'on' => 'update'); + $def = array('rule' => 'notBlank', 'allowEmpty' => false, 'on' => 'update'); $Rule = new CakeValidationRule($def); $this->assertTrue($Rule->isEmptyAllowed()); $Rule->isUpdate(true); $this->assertFalse($Rule->isEmptyAllowed()); - $def = array('rule' => 'notEmpty', 'allowEmpty' => false, 'on' => 'create'); + $def = array('rule' => 'notBlank', 'allowEmpty' => false, 'on' => 'create'); $Rule = new CakeValidationRule($def); $this->assertFalse($Rule->isEmptyAllowed()); diff --git a/lib/Cake/Test/Case/Model/Validator/CakeValidationSetTest.php b/lib/Cake/Test/Case/Model/Validator/CakeValidationSetTest.php index ecd9e444e3d..ee2b178a864 100644 --- a/lib/Cake/Test/Case/Model/Validator/CakeValidationSetTest.php +++ b/lib/Cake/Test/Case/Model/Validator/CakeValidationSetTest.php @@ -41,7 +41,7 @@ public function setUp() { * @return void */ public function testValidate() { - $Field = new CakeValidationSet('title', 'notEmpty'); + $Field = new CakeValidationSet('title', 'notBlank'); $data = array( 'title' => '', 'body' => 'a body' @@ -51,20 +51,20 @@ public function testValidate() { $expected = array('This field cannot be left blank'); $this->assertEquals($expected, $result); - $Field = new CakeValidationSet('body', 'notEmpty'); + $Field = new CakeValidationSet('body', 'notBlank'); $result = $Field->validate($data); $this->assertEmpty($result); $Field = new CakeValidationSet('nothere', array( - 'notEmpty' => array( - 'rule' => 'notEmpty', + 'notBlank' => array( + 'rule' => 'notBlank', 'required' => true ) )); $result = $Field->validate($data); - $expected = array('notEmpty'); + $expected = array('notBlank'); $this->assertEquals($expected, $result); $Field = new CakeValidationSet('body', array( @@ -83,11 +83,11 @@ public function testValidate() { * @return void */ public function testGetRule() { - $rules = array('notEmpty' => array('rule' => 'notEmpty', 'message' => 'Can not be empty')); + $rules = array('notBlank' => array('rule' => 'notBlank', 'message' => 'Can not be empty')); $Field = new CakeValidationSet('title', $rules); - $result = $Field->getRule('notEmpty'); + $result = $Field->getRule('notBlank'); $this->assertInstanceOf('CakeValidationRule', $result); - $this->assertEquals('notEmpty', $result->rule); + $this->assertEquals('notBlank', $result->rule); $this->assertEquals(null, $result->required); $this->assertEquals(false, $result->allowEmpty); $this->assertEquals(null, $result->on); @@ -101,12 +101,12 @@ public function testGetRule() { * @return void */ public function testGetRules() { - $rules = array('notEmpty' => array('rule' => 'notEmpty', 'message' => 'Can not be empty')); + $rules = array('notBlank' => array('rule' => 'notBlank', 'message' => 'Can not be empty')); $Field = new CakeValidationSet('title', $rules); $result = $Field->getRules(); - $this->assertEquals(array('notEmpty'), array_keys($result)); - $this->assertInstanceOf('CakeValidationRule', $result['notEmpty']); + $this->assertEquals(array('notBlank'), array_keys($result)); + $this->assertInstanceOf('CakeValidationRule', $result['notBlank']); } /** @@ -115,23 +115,23 @@ public function testGetRules() { * @return void */ public function testSetRule() { - $rules = array('notEmpty' => array('rule' => 'notEmpty', 'message' => 'Can not be empty')); + $rules = array('notBlank' => array('rule' => 'notBlank', 'message' => 'Can not be empty')); $Field = new CakeValidationSet('title', $rules); - $Rule = new CakeValidationRule($rules['notEmpty']); + $Rule = new CakeValidationRule($rules['notBlank']); - $this->assertEquals($Rule, $Field->getRule('notEmpty')); + $this->assertEquals($Rule, $Field->getRule('notBlank')); $rules = array('validEmail' => array('rule' => 'email', 'message' => 'Invalid email')); $Rule = new CakeValidationRule($rules['validEmail']); $Field->setRule('validEmail', $Rule); $result = $Field->getRules(); - $this->assertEquals(array('notEmpty', 'validEmail'), array_keys($result)); + $this->assertEquals(array('notBlank', 'validEmail'), array_keys($result)); $rules = array('validEmail' => array('rule' => 'email', 'message' => 'Other message')); $Rule = new CakeValidationRule($rules['validEmail']); $Field->setRule('validEmail', $Rule); $result = $Field->getRules(); - $this->assertEquals(array('notEmpty', 'validEmail'), array_keys($result)); + $this->assertEquals(array('notBlank', 'validEmail'), array_keys($result)); $result = $Field->getRule('validEmail'); $this->assertInstanceOf('CakeValidationRule', $result); $this->assertEquals('email', $result->rule); @@ -148,9 +148,9 @@ public function testSetRule() { * @return void */ public function testSetRules() { - $rule = array('notEmpty' => array('rule' => 'notEmpty', 'message' => 'Can not be empty')); + $rule = array('notBlank' => array('rule' => 'notBlank', 'message' => 'Can not be empty')); $Field = new CakeValidationSet('title', $rule); - $RuleEmpty = new CakeValidationRule($rule['notEmpty']); + $RuleEmpty = new CakeValidationRule($rule['notBlank']); $rule = array('validEmail' => array('rule' => 'email', 'message' => 'Invalid email')); $RuleEmail = new CakeValidationRule($rule['validEmail']); @@ -165,15 +165,15 @@ public function testSetRules() { $this->assertEquals(array('validEmail'), array_keys($result)); $this->assertTrue(array_pop($result) instanceof CakeValidationRule); - $rules = array('notEmpty' => $RuleEmpty); + $rules = array('notBlank' => $RuleEmpty); $Field->setRules($rules, true); $result = $Field->getRules(); - $this->assertEquals(array('validEmail', 'notEmpty'), array_keys($result)); + $this->assertEquals(array('validEmail', 'notBlank'), array_keys($result)); - $rules = array('notEmpty' => array('rule' => 'notEmpty')); + $rules = array('notBlank' => array('rule' => 'notBlank')); $Field->setRules($rules, true); $result = $Field->getRules(); - $this->assertEquals(array('validEmail', 'notEmpty'), array_keys($result)); + $this->assertEquals(array('validEmail', 'notBlank'), array_keys($result)); $this->assertTrue(array_pop($result) instanceof CakeValidationRule); $this->assertTrue(array_pop($result) instanceof CakeValidationRule); } @@ -185,14 +185,14 @@ public function testSetRules() { */ public function testArrayAccessGet() { $Set = new CakeValidationSet('title', array( - 'notEmpty' => array('rule' => 'notEmpty', 'required' => true), + 'notBlank' => array('rule' => 'notBlank', 'required' => true), 'numeric' => array('rule' => 'numeric'), 'other' => array('rule' => array('other', 1)), )); - $rule = $Set['notEmpty']; + $rule = $Set['notBlank']; $this->assertInstanceOf('CakeValidationRule', $rule); - $this->assertEquals('notEmpty', $rule->rule); + $this->assertEquals('notBlank', $rule->rule); $rule = $Set['numeric']; $this->assertInstanceOf('CakeValidationRule', $rule); @@ -210,12 +210,12 @@ public function testArrayAccessGet() { */ public function testArrayAccessExists() { $Set = new CakeValidationSet('title', array( - 'notEmpty' => array('rule' => 'notEmpty', 'required' => true), + 'notBlank' => array('rule' => 'notBlank', 'required' => true), 'numeric' => array('rule' => 'numeric'), 'other' => array('rule' => array('other', 1)), )); - $this->assertTrue(isset($Set['notEmpty'])); + $this->assertTrue(isset($Set['notBlank'])); $this->assertTrue(isset($Set['numeric'])); $this->assertTrue(isset($Set['other'])); $this->assertFalse(isset($Set['fail'])); @@ -228,7 +228,7 @@ public function testArrayAccessExists() { */ public function testArrayAccessSet() { $Set = new CakeValidationSet('title', array( - 'notEmpty' => array('rule' => 'notEmpty', 'required' => true), + 'notBlank' => array('rule' => 'notBlank', 'required' => true), )); $this->assertFalse(isset($Set['other'])); @@ -251,19 +251,19 @@ public function testArrayAccessSet() { */ public function testArrayAccessUnset() { $Set = new CakeValidationSet('title', array( - 'notEmpty' => array('rule' => 'notEmpty', 'required' => true), + 'notBlank' => array('rule' => 'notBlank', 'required' => true), 'numeric' => array('rule' => 'numeric'), 'other' => array('rule' => array('other', 1)), )); - unset($Set['notEmpty']); - $this->assertFalse(isset($Set['notEmpty'])); + unset($Set['notBlank']); + $this->assertFalse(isset($Set['notBlank'])); unset($Set['numeric']); - $this->assertFalse(isset($Set['notEmpty'])); + $this->assertFalse(isset($Set['notBlank'])); unset($Set['other']); - $this->assertFalse(isset($Set['notEmpty'])); + $this->assertFalse(isset($Set['notBlank'])); } /** @@ -273,7 +273,7 @@ public function testArrayAccessUnset() { */ public function testIterator() { $Set = new CakeValidationSet('title', array( - 'notEmpty' => array('rule' => 'notEmpty', 'required' => true), + 'notBlank' => array('rule' => 'notBlank', 'required' => true), 'numeric' => array('rule' => 'numeric'), 'other' => array('rule' => array('other', 1)), )); @@ -281,7 +281,7 @@ public function testIterator() { $i = 0; foreach ($Set as $name => $rule) { if ($i === 0) { - $this->assertEquals('notEmpty', $name); + $this->assertEquals('notBlank', $name); } if ($i === 1) { $this->assertEquals('numeric', $name); @@ -302,7 +302,7 @@ public function testIterator() { */ public function testCount() { $Set = new CakeValidationSet('title', array( - 'notEmpty' => array('rule' => 'notEmpty', 'required' => true), + 'notBlank' => array('rule' => 'notBlank', 'required' => true), 'numeric' => array('rule' => 'numeric'), 'other' => array('rule' => array('other', 1)), )); @@ -319,13 +319,13 @@ public function testCount() { */ public function testRemoveRule() { $Set = new CakeValidationSet('title', array( - 'notEmpty' => array('rule' => 'notEmpty', 'required' => true), + 'notBlank' => array('rule' => 'notBlank', 'required' => true), 'numeric' => array('rule' => 'numeric'), 'other' => array('rule' => array('other', 1)), )); - $Set->removeRule('notEmpty'); - $this->assertFalse(isset($Set['notEmpty'])); + $Set->removeRule('notBlank'); + $this->assertFalse(isset($Set['notBlank'])); $Set->removeRule('numeric'); $this->assertFalse(isset($Set['numeric'])); diff --git a/lib/Cake/Test/Case/Model/models.php b/lib/Cake/Test/Case/Model/models.php index ced7a56b367..32ae09145c8 100644 --- a/lib/Cake/Test/Case/Model/models.php +++ b/lib/Cake/Test/Case/Model/models.php @@ -208,7 +208,7 @@ class User extends CakeTestModel { * * @var array */ - public $validate = array('user' => 'notEmpty', 'password' => 'notEmpty'); + public $validate = array('user' => 'notBlank', 'password' => 'notBlank'); /** * beforeFind() callback used to run ContainableBehaviorTest::testLazyLoad() @@ -269,8 +269,8 @@ class Article extends CakeTestModel { */ public $validate = array( 'user_id' => 'numeric', - 'title' => array('required' => false, 'rule' => 'notEmpty'), - 'body' => array('required' => false, 'rule' => 'notEmpty'), + 'title' => array('required' => false, 'rule' => 'notBlank'), + 'body' => array('required' => false, 'rule' => 'notBlank'), ); /** @@ -424,7 +424,7 @@ class ArticleFeatured extends CakeTestModel { * * @var array */ - public $validate = array('user_id' => 'numeric', 'title' => 'notEmpty', 'body' => 'notEmpty'); + public $validate = array('user_id' => 'numeric', 'title' => 'notBlank', 'body' => 'notBlank'); } @@ -802,7 +802,7 @@ class Apple extends CakeTestModel { * * @var array */ - public $validate = array('name' => 'notEmpty'); + public $validate = array('name' => 'notBlank'); /** * hasOne property @@ -1197,7 +1197,7 @@ class NodeAfterFind extends CakeTestModel { * * @var array */ - public $validate = array('name' => 'notEmpty'); + public $validate = array('name' => 'notBlank'); /** * useTable property @@ -1287,7 +1287,7 @@ class NodeNoAfterFind extends CakeTestModel { * * @var array */ - public $validate = array('name' => 'notEmpty'); + public $validate = array('name' => 'notBlank'); /** * useTable property @@ -2191,10 +2191,10 @@ class ValidationTest1 extends CakeTestModel { * @var array */ public $validate = array( - 'title' => 'notEmpty', + 'title' => 'notBlank', 'published' => 'customValidationMethod', 'body' => array( - 'notEmpty', + 'notBlank', '/^.{5,}$/s' => 'no matchy', '/^[0-9A-Za-z \\.]{1,}$/s' ) @@ -2270,10 +2270,10 @@ class ValidationTest2 extends CakeTestModel { * @var array */ public $validate = array( - 'title' => 'notEmpty', + 'title' => 'notBlank', 'published' => 'customValidationMethod', 'body' => array( - 'notEmpty', + 'notBlank', '/^.{5,}$/s' => 'no matchy', '/^[0-9A-Za-z \\.]{1,}$/s' ) @@ -2394,7 +2394,7 @@ class Story extends CakeTestModel { * * @var array */ - public $validate = array('title' => 'notEmpty'); + public $validate = array('title' => 'notBlank'); } /** diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index bd0dbb2c875..10cbbcc5388 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -81,15 +81,15 @@ class Contact extends CakeTestModel { 'non_existing' => array(), 'idontexist' => array(), 'imrequired' => array('rule' => array('between', 5, 30), 'allowEmpty' => false), - 'imrequiredonupdate' => array('notEmpty' => array('rule' => 'alphaNumeric', 'on' => 'update')), + 'imrequiredonupdate' => array('notBlank' => array('rule' => 'alphaNumeric', 'on' => 'update')), 'imrequiredoncreate' => array('required' => array('rule' => 'alphaNumeric', 'on' => 'create')), 'imrequiredonboth' => array( 'required' => array('rule' => 'alphaNumeric'), ), - 'string_required' => 'notEmpty', + 'string_required' => 'notBlank', 'imalsorequired' => array('rule' => 'alphaNumeric', 'allowEmpty' => false), - 'imrequiredtoo' => array('rule' => 'notEmpty'), - 'required_one' => array('required' => array('rule' => array('notEmpty'))), + 'imrequiredtoo' => array('rule' => 'notBlank'), + 'required_one' => array('required' => array('rule' => array('notBlank'))), 'imnotrequired' => array('required' => false, 'rule' => 'alphaNumeric', 'allowEmpty' => true), 'imalsonotrequired' => array( 'alpha' => array('rule' => 'alphaNumeric', 'allowEmpty' => true), @@ -3623,9 +3623,9 @@ public function testError() { ); $this->assertTags($result, $expected); - $Contact->validationErrors['field'] = array('notEmpty', 'email', 'Something else'); + $Contact->validationErrors['field'] = array('notBlank', 'email', 'Something else'); $result = $this->Form->error('Contact.field', array( - 'notEmpty' => 'Cannot be empty', + 'notBlank' => 'Cannot be empty', 'email' => 'No good!' )); $expected = array( @@ -3640,13 +3640,13 @@ public function testError() { $this->assertTags($result, $expected); // Testing error messages list options - $Contact->validationErrors['field'] = array('notEmpty', 'email'); + $Contact->validationErrors['field'] = array('notBlank', 'email'); $result = $this->Form->error('Contact.field', null, array('listOptions' => 'ol')); $expected = array( 'div' => array('class' => 'error-message'), 'ol' => array(), - ' array('class' => 'error-message'), 'ol' => array(), - ' array('class' => 'error-message'), 'ul' => array('class' => 'ul-class'), - array('li' => array('class' => 'li-class')), 'notEmpty', '/li', + array('li' => array('class' => 'li-class')), 'notBlank', '/li', array('li' => array('class' => 'li-class')), 'email', '/li', '/ul', '/div' @@ -9070,7 +9070,7 @@ public function testFormInputRequiredDetection() { * @return void */ public function testFormInputRequiredDetectionModelValidator() { - ClassRegistry::getObject('ContactTag')->validator()->add('iwillberequired', 'required', array('rule' => 'notEmpty')); + ClassRegistry::getObject('ContactTag')->validator()->add('iwillberequired', 'required', array('rule' => 'notBlank')); $this->Form->create('ContactTag'); $result = $this->Form->input('ContactTag.iwillberequired'); diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php index d1c32b8d65d..a52c21e75a3 100644 --- a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php @@ -29,8 +29,8 @@ class TestPluginAuthors extends TestPluginAppModel { public $validate = array( 'field' => array( - 'notEmpty' => array( - 'rule' => 'notEmpty', + 'notBlank' => array( + 'rule' => 'notBlank', 'message' => 'I can haz plugin model validation message', ), ), From f742fa51fea2cdfa13d6548ecebf0d02fe746261 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Sun, 17 May 2015 23:24:23 +0200 Subject: [PATCH 187/336] Dont include deprecated options for bake --- lib/Cake/Console/Command/Task/ModelTask.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index 15563dd3f8a..dc7fe33cc4a 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -383,6 +383,8 @@ public function initValidations() { if (class_exists('Validation')) { $options = get_class_methods('Validation'); } + $deprecatedOptions = array('notEmpty'); + $options = array_diff($options, $deprecatedOptions); sort($options); $default = 1; foreach ($options as $option) { From 29747995dc6f2fdb2b82767eb3c68cba4fd0048d Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Mon, 18 May 2015 18:10:02 +0200 Subject: [PATCH 188/336] Add missing minimizable HTML attributes --- lib/Cake/View/Helper.php | 45 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/lib/Cake/View/Helper.php b/lib/Cake/View/Helper.php index e91299e7390..35aefff4445 100644 --- a/lib/Cake/View/Helper.php +++ b/lib/Cake/View/Helper.php @@ -145,9 +145,48 @@ class Helper extends Object { * @var array */ protected $_minimizedAttributes = array( - 'compact', 'checked', 'declare', 'readonly', 'disabled', 'selected', - 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize', - 'autoplay', 'controls', 'loop', 'muted', 'required', 'novalidate', 'formnovalidate' + 'allowfullscreen', + 'async', + 'autofocus', + 'autoplay', + 'checked', + 'compact', + 'controls', + 'declare', + 'default', + 'defaultchecked', + 'defaultmuted', + 'defaultselected', + 'defer', + 'disabled', + 'enabled', + 'formnovalidate', + 'hidden', + 'indeterminate', + 'inert', + 'ismap', + 'itemscope', + 'loop', + 'multiple', + 'muted', + 'nohref', + 'noresize', + 'noshade', + 'novalidate', + 'nowrap', + 'open', + 'pauseonexit', + 'readonly', + 'required', + 'reversed', + 'scoped', + 'seamless', + 'selected', + 'sortable', + 'spellcheck', + 'truespeed', + 'typemustmatch', + 'visible' ); /** From 508b9d14437eff70ead94760ff745474334c7f3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Tue, 19 May 2015 15:06:12 +0200 Subject: [PATCH 189/336] Rename test methods after notBlank change Was a left-over from #6579 --- lib/Cake/Test/Case/Utility/ValidationTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index 332b1b10b93..118f6318301 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -124,11 +124,11 @@ public function tearDown() { } /** - * testNotEmpty method + * Test notBlank method * * @return void */ - public function testNotEmpty() { + public function testNotBlank() { $this->assertTrue(Validation::notBlank('abcdefg')); $this->assertTrue(Validation::notBlank('fasdf ')); $this->assertTrue(Validation::notBlank('fooo' . chr(243) . 'blabla')); @@ -141,11 +141,11 @@ public function testNotEmpty() { } /** - * testNotEmptyISO88591Encoding method + * Test notBlank method with ISO88591 encoding * * @return void */ - public function testNotEmptyISO88591AppEncoding() { + public function testNotBlankISO88591AppEncoding() { Configure::write('App.encoding', 'ISO-8859-1'); $this->assertTrue(Validation::notBlank('abcdefg')); $this->assertTrue(Validation::notBlank('fasdf ')); From 52a0d642ec36a9a3f50bfc5339aa73b3eecfbe8d Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 20 May 2015 22:22:38 -0400 Subject: [PATCH 190/336] Fix incorrectly quoted table aliases in virtual fields. DboSource::_quoteFields() is already a bit of a mess, and while I'm not happy about having to add more regex replacement, it seems to be the only reasonable solution given that the code is already 'parsing' SQL to apply identifier quoting. Fixes #6602 --- lib/Cake/Model/Datasource/DboSource.php | 7 +++++ lib/Cake/Test/Case/Model/ModelReadTest.php | 32 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 80c35120246..2e8e6574c74 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -2869,12 +2869,19 @@ protected function _quoteFields($conditions) { if (!empty($this->endQuote)) { $end = preg_quote($this->endQuote); } + // Remove quotes and requote all the Model.field names. $conditions = str_replace(array($start, $end), '', $conditions); $conditions = preg_replace_callback( '/(?:[\'\"][^\'\"\\\]*(?:\\\.[^\'\"\\\]*)*[\'\"])|([a-z0-9_][a-z0-9\\-_]*\\.[a-z0-9_][a-z0-9_\\-]*)/i', array(&$this, '_quoteMatchedField'), $conditions ); + // Quote `table_name AS Alias` + $conditions = preg_replace( + '/(\s[a-z0-9\\-_.' . $start . $end . ']*' . $end . ')\s+AS\s+([a-z0-9\\-_]+)/i', + '\1 AS ' . $this->startQuote . '\2' . $this->endQuote, + $conditions + ); if ($conditions !== null) { return $conditions; } diff --git a/lib/Cake/Test/Case/Model/ModelReadTest.php b/lib/Cake/Test/Case/Model/ModelReadTest.php index b684f06d07e..7a29cbc3716 100644 --- a/lib/Cake/Test/Case/Model/ModelReadTest.php +++ b/lib/Cake/Test/Case/Model/ModelReadTest.php @@ -7836,6 +7836,38 @@ public function testVirtualFields() { $this->assertEquals(4, $result); } +/** + * Test virtualfields that contain subqueries get correctly + * quoted allowing reserved words to be used. + * + * @return void + */ + public function testVirtualFieldSubqueryReservedWords() { + $this->loadFixtures('User'); + $user = ClassRegistry::init('User'); + $user->cacheMethods = false; + $ds = $user->getDataSource(); + + $sub = $ds->buildStatement( + array( + 'fields' => array('Table.user'), + 'table' => $ds->fullTableName($user), + 'alias' => 'Table', + 'limit' => 1, + 'conditions' => array( + "Table.id > 1" + ) + ), + $user + ); + $user->virtualFields = array( + 'sub_test' => $sub + ); + + $result = $user->field('sub_test', array('id' => 1)); + $this->assertNotEmpty($result); + } + /** * testVirtualFieldsOrder() * From 4a3b2e2a031b037c1b3f2e91df76e210aaaadddd Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 21 May 2015 21:58:12 -0400 Subject: [PATCH 191/336] Fix failing test in SQLite. SQLite does not handle subqueries in virtual fields well. However, the original issue was that the generated query was invalid which find(first) will still catch. --- lib/Cake/Test/Case/Model/ModelReadTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Model/ModelReadTest.php b/lib/Cake/Test/Case/Model/ModelReadTest.php index 7a29cbc3716..255371253ee 100644 --- a/lib/Cake/Test/Case/Model/ModelReadTest.php +++ b/lib/Cake/Test/Case/Model/ModelReadTest.php @@ -7864,7 +7864,7 @@ public function testVirtualFieldSubqueryReservedWords() { 'sub_test' => $sub ); - $result = $user->field('sub_test', array('id' => 1)); + $result = $user->find('first'); $this->assertNotEmpty($result); } From 9626f0e726e0e1d649ff791c08bd69c4f3f7e8e7 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 22 May 2015 22:03:32 -0400 Subject: [PATCH 192/336] Exclude deprecated validators from bake. Don't include deprecated validators in bake. Refs #6581 --- lib/Cake/Console/Command/Task/ModelTask.php | 2 +- .../Test/Case/Console/Command/Task/ModelTaskTest.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index dc7fe33cc4a..2dc03a5c384 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -383,7 +383,7 @@ public function initValidations() { if (class_exists('Validation')) { $options = get_class_methods('Validation'); } - $deprecatedOptions = array('notEmpty'); + $deprecatedOptions = array('notEmpty', 'between', 'ssn'); $options = array_diff($options, $deprecatedOptions); sort($options); $default = 1; diff --git a/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php index 22d6f8e5236..e1b3625a0ab 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php @@ -315,7 +315,7 @@ public function testInteractiveFieldValidation() { $this->Task->initValidations(); $this->Task->interactive = true; $this->Task->expects($this->any())->method('in') - ->will($this->onConsecutiveCalls('25', 'y', '19', 'n')); + ->will($this->onConsecutiveCalls('24', 'y', '18', 'n')); $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); $expected = array('notBlank' => 'notBlank', 'maxLength' => 'maxLength'); @@ -333,7 +333,7 @@ public function testInteractiveFieldValidationWithBogusResponse() { $this->Task->interactive = true; $this->Task->expects($this->any())->method('in') - ->will($this->onConsecutiveCalls('999999', '25', 'n')); + ->will($this->onConsecutiveCalls('999999', '24', 'n')); $this->Task->expects($this->at(10))->method('out') ->with($this->stringContains('make a valid')); @@ -368,7 +368,7 @@ public function testSkippingChoiceInteractiveFieldValidation() { $this->Task->initValidations(); $this->Task->interactive = true; $this->Task->expects($this->any())->method('in') - ->will($this->onConsecutiveCalls('25', 'y', 's')); + ->will($this->onConsecutiveCalls('24', 'y', 's')); $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); $expected = array('notBlank' => 'notBlank', '_skipFields' => true); @@ -384,7 +384,7 @@ public function testSkippingAnotherInteractiveFieldValidation() { $this->Task->initValidations(); $this->Task->interactive = true; $this->Task->expects($this->any())->method('in') - ->will($this->onConsecutiveCalls('25', 's')); + ->will($this->onConsecutiveCalls('24', 's')); $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); $expected = array('notBlank' => 'notBlank', '_skipFields' => true); @@ -400,7 +400,7 @@ public function testSkippingAnotherInteractiveFieldValidation() { public function testInteractiveDoValidationWithSkipping() { $this->Task->expects($this->any()) ->method('in') - ->will($this->onConsecutiveCalls('36', '25', 'n', '11', 's')); + ->will($this->onConsecutiveCalls('34', '24', 'n', '10', 's')); $this->Task->interactive = true; $Model = $this->getMock('Model'); $Model->primaryKey = 'id'; From 15f88533e894708b5adf7c2cd9e396b9da9a75c3 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 24 May 2015 21:01:09 -0400 Subject: [PATCH 193/336] Update version number to 2.6.5 --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index 0a2a95a2b92..96fbfb43550 100644 --- a/lib/Cake/VERSION.txt +++ b/lib/Cake/VERSION.txt @@ -17,4 +17,4 @@ // @license http://www.opensource.org/licenses/mit-license.php MIT License // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -2.6.4 +2.6.5 From 8ebc9cdd875f144a734d43978d618400962c5e58 Mon Sep 17 00:00:00 2001 From: nojimage Date: Mon, 25 May 2015 22:10:50 +0900 Subject: [PATCH 194/336] refs #6635 FormHelper::radio() return collect id attributes with multibyte --- .../Test/Case/View/Helper/FormHelperTest.php | 19 +++++++++++++++++++ lib/Cake/Utility/Inflector.php | 7 ++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index bd0dbb2c875..a1ef2cd9edf 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -3902,6 +3902,25 @@ public function testRadio() { '/fieldset' ); $this->assertTags($result, $expected); + + $result = $this->Form->radio( + 'Model.multibyte', + array('男性' => '男性') + ); + $expected = array( + 'input' => array( + 'type' => 'hidden', 'name' => 'data[Model][multibyte]', + 'id' => 'ModelMultibyte_', 'value' => '', + ), + array('input' => array( + 'type' => 'radio', 'name' => 'data[Model][multibyte]', + 'id' => 'ModelMultibyte男性', 'value' => '男性') + ), + array('label' => array('for' => 'ModelMultibyte男性')), + '男性', + '/label', + ); + $this->assertTags($result, $expected); } /** diff --git a/lib/Cake/Utility/Inflector.php b/lib/Cake/Utility/Inflector.php index 594556b60d0..426334fa500 100644 --- a/lib/Cake/Utility/Inflector.php +++ b/lib/Cake/Utility/Inflector.php @@ -495,7 +495,12 @@ public static function underscore($camelCasedWord) { */ public static function humanize($lowerCaseAndUnderscoredWord) { if (!($result = self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) { - $result = ucwords(str_replace('_', ' ', $lowerCaseAndUnderscoredWord)); + $result = str_replace('_', ' ', $lowerCaseAndUnderscoredWord); + if (function_exists('mb_convert_case') && Multibyte::checkMultibyte($result)) { + $result = mb_convert_case($result, MB_CASE_TITLE, Configure::read('App.encoding')); + } else { + $result = ucwords($result); + } self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord, $result); } return $result; From c6e4208bda27115d03148d4191c0d96baff8e61c Mon Sep 17 00:00:00 2001 From: nojimage Date: Tue, 26 May 2015 13:29:05 +0900 Subject: [PATCH 195/336] refs #6635 Inflector::underscore, humanize support multibyte string inputs --- lib/Cake/Test/Case/Utility/InflectorTest.php | 4 ++++ lib/Cake/Utility/Inflector.php | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/InflectorTest.php b/lib/Cake/Test/Case/Utility/InflectorTest.php index b621a1920a1..c1abaf15a30 100644 --- a/lib/Cake/Test/Case/Utility/InflectorTest.php +++ b/lib/Cake/Test/Case/Utility/InflectorTest.php @@ -399,12 +399,14 @@ public function testInflectorUnderscore() { $this->assertSame(Inflector::underscore('testThing'), 'test_thing'); $this->assertSame(Inflector::underscore('TestThingExtra'), 'test_thing_extra'); $this->assertSame(Inflector::underscore('testThingExtra'), 'test_thing_extra'); + $this->assertSame(Inflector::underscore('testThingExtrå'), 'test_thing_extrå'); // Identical checks test the cache code path. $this->assertSame(Inflector::underscore('TestThing'), 'test_thing'); $this->assertSame(Inflector::underscore('testThing'), 'test_thing'); $this->assertSame(Inflector::underscore('TestThingExtra'), 'test_thing_extra'); $this->assertSame(Inflector::underscore('testThingExtra'), 'test_thing_extra'); + $this->assertSame(Inflector::underscore('testThingExtrå'), 'test_thing_extrå'); // Test stupid values $this->assertSame(Inflector::underscore(''), ''); @@ -457,6 +459,8 @@ public function testHumanization() { $this->assertEquals(Inflector::humanize('posts'), 'Posts'); $this->assertEquals(Inflector::humanize('posts_tags'), 'Posts Tags'); $this->assertEquals(Inflector::humanize('file_systems'), 'File Systems'); + $this->assertEquals(Inflector::humanize('hello_wörld'), 'Hello Wörld'); + $this->assertEquals(Inflector::humanize('福岡_city'), '福岡 City'); } /** diff --git a/lib/Cake/Utility/Inflector.php b/lib/Cake/Utility/Inflector.php index 426334fa500..79eb448f3a1 100644 --- a/lib/Cake/Utility/Inflector.php +++ b/lib/Cake/Utility/Inflector.php @@ -479,7 +479,12 @@ public static function camelize($lowerCaseAndUnderscoredWord) { */ public static function underscore($camelCasedWord) { if (!($result = self::_cache(__FUNCTION__, $camelCasedWord))) { - $result = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $camelCasedWord)); + $underscoredWord = preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $camelCasedWord); + if (function_exists('mb_convert_case')) { + $result = mb_convert_case($underscoredWord, MB_CASE_LOWER, Configure::read('App.encoding')); + } else { + $result = strtolower($underscoredWord); + } self::_cache(__FUNCTION__, $camelCasedWord, $result); } return $result; @@ -495,8 +500,9 @@ public static function underscore($camelCasedWord) { */ public static function humanize($lowerCaseAndUnderscoredWord) { if (!($result = self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) { + $lowerCaseAndUnderscoredWord = self::underscore($lowerCaseAndUnderscoredWord); $result = str_replace('_', ' ', $lowerCaseAndUnderscoredWord); - if (function_exists('mb_convert_case') && Multibyte::checkMultibyte($result)) { + if (function_exists('mb_convert_case')) { $result = mb_convert_case($result, MB_CASE_TITLE, Configure::read('App.encoding')); } else { $result = ucwords($result); From bf550d13ceb785feb745dd143544d1c2e53521ea Mon Sep 17 00:00:00 2001 From: Igor Padovan da Silva Date: Tue, 26 May 2015 17:46:08 -0400 Subject: [PATCH 196/336] preventing error on trying to delete unexiting buffer --- lib/Cake/Network/CakeResponse.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index e6d0bf2b3f9..d1081400367 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -1496,9 +1496,10 @@ protected function _isActive() { * @return bool */ protected function _clearBuffer() { - //@codingStandardsIgnoreStart - return @ob_end_clean(); - //@codingStandardsIgnoreEnd + if (ob_get_length()) { + return ob_end_clean(); + } + return true; } /** From 733ddc7ff447bbb6ed036363b951768ca402fccb Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 26 May 2015 22:51:00 -0400 Subject: [PATCH 197/336] Use mb* functions in Inflector humanize/underscore. Use the mbstring shims we already provide to make Inflector more robust than it currently is. This solves the invalid ID attribute generation in a way that never varies between environments. Refs #6635 --- lib/Cake/Utility/Inflector.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/Cake/Utility/Inflector.php b/lib/Cake/Utility/Inflector.php index 79eb448f3a1..61a63c2a18b 100644 --- a/lib/Cake/Utility/Inflector.php +++ b/lib/Cake/Utility/Inflector.php @@ -480,11 +480,7 @@ public static function camelize($lowerCaseAndUnderscoredWord) { public static function underscore($camelCasedWord) { if (!($result = self::_cache(__FUNCTION__, $camelCasedWord))) { $underscoredWord = preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $camelCasedWord); - if (function_exists('mb_convert_case')) { - $result = mb_convert_case($underscoredWord, MB_CASE_LOWER, Configure::read('App.encoding')); - } else { - $result = strtolower($underscoredWord); - } + $result = mb_strtolower($underscoredWord); self::_cache(__FUNCTION__, $camelCasedWord, $result); } return $result; @@ -501,12 +497,11 @@ public static function underscore($camelCasedWord) { public static function humanize($lowerCaseAndUnderscoredWord) { if (!($result = self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) { $lowerCaseAndUnderscoredWord = self::underscore($lowerCaseAndUnderscoredWord); - $result = str_replace('_', ' ', $lowerCaseAndUnderscoredWord); - if (function_exists('mb_convert_case')) { - $result = mb_convert_case($result, MB_CASE_TITLE, Configure::read('App.encoding')); - } else { - $result = ucwords($result); + $result = explode(' ', str_replace('_', ' ', $lowerCaseAndUnderscoredWord)); + foreach ($result as &$word) { + $word = mb_strtoupper(mb_substr($word, 0, 1)) . mb_substr($word, 1); } + $result = implode(' ', $result); self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord, $result); } return $result; From 995d8d22c696eba27e8d1542ea4070a85afef1ea Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 27 May 2015 09:45:53 -0400 Subject: [PATCH 198/336] Disable reading XML files and URLs when handling user data. Allowing users to load arbitrary files/URLs with Xml is not desirable when handing user input. --- .../Component/RequestHandlerComponent.php | 2 +- lib/Cake/Test/Case/Utility/XmlTest.php | 22 +++++++++++++++++++ lib/Cake/Utility/Xml.php | 8 +++++-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Controller/Component/RequestHandlerComponent.php b/lib/Cake/Controller/Component/RequestHandlerComponent.php index 9d55814873c..75bf2648639 100644 --- a/lib/Cake/Controller/Component/RequestHandlerComponent.php +++ b/lib/Cake/Controller/Component/RequestHandlerComponent.php @@ -229,7 +229,7 @@ public function startup(Controller $controller) { */ public function convertXml($xml) { try { - $xml = Xml::build($xml); + $xml = Xml::build($xml, ['readFile' => false]); if (isset($xml->data)) { return Xml::toArray($xml->data); } diff --git a/lib/Cake/Test/Case/Utility/XmlTest.php b/lib/Cake/Test/Case/Utility/XmlTest.php index 273801892a0..d9701444569 100644 --- a/lib/Cake/Test/Case/Utility/XmlTest.php +++ b/lib/Cake/Test/Case/Utility/XmlTest.php @@ -167,6 +167,28 @@ public function testBuild() { $this->assertNotRegExp('/encoding/', $obj->saveXML()); } +/** + * Test that the readFile option disables local file parsing. + * + * @expectedException XmlException + * @return void + */ + public function testBuildFromFileWhenDisabled() { + $xml = CAKE . 'Test' . DS . 'Fixture' . DS . 'sample.xml'; + $obj = Xml::build($xml, ['readFile' => false]); + } + +/** + * Test that the readFile option disables local file parsing. + * + * @expectedException XmlException + * @return void + */ + public function testBuildFromUrlWhenDisabled() { + $xml = 'http://www.google.com'; + $obj = Xml::build($xml, ['readFile' => false]); + } + /** * data provider function for testBuildInvalidData * diff --git a/lib/Cake/Utility/Xml.php b/lib/Cake/Utility/Xml.php index 0cd5e891b5c..74d88494d41 100644 --- a/lib/Cake/Utility/Xml.php +++ b/lib/Cake/Utility/Xml.php @@ -77,6 +77,9 @@ class Xml { * - `return` Can be 'simplexml' to return object of SimpleXMLElement or 'domdocument' to return DOMDocument. * - `loadEntities` Defaults to false. Set to true to enable loading of ` 'simplexml', 'loadEntities' => false, + 'readFile' => true ); $options += $defaults; @@ -98,9 +102,9 @@ public static function build($input, $options = array()) { return self::fromArray((array)$input, $options); } elseif (strpos($input, '<') !== false) { return self::_loadXml($input, $options); - } elseif (file_exists($input)) { + } elseif ($options['readFile'] && file_exists($input)) { return self::_loadXml(file_get_contents($input), $options); - } elseif (strpos($input, 'http://') === 0 || strpos($input, 'https://') === 0) { + } elseif ($options['readFile'] && strpos($input, 'http://') === 0 || strpos($input, 'https://') === 0) { try { $socket = new HttpSocket(array('request' => array('redirect' => 10))); $response = $socket->get($input); From b66c1ce53c6393258d4f4ec59366e3600689d42b Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 28 May 2015 09:50:27 -0400 Subject: [PATCH 199/336] Update version number to 2.6.6 --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index 96fbfb43550..52d4c9832af 100644 --- a/lib/Cake/VERSION.txt +++ b/lib/Cake/VERSION.txt @@ -17,4 +17,4 @@ // @license http://www.opensource.org/licenses/mit-license.php MIT License // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -2.6.5 +2.6.6 From 65691836befd5f7abfcb2846a06bf532d543eb3c Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 28 May 2015 17:39:52 -0400 Subject: [PATCH 200/336] Fix syntax errors in PHP <5.4 --- lib/Cake/Controller/Component/RequestHandlerComponent.php | 2 +- lib/Cake/Test/Case/Utility/XmlTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Controller/Component/RequestHandlerComponent.php b/lib/Cake/Controller/Component/RequestHandlerComponent.php index 75bf2648639..271b5677393 100644 --- a/lib/Cake/Controller/Component/RequestHandlerComponent.php +++ b/lib/Cake/Controller/Component/RequestHandlerComponent.php @@ -229,7 +229,7 @@ public function startup(Controller $controller) { */ public function convertXml($xml) { try { - $xml = Xml::build($xml, ['readFile' => false]); + $xml = Xml::build($xml, array('readFile' => false)); if (isset($xml->data)) { return Xml::toArray($xml->data); } diff --git a/lib/Cake/Test/Case/Utility/XmlTest.php b/lib/Cake/Test/Case/Utility/XmlTest.php index d9701444569..614a22a0544 100644 --- a/lib/Cake/Test/Case/Utility/XmlTest.php +++ b/lib/Cake/Test/Case/Utility/XmlTest.php @@ -175,7 +175,7 @@ public function testBuild() { */ public function testBuildFromFileWhenDisabled() { $xml = CAKE . 'Test' . DS . 'Fixture' . DS . 'sample.xml'; - $obj = Xml::build($xml, ['readFile' => false]); + $obj = Xml::build($xml, array('readFile' => false)); } /** @@ -186,7 +186,7 @@ public function testBuildFromFileWhenDisabled() { */ public function testBuildFromUrlWhenDisabled() { $xml = 'http://www.google.com'; - $obj = Xml::build($xml, ['readFile' => false]); + $obj = Xml::build($xml, array('readFile' => false)); } /** From 523597df432e645b582f0b9c44e8a2464ea71048 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 28 May 2015 19:30:33 -0400 Subject: [PATCH 201/336] Update version number to 2.6.7 --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index 52d4c9832af..ed91c106a38 100644 --- a/lib/Cake/VERSION.txt +++ b/lib/Cake/VERSION.txt @@ -17,4 +17,4 @@ // @license http://www.opensource.org/licenses/mit-license.php MIT License // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -2.6.6 +2.6.7 From 2a5cbb8037f891a267324f6ec4dfa61db4ab52b2 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Sun, 31 May 2015 13:40:22 +0200 Subject: [PATCH 202/336] Add missing static keyword. --- lib/Cake/Utility/Validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index 640f8b1ac54..80037c203f7 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -56,7 +56,7 @@ class Validation { * @deprecated 2.7.0 Use Validation::notBlank() instead. * @see Validation::notBlank() */ - public function notEmpty($check) { + public static function notEmpty($check) { trigger_error('Validation::notEmpty() is deprecated. Use Validation::notBlank() instead.', E_USER_DEPRECATED); return self::notBlank($check); } From 670d93b6f63589c7988ff0861c2c169af7398824 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Mon, 1 Jun 2015 12:36:20 +0200 Subject: [PATCH 203/336] Extract formatTreeList() from generateTreeList(). --- lib/Cake/Model/Behavior/TreeBehavior.php | 42 ++++++++++++++----- .../Model/Behavior/TreeBehaviorNumberTest.php | 23 ++++++++++ 2 files changed, 55 insertions(+), 10 deletions(-) diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index e982c9796b1..7fd95cd29d7 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -442,6 +442,37 @@ public function generateTreeList(Model $Model, $conditions = null, $keyPath = nu $fields = array($Model->primaryKey, $Model->displayField, $left, $right); } + $conditions = (array)$conditions; + if ($scope) { + $conditions[] = $scope; + } + + $order = $Model->escapeField($left) . ' asc'; + $results = $Model->find('all', compact('conditions', 'fields', 'order', 'recursive')); + + return $this->formatTreeList($Model, $results, $keyPath, $valuePath); + } + +/** + * Formats result of a find() call to a hierarchical array used for HTML select boxes. + * + * Note that when using your own find() call this expects the order to be "left" field asc in order + * to generate the same result as using generateTreeList() directly. + * + * @param Model $Model Model using this behavior + * @param array $results Result array of a find() call + * @param null $keyPath A string path to the key, i.e. "{n}.Post.id" + * @param null $valuePath A string path to the value, i.e. "{n}.Post.title" + * @param string $spacer The character or characters which will be repeated + * @return array An associative array of records, where the id is the key, and the display field is the value + */ + public function formatTreeList(Model $Model, array $results, $keyPath = null, $valuePath = null, $spacer = '_') { + if (empty($results)) { + return array(); + } + + extract($this->settings[$Model->alias]); + if (!$keyPath) { $keyPath = '{n}.' . $Model->alias . '.' . $Model->primaryKey; } @@ -456,13 +487,6 @@ public function generateTreeList(Model $Model, $conditions = null, $keyPath = nu array_unshift($valuePath, '%s' . $valuePath[0], '{n}.tree_prefix'); } - $conditions = (array)$conditions; - if ($scope) { - $conditions[] = $scope; - } - - $order = $Model->escapeField($left) . " asc"; - $results = $Model->find('all', compact('conditions', 'fields', 'order', 'recursive')); $stack = array(); foreach ($results as $i => $result) { @@ -474,9 +498,7 @@ public function generateTreeList(Model $Model, $conditions = null, $keyPath = nu $results[$i]['tree_prefix'] = str_repeat($spacer, $count); $stack[] = $result[$Model->alias][$right]; } - if (empty($results)) { - return array(); - } + return Hash::combine($results, $keyPath, $valuePath); } diff --git a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php index da7da8196c0..62de4bb6d42 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php @@ -1433,6 +1433,29 @@ public function testGenerateTreeListFormatting() { $this->assertEquals('__3 - 1.1.1', $result[3]); } +/** + * Test the formatting options of formatTreeList() + * + * @return void + */ + public function testFormatTreeList() { + extract($this->settings); + $this->Tree = new $modelClass(); + $this->Tree->initialize(2, 2); + + $options = array('order' => array('lft' => 'asc')); + $records = $this->Tree->find('all', $options); + + $result = $this->Tree->formatTreeList( + $records, + "{n}.$modelClass.id", + array('%s - %s', "{n}.$modelClass.id", "{n}.$modelClass.name") + ); + $this->assertEquals('1 - 1. Root', $result[1]); + $this->assertEquals('_2 - 1.1', $result[2]); + $this->assertEquals('__3 - 1.1.1', $result[3]); + } + /** * testArraySyntax method * From 4ad001b9ca7021b951ceefec89fc28f0b1bdba0f Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Mon, 1 Jun 2015 16:12:45 +0200 Subject: [PATCH 204/336] Use options array. --- lib/Cake/Model/Behavior/TreeBehavior.php | 29 ++++++++++++------- .../Model/Behavior/TreeBehaviorNumberTest.php | 14 ++++----- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index 7fd95cd29d7..c4aa95a8ef1 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -450,7 +450,7 @@ public function generateTreeList(Model $Model, $conditions = null, $keyPath = nu $order = $Model->escapeField($left) . ' asc'; $results = $Model->find('all', compact('conditions', 'fields', 'order', 'recursive')); - return $this->formatTreeList($Model, $results, $keyPath, $valuePath); + return $this->formatTreeList($Model, $results, compact('keyPath', 'valuePath', 'spacer')); } /** @@ -461,30 +461,37 @@ public function generateTreeList(Model $Model, $conditions = null, $keyPath = nu * * @param Model $Model Model using this behavior * @param array $results Result array of a find() call + * @param array $options Options * @param null $keyPath A string path to the key, i.e. "{n}.Post.id" * @param null $valuePath A string path to the value, i.e. "{n}.Post.title" * @param string $spacer The character or characters which will be repeated * @return array An associative array of records, where the id is the key, and the display field is the value */ - public function formatTreeList(Model $Model, array $results, $keyPath = null, $valuePath = null, $spacer = '_') { + public function formatTreeList(Model $Model, array $results, array $options = array()) { if (empty($results)) { return array(); } + $defaults = array( + 'keyPath' => null, + 'valuePath' => null, + 'spacer' => '_' + ); + $options += $defaults; extract($this->settings[$Model->alias]); - if (!$keyPath) { - $keyPath = '{n}.' . $Model->alias . '.' . $Model->primaryKey; + if (!$options['keyPath']) { + $options['keyPath'] = '{n}.' . $Model->alias . '.' . $Model->primaryKey; } - if (!$valuePath) { - $valuePath = array('%s%s', '{n}.tree_prefix', '{n}.' . $Model->alias . '.' . $Model->displayField); + if (!$options['valuePath']) { + $options['valuePath'] = array('%s%s', '{n}.tree_prefix', '{n}.' . $Model->alias . '.' . $Model->displayField); - } elseif (is_string($valuePath)) { - $valuePath = array('%s%s', '{n}.tree_prefix', $valuePath); + } elseif (is_string($options['valuePath'])) { + $options['valuePath'] = array('%s%s', '{n}.tree_prefix', $options['valuePath']); } else { - array_unshift($valuePath, '%s' . $valuePath[0], '{n}.tree_prefix'); + array_unshift($options['valuePath'], '%s' . $options['valuePath'][0], '{n}.tree_prefix'); } $stack = array(); @@ -495,11 +502,11 @@ public function formatTreeList(Model $Model, array $results, $keyPath = null, $v array_pop($stack); $count--; } - $results[$i]['tree_prefix'] = str_repeat($spacer, $count); + $results[$i]['tree_prefix'] = str_repeat($options['spacer'], $count); $stack[] = $result[$Model->alias][$right]; } - return Hash::combine($results, $keyPath, $valuePath); + return Hash::combine($results, $options['keyPath'], $options['valuePath']); } /** diff --git a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php index 62de4bb6d42..b9eb1ed2528 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php @@ -1446,14 +1446,14 @@ public function testFormatTreeList() { $options = array('order' => array('lft' => 'asc')); $records = $this->Tree->find('all', $options); - $result = $this->Tree->formatTreeList( - $records, - "{n}.$modelClass.id", - array('%s - %s', "{n}.$modelClass.id", "{n}.$modelClass.name") - ); + $options = array( + 'keyPath' => "{n}.$modelClass.id", + 'valuePath' => array('%s - %s', "{n}.$modelClass.id", "{n}.$modelClass.name"), + 'spacer' => '--'); + $result = $this->Tree->formatTreeList($records, $options); $this->assertEquals('1 - 1. Root', $result[1]); - $this->assertEquals('_2 - 1.1', $result[2]); - $this->assertEquals('__3 - 1.1.1', $result[3]); + $this->assertEquals('--2 - 1.1', $result[2]); + $this->assertEquals('----3 - 1.1.1', $result[3]); } /** From 0524eb95aeedbe0fa8e35b4b5fec0f71f8cb786a Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Mon, 1 Jun 2015 16:14:15 +0200 Subject: [PATCH 205/336] Documentation update --- lib/Cake/Model/Behavior/TreeBehavior.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index c4aa95a8ef1..a19d4a8fe6f 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -459,12 +459,15 @@ public function generateTreeList(Model $Model, $conditions = null, $keyPath = nu * Note that when using your own find() call this expects the order to be "left" field asc in order * to generate the same result as using generateTreeList() directly. * + * Options: + * + * - 'keyPath': A string path to the key, i.e. "{n}.Post.id" + * - 'valuePath': A string path to the value, i.e. "{n}.Post.title" + * - 'spacer': The character or characters which will be repeated + * * @param Model $Model Model using this behavior * @param array $results Result array of a find() call * @param array $options Options - * @param null $keyPath A string path to the key, i.e. "{n}.Post.id" - * @param null $valuePath A string path to the value, i.e. "{n}.Post.title" - * @param string $spacer The character or characters which will be repeated * @return array An associative array of records, where the id is the key, and the display field is the value */ public function formatTreeList(Model $Model, array $results, array $options = array()) { From df0f2295c3d9fabba6c5bcbdf46e93be6e398def Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 2 Jun 2015 23:06:06 -0400 Subject: [PATCH 206/336] Fix issue with overlapping irregular inflections. When irregular inflections overlap we should choose the longest match, not the shortest. Refs #6659 --- lib/Cake/Test/Case/Utility/InflectorTest.php | 46 ++++++++++++++++++++ lib/Cake/Utility/Inflector.php | 12 +++-- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/InflectorTest.php b/lib/Cake/Test/Case/Utility/InflectorTest.php index c1abaf15a30..8635f39f4ec 100644 --- a/lib/Cake/Test/Case/Utility/InflectorTest.php +++ b/lib/Cake/Test/Case/Utility/InflectorTest.php @@ -183,6 +183,29 @@ public function testInflectingSingulars() { $this->assertEquals(Inflector::singularize(''), ''); } +/** + * Test that overlapping irregulars don't collide. + * + * @return void + */ + public function testSingularizeMultiWordIrregular() { + Inflector::rules('singular', array( + 'irregular' => array( + 'preguntas_frecuentes' => 'pregunta_frecuente', + 'categorias_preguntas_frecuentes' => 'categoria_pregunta_frecuente', + ) + )); + $this->assertEquals('pregunta_frecuente', Inflector::singularize('preguntas_frecuentes')); + $this->assertEquals( + 'categoria_pregunta_frecuente', + Inflector::singularize('categorias_preguntas_frecuentes') + ); + $this->assertEquals( + 'faq_categoria_pregunta_frecuente', + Inflector::singularize('faq_categorias_preguntas_frecuentes') + ); + } + /** * testInflectingPlurals method * @@ -256,6 +279,29 @@ public function testInflectingPlurals() { $this->assertEquals(Inflector::pluralize(''), ''); } +/** + * Test that overlapping irregulars don't collide. + * + * @return void + */ + public function testPluralizeMultiWordIrregular() { + Inflector::rules('plural', array( + 'irregular' => array( + 'pregunta_frecuente' => 'preguntas_frecuentes', + 'categoria_pregunta_frecuente' => 'categorias_preguntas_frecuentes', + ) + )); + $this->assertEquals('preguntas_frecuentes', Inflector::pluralize('pregunta_frecuente')); + $this->assertEquals( + 'categorias_preguntas_frecuentes', + Inflector::pluralize('categoria_pregunta_frecuente') + ); + $this->assertEquals( + 'faq_categorias_preguntas_frecuentes', + Inflector::pluralize('faq_categoria_pregunta_frecuente') + ); + } + /** * testInflectingMultiWordIrregulars * diff --git a/lib/Cake/Utility/Inflector.php b/lib/Cake/Utility/Inflector.php index 61a63c2a18b..d06d4baff83 100644 --- a/lib/Cake/Utility/Inflector.php +++ b/lib/Cake/Utility/Inflector.php @@ -386,8 +386,10 @@ public static function pluralize($word) { self::$_plural['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$_plural['merged']['irregular'])) . ')'; } - if (preg_match('/(.*(?:\\b|_))(' . self::$_plural['cacheIrregular'] . ')$/i', $word, $regs)) { - self::$_cache['pluralize'][$word] = $regs[1] . substr($regs[2], 0, 1) . substr(self::$_plural['merged']['irregular'][strtolower($regs[2])], 1); + if (preg_match('/(.*?(?:\\b|_))(' . self::$_plural['cacheIrregular'] . ')$/i', $word, $regs)) { + self::$_cache['pluralize'][$word] = $regs[1] . + substr($regs[2], 0, 1) . + substr(self::$_plural['merged']['irregular'][strtolower($regs[2])], 1); return self::$_cache['pluralize'][$word]; } @@ -435,8 +437,10 @@ public static function singularize($word) { self::$_singular['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$_singular['merged']['irregular'])) . ')'; } - if (preg_match('/(.*(?:\\b|_))(' . self::$_singular['cacheIrregular'] . ')$/i', $word, $regs)) { - self::$_cache['singularize'][$word] = $regs[1] . substr($regs[2], 0, 1) . substr(self::$_singular['merged']['irregular'][strtolower($regs[2])], 1); + if (preg_match('/(.*?(?:\\b|_))(' . self::$_singular['cacheIrregular'] . ')$/i', $word, $regs)) { + self::$_cache['singularize'][$word] = $regs[1] . + substr($regs[2], 0, 1) . + substr(self::$_singular['merged']['irregular'][strtolower($regs[2])], 1); return self::$_cache['singularize'][$word]; } From 239c83938f1c238900fef1ab0996a6cfd9975727 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 5 Jun 2015 10:20:51 -0400 Subject: [PATCH 207/336] Fix regression in camelize(). The input should not be lowercased before camelizing, as this can cause inputs that were previously camelized to create incorrect results. Refs #6735 --- lib/Cake/Test/Case/Utility/InflectorTest.php | 14 ++++++++++++++ lib/Cake/Utility/Inflector.php | 1 - 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Utility/InflectorTest.php b/lib/Cake/Test/Case/Utility/InflectorTest.php index 8635f39f4ec..9f54ee1fc8a 100644 --- a/lib/Cake/Test/Case/Utility/InflectorTest.php +++ b/lib/Cake/Test/Case/Utility/InflectorTest.php @@ -460,6 +460,20 @@ public function testInflectorUnderscore() { $this->assertSame(Inflector::underscore(false), ''); } + +/** + * Test camelize() + * + * @return void + */ + public function testCamelize() { + $this->assertSame('BlogArticles', Inflector::camelize('blog_articles')); + $this->assertSame('BlogArticles', Inflector::camelize('blog articles')); + $this->assertSame('MyPlugin.MyClass', Inflector::camelize('MyPlugin.MyClass')); + $this->assertSame('MyPlugin.MyClass', Inflector::camelize('my_plugin.MyClass')); + $this->assertSame('MyPlugin.myClass', Inflector::camelize('MyPlugin.my_class')); + } + /** * testVariableNaming method * diff --git a/lib/Cake/Utility/Inflector.php b/lib/Cake/Utility/Inflector.php index d06d4baff83..6863d95bb19 100644 --- a/lib/Cake/Utility/Inflector.php +++ b/lib/Cake/Utility/Inflector.php @@ -500,7 +500,6 @@ public static function underscore($camelCasedWord) { */ public static function humanize($lowerCaseAndUnderscoredWord) { if (!($result = self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) { - $lowerCaseAndUnderscoredWord = self::underscore($lowerCaseAndUnderscoredWord); $result = explode(' ', str_replace('_', ' ', $lowerCaseAndUnderscoredWord)); foreach ($result as &$word) { $word = mb_strtoupper(mb_substr($word, 0, 1)) . mb_substr($word, 1); From 0e6fcc02b809b5885009e458a04c67e3c9427b57 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 5 Jun 2015 10:31:29 -0400 Subject: [PATCH 208/336] Add/correct some tests for humanize. The arguments for assertEquals() were backwards. While there are many more flipped assertions I will change the others separately. --- lib/Cake/Test/Case/Utility/InflectorTest.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/InflectorTest.php b/lib/Cake/Test/Case/Utility/InflectorTest.php index 9f54ee1fc8a..e3fd21191fc 100644 --- a/lib/Cake/Test/Case/Utility/InflectorTest.php +++ b/lib/Cake/Test/Case/Utility/InflectorTest.php @@ -504,10 +504,10 @@ public function testClassNaming() { * @return void */ public function testTableNaming() { - $this->assertEquals(Inflector::tableize('ArtistsGenre'), 'artists_genres'); - $this->assertEquals(Inflector::tableize('FileSystem'), 'file_systems'); - $this->assertEquals(Inflector::tableize('News'), 'news'); - $this->assertEquals(Inflector::tableize('Bureau'), 'bureaus'); + $this->assertEquals('artists_genres', Inflector::tableize('ArtistsGenre')); + $this->assertEquals('file_systems', Inflector::tableize('FileSystem')); + $this->assertEquals('news', Inflector::tableize('News')); + $this->assertEquals('bureaus', Inflector::tableize('Bureau')); } /** @@ -516,11 +516,12 @@ public function testTableNaming() { * @return void */ public function testHumanization() { - $this->assertEquals(Inflector::humanize('posts'), 'Posts'); - $this->assertEquals(Inflector::humanize('posts_tags'), 'Posts Tags'); - $this->assertEquals(Inflector::humanize('file_systems'), 'File Systems'); - $this->assertEquals(Inflector::humanize('hello_wörld'), 'Hello Wörld'); - $this->assertEquals(Inflector::humanize('福岡_city'), '福岡 City'); + $this->assertEquals('Posts', Inflector::humanize('posts')); + $this->assertEquals('Posts Tags', Inflector::humanize('posts_tags')); + $this->assertEquals('File Systems', Inflector::humanize('file_systems')); + $this->assertEquals('FiLe SysTems', Inflector::humanize('FiLe_SysTems')); + $this->assertEquals('Hello Wörld', Inflector::humanize('hello_wörld')); + $this->assertEquals('福岡 City', Inflector::humanize('福岡_city')); } /** From 6d60e6a4db395d7698cd748b3255fb525627ae30 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 7 Jun 2015 15:45:16 -0400 Subject: [PATCH 209/336] Backport 7eec48268ebb6a17656df4a059f9e7b43991472f to 2.x Backport fixes to base path generation that prevent issue when a URL contains // it can circumvent the base path generation, which results in unwanted user data in the base/webroot paths. This creates an opportunity for CSS manipulation in old versions of IE, and newer ones via iframe inheritance. --- lib/Cake/Network/CakeRequest.php | 2 ++ lib/Cake/Test/Case/Network/CakeRequestTest.php | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index a51a74c6531..eb9f9905fed 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -293,6 +293,8 @@ protected function _base() { if (!$baseUrl) { $base = dirname(env('PHP_SELF')); + // Clean up additional / which cause following code to fail.. + $base = preg_replace('#/+#', '/', $base); $indexPos = strpos($base, '/webroot/index.php'); if ($indexPos !== false) { diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index 88bbbba6aa6..accf7c6c6df 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -1361,6 +1361,24 @@ public function testBaseUrlWithModRewriteAndIndexPhp() { $this->assertEquals('/cakephp/bananas/eat/tasty_banana', $request->here); } + /** + * Test that even if mod_rewrite is on, and the url contains index.php + * and there are numerous //s that the base/webroot is calculated correctly. + * + * @return void + */ + public function testBaseUrlWithModRewriteAndExtraSlashes() { + $_SERVER['REQUEST_URI'] = '/cakephp/webroot///index.php/bananas/eat'; + $_SERVER['PHP_SELF'] = '/cakephp/webroot///index.php/bananas/eat'; + $_SERVER['PATH_INFO'] = '/bananas/eat'; + $request = new CakeRequest(); + + $this->assertEquals('/cakephp', $request->base); + $this->assertEquals('/cakephp/', $request->webroot); + $this->assertEquals('bananas/eat', $request->url); + $this->assertEquals('/cakephp/bananas/eat', $request->here); + } + /** * Test base, webroot, and URL parsing when there is no URL rewriting * From 56143c663e14b810965da8146a9bde50ddf8b857 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 11 Jun 2015 22:17:18 -0400 Subject: [PATCH 210/336] Update doc blocks for CakePlugin::load(). Refs #5665 --- lib/Cake/Core/CakePlugin.php | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/lib/Cake/Core/CakePlugin.php b/lib/Cake/Core/CakePlugin.php index 5f30887f40a..1c2a31a4477 100644 --- a/lib/Cake/Core/CakePlugin.php +++ b/lib/Cake/Core/CakePlugin.php @@ -37,14 +37,29 @@ class CakePlugin { * * Examples: * - * `CakePlugin::load('DebugKit')` will load the DebugKit plugin and will not load any bootstrap nor route files - * `CakePlugin::load('DebugKit', array('bootstrap' => true, 'routes' => true))` will load the bootstrap.php and routes.php files - * `CakePlugin::load('DebugKit', array('bootstrap' => false, 'routes' => true))` will load routes.php file but not bootstrap.php - * `CakePlugin::load('DebugKit', array('bootstrap' => array('config1', 'config2')))` will load config1.php and config2.php files - * `CakePlugin::load('DebugKit', array('bootstrap' => 'aCallableMethod'))` will run the aCallableMethod function to initialize it + * `CakePlugin::load('DebugKit')` * - * Bootstrap initialization functions can be expressed as a PHP callback type, including closures. Callbacks will receive two - * parameters (plugin name, plugin configuration) + * Will load the DebugKit plugin and will not load any bootstrap nor route files + * + * `CakePlugin::load('DebugKit', array('bootstrap' => true, 'routes' => true))` + * + * will load the bootstrap.php and routes.php files + * + * `CakePlugin::load('DebugKit', array('bootstrap' => false, 'routes' => true))` + * + * will load routes.php file but not bootstrap.php + * + * `CakePlugin::load('DebugKit', array('bootstrap' => array('config1', 'config2')))` + * + * will load config1.php and config2.php files + * + * `CakePlugin::load('DebugKit', array('bootstrap' => 'aCallableMethod'))` + * + * will run the aCallableMethod function to initialize it + * + * Bootstrap initialization functions can be expressed as a PHP callback type, + * including closures. Callbacks will receive two parameters + * (plugin name, plugin configuration) * * It is also possible to load multiple plugins at once. Examples: * @@ -63,7 +78,9 @@ class CakePlugin { * ), array('bootstrap' => true)) * ``` * - * Will only load the bootstrap for ApiGenerator and only the routes for DebugKit + * Will only load the bootstrap for ApiGenerator and only the routes for DebugKit. + * By using the `path` option you can specify an absolute path to the plugin. Make + * sure that the path is slash terminated or your plugin will not be located properly. * * @param string|array $plugin name of the plugin to be loaded in CamelCase format or array or plugins to load * @param array $config configuration options for the plugin From 90da605cc8cf7397b6080952e7123a0c18244d53 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 13 Jun 2015 15:48:27 -0400 Subject: [PATCH 211/336] Re-enable 5.2 as travis still supports it for now. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 82761958e4c..54a265566c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: php php: + - 5.2 - 5.3 - 5.4 - 5.5 From f3099fefdff4fdf1b0facc47ea0df27482a4804b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Mon, 15 Jun 2015 00:56:09 +0200 Subject: [PATCH 212/336] Define code coverage explicitly --- lib/Cake/Test/Case/Utility/FileTest.php | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/Cake/Test/Case/Utility/FileTest.php b/lib/Cake/Test/Case/Utility/FileTest.php index ce433a7f355..f596767c4a4 100644 --- a/lib/Cake/Test/Case/Utility/FileTest.php +++ b/lib/Cake/Test/Case/Utility/FileTest.php @@ -23,6 +23,7 @@ * FileTest class * * @package Cake.Test.Case.Utility + * @coversDefaultClass File */ class FileTest extends CakeTestCase { @@ -62,6 +63,15 @@ public function tearDown() { * testBasic method * * @return void + * @covers ::__construct + * @covers ::info + * @covers ::ext + * @covers ::name + * @covers ::md5 + * @covers ::size + * @covers ::owner + * @covers ::group + * @covers ::Folder */ public function testBasic() { $file = CAKE . DS . 'LICENSE.txt'; @@ -126,6 +136,7 @@ function_exists('mime_content_type') && * testPermission method * * @return void + * @covers ::perms */ public function testPermission() { $this->skipIf(DIRECTORY_SEPARATOR === '\\', 'File permissions tests not supported on Windows.'); @@ -172,6 +183,7 @@ public function testPermission() { * testRead method * * @return void + * @covers ::read */ public function testRead() { $file = __FILE__; @@ -203,6 +215,7 @@ public function testRead() { * testOffset method * * @return void + * @covers ::offset */ public function testOffset() { $this->File->close(); @@ -235,6 +248,7 @@ public function testOffset() { * testOpen method * * @return void + * @covers ::open */ public function testOpen() { $this->File->handle = null; @@ -259,6 +273,7 @@ public function testOpen() { * testClose method * * @return void + * @covers ::close */ public function testClose() { $this->File->handle = null; @@ -276,6 +291,9 @@ public function testClose() { * testCreate method * * @return void + * @covers ::create + * @covers ::exists + * @covers ::clearStatCache */ public function testCreate() { $tmpFile = TMP . 'tests' . DS . 'cakephp.file.test.tmp'; @@ -287,6 +305,8 @@ public function testCreate() { * testOpeningNonExistentFileCreatesIt method * * @return void + * @covers ::open + * @covers ::create */ public function testOpeningNonExistentFileCreatesIt() { $someFile = new File(TMP . 'some_file.txt', false); @@ -300,6 +320,7 @@ public function testOpeningNonExistentFileCreatesIt() { * testPrepare method * * @return void + * @covers ::prepare */ public function testPrepare() { $string = "some\nvery\ncool\r\nteststring here\n\n\nfor\r\r\n\n\r\n\nhere"; @@ -320,6 +341,7 @@ public function testPrepare() { * testReadable method * * @return void + * @covers ::readable */ public function testReadable() { $someFile = new File(TMP . 'some_file.txt', false); @@ -333,6 +355,7 @@ public function testReadable() { * testWritable method * * @return void + * @covers ::writable */ public function testWritable() { $someFile = new File(TMP . 'some_file.txt', false); @@ -346,6 +369,7 @@ public function testWritable() { * testExecutable method * * @return void + * @covers ::executable */ public function testExecutable() { $someFile = new File(TMP . 'some_file.txt', false); @@ -359,6 +383,7 @@ public function testExecutable() { * testLastAccess method * * @return void + * @covers ::lastAccess */ public function testLastAccess() { $someFile = new File(TMP . 'some_file.txt', false); @@ -373,6 +398,7 @@ public function testLastAccess() { * testLastChange method * * @return void + * @covers ::lastChange */ public function testLastChange() { $someFile = new File(TMP . 'some_file.txt', false); @@ -391,6 +417,7 @@ public function testLastChange() { * testWrite method * * @return void + * @covers ::write */ public function testWrite() { if (!$tmpFile = $this->_getTmpFile()) { @@ -421,6 +448,7 @@ public function testWrite() { * testAppend method * * @return void + * @covers ::append */ public function testAppend() { if (!$tmpFile = $this->_getTmpFile()) { @@ -457,6 +485,7 @@ public function testAppend() { * testDelete method * * @return void + * @covers ::delete */ public function testDelete() { if (!$tmpFile = $this->_getTmpFile()) { @@ -482,6 +511,7 @@ public function testDelete() { * active filehandles open. * * @return void + * @covers ::delete */ public function testDeleteAfterRead() { if (!$tmpFile = $this->_getTmpFile()) { @@ -499,6 +529,7 @@ public function testDeleteAfterRead() { * testCopy method * * @return void + * @covers ::copy */ public function testCopy() { $dest = TMP . 'tests' . DS . 'cakephp.file.test.tmp'; @@ -527,6 +558,7 @@ public function testCopy() { * Test mime() * * @return void + * @covers ::mime */ public function testMime() { $this->skipIf(!function_exists('finfo_open') && !function_exists('mime_content_type'), 'Not able to read mime type'); @@ -566,6 +598,7 @@ protected function _getTmpFile($paintSkip = true) { * testReplaceText method * * @return void + * @covers ::replaceText */ public function testReplaceText() { $TestFile = new File(dirname(__FILE__) . '/../../test_app/Vendor/welcome.php'); @@ -603,6 +636,7 @@ public function testReplaceText() { * do not exist. * * @return void + * @covers ::pwd */ public function testNoPartialPathBeingSetForNonExistentPath() { $tmpFile = new File('/non/existent/file'); From 947262e754ecd6e159a2d16929eb62ce2b980709 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 14 Jun 2015 21:56:48 -0400 Subject: [PATCH 213/336] Fix PHPCS errors. --- lib/Cake/Test/Case/Network/CakeRequestTest.php | 12 ++++++------ lib/Cake/Test/Case/Utility/InflectorTest.php | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index 013ceeccd1b..2dfdfea4eb8 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -1423,12 +1423,12 @@ public function testBaseUrlWithModRewriteAndIndexPhp() { $this->assertEquals('/cakephp/bananas/eat/tasty_banana', $request->here); } - /** - * Test that even if mod_rewrite is on, and the url contains index.php - * and there are numerous //s that the base/webroot is calculated correctly. - * - * @return void - */ +/** + * Test that even if mod_rewrite is on, and the url contains index.php + * and there are numerous //s that the base/webroot is calculated correctly. + * + * @return void + */ public function testBaseUrlWithModRewriteAndExtraSlashes() { $_SERVER['REQUEST_URI'] = '/cakephp/webroot///index.php/bananas/eat'; $_SERVER['PHP_SELF'] = '/cakephp/webroot///index.php/bananas/eat'; diff --git a/lib/Cake/Test/Case/Utility/InflectorTest.php b/lib/Cake/Test/Case/Utility/InflectorTest.php index e3fd21191fc..bf7cd11c08b 100644 --- a/lib/Cake/Test/Case/Utility/InflectorTest.php +++ b/lib/Cake/Test/Case/Utility/InflectorTest.php @@ -460,7 +460,6 @@ public function testInflectorUnderscore() { $this->assertSame(Inflector::underscore(false), ''); } - /** * Test camelize() * From 0b20f6d334a6d658541da123682d75d45517d276 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 14 Jun 2015 22:00:29 -0400 Subject: [PATCH 214/336] PHP5.2 has no composer. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 54a265566c6..c62fd7bdeda 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,8 +27,8 @@ matrix: before_script: - - sh -c "composer global require 'phpunit/phpunit=3.7.33'" - - sh -c "ln -s ~/.composer/vendor/phpunit/phpunit/PHPUnit ./vendors/PHPUnit" + - sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then composer global require 'phpunit/phpunit=3.7.33'; fi" + - sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then ln -s ~/.composer/vendor/phpunit/phpunit/PHPUnit ./vendors/PHPUnit; fi" - sudo locale-gen de_DE - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi" - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test2;'; fi" From 0d3057bb772b7ada4df2189d60ad90bb59872968 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 14 Jun 2015 22:17:22 -0400 Subject: [PATCH 215/336] Re-remove 5.2 from travis.yml There are a bunch of failing tests in the JsonView and HttpSocket classes, both these failures are caused by annoying differences in PHP that I don't think are really worth working around. --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c62fd7bdeda..82761958e4c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 5.2 - 5.3 - 5.4 - 5.5 @@ -27,8 +26,8 @@ matrix: before_script: - - sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then composer global require 'phpunit/phpunit=3.7.33'; fi" - - sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then ln -s ~/.composer/vendor/phpunit/phpunit/PHPUnit ./vendors/PHPUnit; fi" + - sh -c "composer global require 'phpunit/phpunit=3.7.33'" + - sh -c "ln -s ~/.composer/vendor/phpunit/phpunit/PHPUnit ./vendors/PHPUnit" - sudo locale-gen de_DE - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi" - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test2;'; fi" From c3080873b997ab840189f4f00609dff41d7e3811 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 14 Jun 2015 22:50:05 -0400 Subject: [PATCH 216/336] Update version number to 2.7.0-RC --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index ccba2066f2e..0f4327170da 100644 --- a/lib/Cake/VERSION.txt +++ b/lib/Cake/VERSION.txt @@ -17,4 +17,4 @@ // @license http://www.opensource.org/licenses/mit-license.php MIT License // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -2.7.0-dev +2.7.0-RC From 86c358f3f901814ceb1b3d62c30b4ad422e14291 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Mon, 15 Jun 2015 16:35:27 +0200 Subject: [PATCH 217/336] Fix Validation::multiple() regarding 0 value. --- lib/Cake/Test/Case/Utility/ValidationTest.php | 14 ++++++++------ lib/Cake/Utility/Validation.php | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index 7126f6ecf17..bb53c1406b0 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -2085,8 +2085,9 @@ public function testMultiple() { $this->assertFalse(Validation::multiple('')); $this->assertFalse(Validation::multiple(null)); $this->assertFalse(Validation::multiple(array())); - $this->assertFalse(Validation::multiple(array(0))); - $this->assertFalse(Validation::multiple(array('0'))); + $this->assertTrue(Validation::multiple(array(0))); + $this->assertTrue(Validation::multiple(array('0'))); + $this->assertFalse(Validation::multiple(array(''))); $this->assertTrue(Validation::multiple(array(0, 3, 4, 5), array('in' => range(0, 10)))); $this->assertFalse(Validation::multiple(array(0, 15, 20, 5), array('in' => range(0, 10)))); @@ -2094,8 +2095,9 @@ public function testMultiple() { $this->assertFalse(Validation::multiple(array('boo', 'foo', 'bar'), array('in' => array('foo', 'bar', 'baz')))); $this->assertFalse(Validation::multiple(array('foo', '1bar'), array('in' => range(0, 10)))); - $this->assertTrue(Validation::multiple(array(0, 5, 10, 11), array('max' => 3))); - $this->assertFalse(Validation::multiple(array(0, 5, 10, 11, 55), array('max' => 3))); + $this->assertFalse(Validation::multiple(array(1, 5, 10, 11), array('max' => 3))); + $this->assertTrue(Validation::multiple(array(0, 5, 10, 11), array('max' => 4))); + $this->assertFalse(Validation::multiple(array(0, 5, 10, 11, 55), array('max' => 4))); $this->assertTrue(Validation::multiple(array('foo', 'bar', 'baz'), array('max' => 3))); $this->assertFalse(Validation::multiple(array('foo', 'bar', 'baz', 'squirrel'), array('max' => 3))); @@ -2110,8 +2112,8 @@ public function testMultiple() { $this->assertFalse(Validation::multiple(array(0, 5, 9, 8, 6, 2, 1), array('in' => range(0, 10), 'max' => 5))); $this->assertFalse(Validation::multiple(array(0, 5, 9, 8, 11), array('in' => range(0, 10), 'max' => 5))); - $this->assertFalse(Validation::multiple(array(0, 5, 9), array('in' => range(0, 10), 'max' => 5, 'min' => 3))); - $this->assertFalse(Validation::multiple(array(0, 5, 9, 8, 6, 2, 1), array('in' => range(0, 10), 'max' => 5, 'min' => 2))); + $this->assertFalse(Validation::multiple(array(-1, 5, 9), array('in' => range(0, 10), 'max' => 5, 'min' => 3))); + $this->assertFalse(Validation::multiple(array(-1, 5, 9, 8, 6, 2, 1), array('in' => range(0, 10), 'max' => 5, 'min' => 2))); $this->assertFalse(Validation::multiple(array(0, 5, 9, 8, 11), array('in' => range(0, 10), 'max' => 5, 'min' => 2))); $this->assertFalse(Validation::multiple(array('2x', '3x'), array('in' => array(1, 2, 3, 4, 5)))); diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index a2243694d16..d5e0e459469 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -143,7 +143,7 @@ public static function blank($check) { * Returns true if $check is in the proper credit card format. * * @param string|array $check credit card number to validate - * @param string|array $type 'all' may be passed as a sting, defaults to fast which checks format of most major credit + * @param string|array $type 'all' may be passed as a sting, defaults to fast which checks format of most major credit * cards * if an array is used only the values of the array are checked. * Example: array('amex', 'bankcard', 'maestro') @@ -594,7 +594,7 @@ public static function multiple($check, $options = array(), $caseInsensitive = f $defaults = array('in' => null, 'max' => null, 'min' => null); $options += $defaults; - $check = array_filter((array)$check); + $check = array_filter((array)$check, 'strlen'); if (empty($check)) { return false; } From 97be9b9696546512e71b790efc6d792d72c88108 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 15 Jun 2015 12:19:20 -0400 Subject: [PATCH 218/336] Fix PHPCS errors. --- lib/Cake/Test/Case/Network/CakeRequestTest.php | 12 ++++++------ lib/Cake/Test/Case/Utility/InflectorTest.php | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index accf7c6c6df..e30803b1757 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -1361,12 +1361,12 @@ public function testBaseUrlWithModRewriteAndIndexPhp() { $this->assertEquals('/cakephp/bananas/eat/tasty_banana', $request->here); } - /** - * Test that even if mod_rewrite is on, and the url contains index.php - * and there are numerous //s that the base/webroot is calculated correctly. - * - * @return void - */ +/** + * Test that even if mod_rewrite is on, and the url contains index.php + * and there are numerous //s that the base/webroot is calculated correctly. + * + * @return void + */ public function testBaseUrlWithModRewriteAndExtraSlashes() { $_SERVER['REQUEST_URI'] = '/cakephp/webroot///index.php/bananas/eat'; $_SERVER['PHP_SELF'] = '/cakephp/webroot///index.php/bananas/eat'; diff --git a/lib/Cake/Test/Case/Utility/InflectorTest.php b/lib/Cake/Test/Case/Utility/InflectorTest.php index e3fd21191fc..bf7cd11c08b 100644 --- a/lib/Cake/Test/Case/Utility/InflectorTest.php +++ b/lib/Cake/Test/Case/Utility/InflectorTest.php @@ -460,7 +460,6 @@ public function testInflectorUnderscore() { $this->assertSame(Inflector::underscore(false), ''); } - /** * Test camelize() * From ccac3b3e06fbb9bb7aa95ad912e0647e5c0682a7 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Tue, 16 Jun 2015 13:23:51 +0200 Subject: [PATCH 219/336] Allow deep options for radio() just as for select(). --- .../Test/Case/View/Helper/FormHelperTest.php | 28 +++++++++++++++++++ lib/Cake/View/Helper/FormHelper.php | 20 ++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index a1ef2cd9edf..bbd81dd7c9e 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -4432,6 +4432,34 @@ public function testRadioAddEmptyOption() { $this->assertTextNotContains('"Model1Field"', $result); } +/** + * Test that radio() accepts a deep array for options + * + * @return void + */ + public function testRadioOptionsArray() { + $result = $this->Form->input('Model.field', array( + 'type' => 'radio', + 'legend' => false, + 'div' => false, + 'options' => array( + '1' => array('name' => 'Option A', 'title' => 'A Title'), + '2' => array('name' => 'Option B', 'data-foo' => 'bar')) + )); + $expected = array( + array('input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'id' => 'ModelField_', 'value' => '')), + array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'id' => 'ModelField1', 'value' => '1', 'title' => 'A Title')), + array('label' => array('for' => 'ModelField1')), + 'Option A', + '/label', + array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'id' => 'ModelField2', 'value' => '2', 'data-foo' => 'bar')), + array('label' => array('for' => 'ModelField2')), + 'Option B', + '/label' + ); + $this->assertTags($result, $expected); + } + /** * Test that radio() accepts an array for label * diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 2a9f5be6c19..1edbe75513e 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -1471,6 +1471,15 @@ public function checkbox($fieldName, $options = array()) { * Creates a set of radio widgets. Will create a legend and fieldset * by default. Use $options to control this * + * You can also customize each radio input element using an array of arrays: + * + * ``` + * $options = array( + * array('name' => 'United states', 'value' => 'US', 'title' => 'My title'), + * array('name' => 'Germany', 'value' => 'DE', 'class' => 'de-de', 'title' => 'Another title'), + * ); + * ``` + * * ### Attributes: * * - `separator` - define the string in between the radio buttons @@ -1553,6 +1562,15 @@ public function radio($fieldName, $options = array(), $attributes = array()) { $this->_domIdSuffixes = array(); foreach ($options as $optValue => $optTitle) { $optionsHere = array('value' => $optValue, 'disabled' => false); + if (is_array($optTitle)) { + if (isset($optTitle['value'])) { + $optionsHere['value'] = $optTitle['value']; + } + + $optionsHere += $optTitle; + $optTitle = $optionsHere['name']; + unset($optionsHere['name']); + } if (isset($value) && strval($optValue) === strval($value)) { $optionsHere['checked'] = 'checked'; @@ -1572,7 +1590,7 @@ public function radio($fieldName, $options = array(), $attributes = array()) { if (is_array($between)) { $optTitle .= array_shift($between); } - $allOptions = array_merge($attributes, $optionsHere); + $allOptions = $optionsHere + $attributes; $out[] = $this->Html->useTag('radio', $attributes['name'], $tagName, array_diff_key($allOptions, array('name' => null, 'type' => null, 'id' => null)), $optTitle From 2d0374e46506907025a99bf38356a7edf9f96248 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 16 Jun 2015 09:56:42 -0400 Subject: [PATCH 220/336] Remove 5.2. A bunch of tests fail and its not worth the candle to fix them as 5.2 is pretty old and dangerous to use. --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c62fd7bdeda..82761958e4c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 5.2 - 5.3 - 5.4 - 5.5 @@ -27,8 +26,8 @@ matrix: before_script: - - sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then composer global require 'phpunit/phpunit=3.7.33'; fi" - - sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then ln -s ~/.composer/vendor/phpunit/phpunit/PHPUnit ./vendors/PHPUnit; fi" + - sh -c "composer global require 'phpunit/phpunit=3.7.33'" + - sh -c "ln -s ~/.composer/vendor/phpunit/phpunit/PHPUnit ./vendors/PHPUnit" - sudo locale-gen de_DE - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi" - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test2;'; fi" From 51d75bc2bec065c5c36c5933f4c9e56ee7cc7373 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Wed, 17 Jun 2015 11:04:04 +0200 Subject: [PATCH 221/336] Remove overhead whitespace in templates. --- lib/Cake/View/Helper/HtmlHelper.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index adb6220d51e..68e662c2d19 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -47,13 +47,13 @@ class HtmlHelper extends AppHelper { 'meta' => '', 'metalink' => '', 'link' => '%s', - 'mailto' => '%s', + 'mailto' => '%s', 'form' => '
', 'formend' => '
', 'input' => '', 'textarea' => '', 'hidden' => '', - 'checkbox' => '', + 'checkbox' => '', 'checkboxmultiple' => '', 'radio' => '%s', 'selectstart' => '', - 'file' => '', - 'file_no_model' => '', - 'submit' => '', - 'submitimage' => '', + 'password' => '', + 'file' => '', + 'file_no_model' => '', + 'submit' => '', + 'submitimage' => '', 'button' => '%s', - 'image' => '', + 'image' => '', 'tableheader' => '%s', 'tableheaderrow' => '%s', 'tablecell' => '%s', @@ -91,7 +91,7 @@ class HtmlHelper extends AppHelper { 'fieldsetstart' => '
%s', 'fieldsetend' => '
', 'legend' => '%s', - 'css' => '', + 'css' => '', 'style' => '', 'charset' => '', 'ul' => '%s', @@ -1188,7 +1188,7 @@ protected function _nestedListItem($items, $options, $itemOptions, $tag) { * * ``` * $tags = array( - * 'meta' => '' + * 'meta' => '' * ); * ``` * From 2d7487d33c0a1e0c74d399897803a437c8e056ad Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Wed, 17 Jun 2015 11:34:03 +0200 Subject: [PATCH 222/336] img tag needs manual space --- lib/Cake/View/Helper/HtmlHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index 68e662c2d19..2a3e02e55ff 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -71,7 +71,7 @@ class HtmlHelper extends AppHelper { 'submit' => '', 'submitimage' => '', 'button' => '%s', - 'image' => '', + 'image' => '', 'tableheader' => '%s', 'tableheaderrow' => '%s', 'tablecell' => '%s', From 7dedf7f86dbc49f667c9db9707f236e243920217 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Wed, 17 Jun 2015 11:38:42 +0200 Subject: [PATCH 223/336] Refactor cleanly. --- lib/Cake/View/Helper/HtmlHelper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index 2a3e02e55ff..ae5741136ef 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -71,7 +71,7 @@ class HtmlHelper extends AppHelper { 'submit' => '', 'submitimage' => '', 'button' => '%s', - 'image' => '', + 'image' => '', 'tableheader' => '%s', 'tableheaderrow' => '%s', 'tablecell' => '%s', @@ -828,7 +828,7 @@ public function image($path, $options = array()) { unset($options['url']); } - $image = sprintf($this->_tags['image'], $path, $this->_parseAttributes($options, null, '', ' ')); + $image = sprintf($this->_tags['image'], $path, $this->_parseAttributes($options, null, ' ', ' ')); if ($url) { return sprintf($this->_tags['link'], $this->url($url), null, $image); From 1b813234623f1d597d1d76e847453abadf15f25e Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Wed, 17 Jun 2015 12:06:56 +0200 Subject: [PATCH 224/336] Use strict check --- lib/Cake/Utility/Validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index 80037c203f7..3ada62684ed 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -77,7 +77,7 @@ public static function notBlank($check) { extract(self::_defaults($check)); } - if (empty($check) && $check != '0') { + if (empty($check) && $check !== '0') { return false; } return self::_check($check, '/[^\s]+/m'); From 4025f2fb22a7093e9363b1b98fce05167f23d6e2 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Wed, 17 Jun 2015 12:38:06 +0200 Subject: [PATCH 225/336] add cast for clarification and to allow int 0. --- lib/Cake/Utility/Validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index 3ada62684ed..574cf2f64a8 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -77,7 +77,7 @@ public static function notBlank($check) { extract(self::_defaults($check)); } - if (empty($check) && $check !== '0') { + if (empty($check) && (string)$check !== '0') { return false; } return self::_check($check, '/[^\s]+/m'); From 705f44e30a55c92b8f92a5fd6d61573f037f0c37 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 19 Jun 2015 22:00:27 -0400 Subject: [PATCH 226/336] Fix regression where attributes were created with no whitespace. --- lib/Cake/View/Helper/HtmlHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index ae5741136ef..a99b090b98d 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -91,7 +91,7 @@ class HtmlHelper extends AppHelper { 'fieldsetstart' => '
%s', 'fieldsetend' => '
', 'legend' => '%s', - 'css' => '', + 'css' => '', 'style' => '', 'charset' => '', 'ul' => '%s', From 1d03d5bd59cc807a6ddb97b618c95662303ccb60 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Sat, 20 Jun 2015 05:10:35 +0200 Subject: [PATCH 227/336] Consolidate template whitespace --- lib/Cake/View/Helper/HtmlHelper.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index a99b090b98d..07acb91b242 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -91,7 +91,7 @@ class HtmlHelper extends AppHelper { 'fieldsetstart' => '
%s', 'fieldsetend' => '
', 'legend' => '%s', - 'css' => '', + 'css' => '', 'style' => '', 'charset' => '', 'ul' => '%s', @@ -472,7 +472,7 @@ public function css($path, $options = array()) { if ($options['rel'] === 'import') { $out = sprintf( $this->_tags['style'], - $this->_parseAttributes($options, array('rel', 'block'), '', ' '), + $this->_parseAttributes($options, array('rel', 'block')), '@import url(' . $url . ');' ); } else { @@ -480,7 +480,7 @@ public function css($path, $options = array()) { $this->_tags['css'], $options['rel'], $url, - $this->_parseAttributes($options, array('rel', 'block'), '', ' ') + $this->_parseAttributes($options, array('rel', 'block')) ); } From 6e5381a4e3cd3a1cb3f161be333fd12ea6a9b0a3 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Sat, 20 Jun 2015 23:27:32 +0200 Subject: [PATCH 228/336] Cleanup method calls. --- lib/Cake/View/Helper/HtmlHelper.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index 07acb91b242..8a7bc15a8e8 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -279,12 +279,12 @@ public function meta($type, $url = null, $options = array()) { if (isset($options['link'])) { $options['link'] = $this->assetUrl($options['link']); if (isset($options['rel']) && $options['rel'] === 'icon') { - $out = sprintf($this->_tags['metalink'], $options['link'], $this->_parseAttributes($options, array('block', 'link'), ' ', ' ')); + $out = sprintf($this->_tags['metalink'], $options['link'], $this->_parseAttributes($options, array('block', 'link'))); $options['rel'] = 'shortcut icon'; } - $out .= sprintf($this->_tags['metalink'], $options['link'], $this->_parseAttributes($options, array('block', 'link'), ' ', ' ')); + $out .= sprintf($this->_tags['metalink'], $options['link'], $this->_parseAttributes($options, array('block', 'link'))); } else { - $out = sprintf($this->_tags['meta'], $this->_parseAttributes($options, array('block', 'type'), ' ', ' ')); + $out = sprintf($this->_tags['meta'], $this->_parseAttributes($options, array('block', 'type'))); } if (empty($options['block'])) { @@ -565,7 +565,7 @@ public function script($url, $options = array()) { $url = str_replace(Configure::read('App.jsBaseUrl'), 'cjs/', $url); } } - $attributes = $this->_parseAttributes($options, array('block', 'once'), ' '); + $attributes = $this->_parseAttributes($options, array('block', 'once')); $out = sprintf($this->_tags['javascriptlink'], $url, $attributes); if (empty($options['block'])) { @@ -601,7 +601,7 @@ public function scriptBlock($script, $options = array()) { } unset($options['inline'], $options['safe']); - $attributes = $this->_parseAttributes($options, array('block'), ' '); + $attributes = $this->_parseAttributes($options, array('block')); $out = sprintf($this->_tags['javascriptblock'], $attributes, $script); if (empty($options['block'])) { @@ -828,7 +828,7 @@ public function image($path, $options = array()) { unset($options['url']); } - $image = sprintf($this->_tags['image'], $path, $this->_parseAttributes($options, null, ' ', ' ')); + $image = sprintf($this->_tags['image'], $path, $this->_parseAttributes($options)); if ($url) { return sprintf($this->_tags['link'], $this->url($url), null, $image); @@ -939,7 +939,7 @@ public function tag($name, $text = null, $options = array()) { } else { $tag = 'tag'; } - return sprintf($this->_tags[$tag], $name, $this->_parseAttributes($options, null, ' ', ''), $text, $name); + return sprintf($this->_tags[$tag], $name, $this->_parseAttributes($options), $text, $name); } /** @@ -957,7 +957,7 @@ public function useTag($tag) { array_shift($args); foreach ($args as &$arg) { if (is_array($arg)) { - $arg = $this->_parseAttributes($arg, null, ' ', ''); + $arg = $this->_parseAttributes($arg); } } return vsprintf($this->_tags[$tag], $args); @@ -1008,7 +1008,7 @@ public function para($class, $text, $options = array()) { if ($text === null) { $tag = 'parastart'; } - return sprintf($this->_tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $text); + return sprintf($this->_tags[$tag], $this->_parseAttributes($options), $text); } /** @@ -1144,7 +1144,7 @@ public function nestedList($list, $options = array(), $itemOptions = array(), $t $options = array(); } $items = $this->_nestedListItem($list, $options, $itemOptions, $tag); - return sprintf($this->_tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $items); + return sprintf($this->_tags[$tag], $this->_parseAttributes($options), $items); } /** @@ -1170,7 +1170,7 @@ protected function _nestedListItem($items, $options, $itemOptions, $tag) { } elseif (isset($itemOptions['odd']) && $index % 2 !== 0) { $itemOptions['class'] = $itemOptions['odd']; } - $out .= sprintf($this->_tags['li'], $this->_parseAttributes($itemOptions, array('even', 'odd'), ' ', ''), $item); + $out .= sprintf($this->_tags['li'], $this->_parseAttributes($itemOptions, array('even', 'odd')), $item); $index++; } return $out; From 26630991a6eb07a2a947e036c359f97519ec654e Mon Sep 17 00:00:00 2001 From: Humberto Pereira Date: Sat, 13 Jun 2015 12:45:27 -0400 Subject: [PATCH 229/336] CakeShells should not print html in case of a error --- lib/Cake/Console/ShellDispatcher.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Cake/Console/ShellDispatcher.php b/lib/Cake/Console/ShellDispatcher.php index 30f37aa0978..20423775152 100644 --- a/lib/Cake/Console/ShellDispatcher.php +++ b/lib/Cake/Console/ShellDispatcher.php @@ -177,6 +177,9 @@ public function setErrorHandlers() { } set_exception_handler($exception['consoleHandler']); set_error_handler($error['consoleHandler'], Configure::read('Error.level')); + + App::uses('Debugger', 'Utility'); + Debugger::getInstance()->output('txt'); } /** From 77150eb6f6675f1dc7ca9a366135826c53cbeb91 Mon Sep 17 00:00:00 2001 From: Humberto Pereira Date: Sat, 13 Jun 2015 12:48:29 -0400 Subject: [PATCH 230/336] fixed tests cases to print html --- lib/Cake/Test/Case/Error/ErrorHandlerTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php index aa7448d6454..18930737b32 100644 --- a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php +++ b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php @@ -19,6 +19,7 @@ App::uses('ErrorHandler', 'Error'); App::uses('Controller', 'Controller'); App::uses('Router', 'Routing'); +App::uses('Debugger', 'Utility'); /** * A faulty ExceptionRenderer to test nesting. @@ -92,6 +93,8 @@ public function testHandleErrorDebugOn() { set_error_handler('ErrorHandler::handleError'); $this->_restoreError = true; + Debugger::getInstance()->output('html'); + ob_start(); $wrong .= ''; $result = ob_get_clean(); @@ -123,6 +126,8 @@ public function testErrorMapping($error, $expected) { set_error_handler('ErrorHandler::handleError'); $this->_restoreError = true; + Debugger::getInstance()->output('html'); + ob_start(); trigger_error('Test error', $error); From fc57e43a5b2994bd5b482009676bbd28331a4488 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Sun, 21 Jun 2015 12:13:09 +0200 Subject: [PATCH 231/336] Adjust tests. --- lib/Cake/Test/Case/Network/Email/CakeEmailTest.php | 2 +- lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php | 1 - lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php | 10 +++++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index c6bed1d73a9..90f55c364f3 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -1570,7 +1570,7 @@ public function testSendRenderWithImage() { $server .= ':' . env('SERVER_PORT'); } - $expected = 'cool image'; + $expected = 'cool image'; $result = $this->CakeEmail->send(); $this->assertContains($expected, $result['message']); } diff --git a/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php b/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php index 873f6a955b5..ea16d323219 100644 --- a/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php @@ -1755,7 +1755,6 @@ public function testMeta() { $result = $this->Html->meta('keywords', 'these, are, some, meta, keywords'); $this->assertTags($result, array('meta' => array('name' => 'keywords', 'content' => 'these, are, some, meta, keywords'))); - $this->assertRegExp('/\s+\/>$/', $result); $result = $this->Html->meta('description', 'this is the meta description'); $this->assertTags($result, array('meta' => array('name' => 'description', 'content' => 'this is the meta description'))); diff --git a/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php b/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php index 5b37bf4f074..cb271c6b078 100644 --- a/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php @@ -2857,7 +2857,7 @@ public function testMetaPage1() { 'paramType' => 'querystring' ) ); - $expected = ''; + $expected = ''; $result = $this->Paginator->meta(); $this->assertSame($expected, $result); } @@ -2878,7 +2878,7 @@ public function testMetaPage1InlineFalse() { 'paramType' => 'querystring' ) ); - $expected = ''; + $expected = ''; $this->Paginator->meta(array('block' => true)); $result = $this->View->fetch('meta'); $this->assertSame($expected, $result); @@ -2900,7 +2900,7 @@ public function testMetaPage1Last() { 'paramType' => 'querystring' ) ); - $expected = ''; + $expected = ''; $result = $this->Paginator->meta(); $this->assertSame($expected, $result); } @@ -2921,8 +2921,8 @@ public function testMetaPage10Last() { 'paramType' => 'querystring' ) ); - $expected = ''; - $expected .= ''; + $expected = ''; + $expected .= ''; $result = $this->Paginator->meta(); $this->assertSame($expected, $result); } From 58983f717aa811f5fef81a67b43cbae58b1a1167 Mon Sep 17 00:00:00 2001 From: Highstrike Date: Wed, 24 Jun 2015 14:06:35 +0300 Subject: [PATCH 232/336] 2.7.0-RC Auth doesn't use the new Flash component Changed 'Flash.' to 'Message.' and also provided backwards compatibility in FlashHelper->render --- .../Controller/Component/FlashComponent.php | 2 +- .../Component/FlashComponentTest.php | 24 +++++++++---------- .../Test/Case/View/Helper/FlashHelperTest.php | 2 +- lib/Cake/View/Helper/FlashHelper.php | 17 +++++++++---- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/lib/Cake/Controller/Component/FlashComponent.php b/lib/Cake/Controller/Component/FlashComponent.php index 5c382d299f9..2e0fa4e6861 100644 --- a/lib/Cake/Controller/Component/FlashComponent.php +++ b/lib/Cake/Controller/Component/FlashComponent.php @@ -84,7 +84,7 @@ public function set($message, $options = array()) { $options['element'] = 'Flash/' . $element; } - CakeSession::write('Flash.' . $options['key'], array( + CakeSession::write('Message.' . $options['key'], array( 'message' => $message, 'key' => $options['key'], 'element' => $options['element'], diff --git a/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php b/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php index 373cdf1940d..56905c54555 100644 --- a/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php @@ -55,7 +55,7 @@ public function tearDown() { * @return void */ public function testSet() { - $this->assertNull(CakeSession::read('Flash.flash')); + $this->assertNull(CakeSession::read('Message.flash')); $this->Flash->set('This is a test message'); $expected = array( @@ -64,7 +64,7 @@ public function testSet() { 'element' => 'Flash/default', 'params' => array() ); - $result = CakeSession::read('Flash.flash'); + $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); $this->Flash->set('This is a test message', array( @@ -77,7 +77,7 @@ public function testSet() { 'element' => 'Flash/test', 'params' => array('foo' => 'bar') ); - $result = CakeSession::read('Flash.flash'); + $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); $this->Flash->set('This is a test message', array('element' => 'MyPlugin.alert')); @@ -87,7 +87,7 @@ public function testSet() { 'element' => 'MyPlugin.Flash/alert', 'params' => array() ); - $result = CakeSession::read('Flash.flash'); + $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); $this->Flash->set('This is a test message', array('key' => 'foobar')); @@ -97,7 +97,7 @@ public function testSet() { 'element' => 'Flash/default', 'params' => array() ); - $result = CakeSession::read('Flash.foobar'); + $result = CakeSession::read('Message.foobar'); $this->assertEquals($expected, $result); } @@ -107,7 +107,7 @@ public function testSet() { * @return void */ public function testSetWithException() { - $this->assertNull(CakeSession::read('Flash.flash')); + $this->assertNull(CakeSession::read('Message.flash')); $this->Flash->set(new Exception('This is a test message', 404)); $expected = array( @@ -116,7 +116,7 @@ public function testSetWithException() { 'element' => 'Flash/default', 'params' => array('code' => 404) ); - $result = CakeSession::read('Flash.flash'); + $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); } @@ -126,7 +126,7 @@ public function testSetWithException() { * @return void */ public function testSetWithComponentConfiguration() { - $this->assertNull(CakeSession::read('Flash.flash')); + $this->assertNull(CakeSession::read('Message.flash')); $FlashWithSettings = $this->Components->load('Flash', array('element' => 'test')); $FlashWithSettings->set('This is a test message'); @@ -136,7 +136,7 @@ public function testSetWithComponentConfiguration() { 'element' => 'Flash/test', 'params' => array() ); - $result = CakeSession::read('Flash.flash'); + $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); } @@ -146,7 +146,7 @@ public function testSetWithComponentConfiguration() { * @return void */ public function testCall() { - $this->assertNull(CakeSession::read('Flash.flash')); + $this->assertNull(CakeSession::read('Message.flash')); $this->Flash->success('It worked'); $expected = array( @@ -155,7 +155,7 @@ public function testCall() { 'element' => 'Flash/success', 'params' => array() ); - $result = CakeSession::read('Flash.flash'); + $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); $this->Flash->error('It did not work', array('element' => 'error_thing')); @@ -165,7 +165,7 @@ public function testCall() { 'element' => 'Flash/error', 'params' => array() ); - $result = CakeSession::read('Flash.flash'); + $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result, 'Element is ignored in magic call.'); } } diff --git a/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php b/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php index d7cf2dc7b2c..ea9221ee6ac 100644 --- a/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php @@ -120,7 +120,7 @@ public function testFlash() { * @expectedException UnexpectedValueException */ public function testFlashThrowsException() { - CakeSession::write('Flash.foo', 'bar'); + CakeSession::write('Message.foo', 'bar'); $this->Flash->render('foo'); } diff --git a/lib/Cake/View/Helper/FlashHelper.php b/lib/Cake/View/Helper/FlashHelper.php index d0ca89e8cea..798e1a5f35e 100644 --- a/lib/Cake/View/Helper/FlashHelper.php +++ b/lib/Cake/View/Helper/FlashHelper.php @@ -61,7 +61,7 @@ class FlashHelper extends AppHelper { * )); * ``` * - * @param string $key The [Flash.]key you are rendering in the view. + * @param string $key The [Message.]key you are rendering in the view. * @param array $options Additional options to use for the creation of this flash message. * Supports the 'params', and 'element' keys that are used in the helper. * @return string|null Rendered flash message or null if flash key does not exist @@ -69,11 +69,11 @@ class FlashHelper extends AppHelper { * @throws UnexpectedValueException If value for flash settings key is not an array. */ public function render($key = 'flash', $options = array()) { - if (!CakeSession::check("Flash.$key")) { + if (!CakeSession::check("Message.$key")) { return; } - $flash = CakeSession::read("Flash.$key"); + $flash = CakeSession::read("Message.$key"); if (!is_array($flash)) { throw new UnexpectedValueException(sprintf( @@ -83,7 +83,16 @@ public function render($key = 'flash', $options = array()) { } $flash = $options + $flash; - CakeSession::delete("Flash.$key"); + CakeSession::delete("Message.$key"); + + // backwards compatibility with Session->setFlash + if($flash['element'] === 'default') { + $class = 'message'; + if (!empty($flash['params']['class'])) { + $class = $flash['params']['class']; + } + return '
' . $flash['message'] . '
'; + } return $this->_View->element($flash['element'], $flash); } From 7cdf19363dbbeffd762e5b04c1aff4c99867d3b2 Mon Sep 17 00:00:00 2001 From: Highstrike Date: Wed, 24 Jun 2015 14:09:32 +0300 Subject: [PATCH 233/336] Tab instead of space IDE preference --- lib/Cake/View/Helper/FlashHelper.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/Cake/View/Helper/FlashHelper.php b/lib/Cake/View/Helper/FlashHelper.php index 798e1a5f35e..6dae5f0caad 100644 --- a/lib/Cake/View/Helper/FlashHelper.php +++ b/lib/Cake/View/Helper/FlashHelper.php @@ -86,13 +86,13 @@ public function render($key = 'flash', $options = array()) { CakeSession::delete("Message.$key"); // backwards compatibility with Session->setFlash - if($flash['element'] === 'default') { - $class = 'message'; - if (!empty($flash['params']['class'])) { - $class = $flash['params']['class']; - } - return '
' . $flash['message'] . '
'; - } + if($flash['element'] === 'default') { + $class = 'message'; + if (!empty($flash['params']['class'])) { + $class = $flash['params']['class']; + } + return '
' . $flash['message'] . '
'; + } return $this->_View->element($flash['element'], $flash); } From 833c747b41ccf01bdedbdb8e3638798bfa8d0407 Mon Sep 17 00:00:00 2001 From: Highstrike Date: Wed, 24 Jun 2015 14:18:14 +0300 Subject: [PATCH 234/336] Test append PR to Issue This commit fixes #6874 --- lib/Cake/View/Helper/FlashHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/View/Helper/FlashHelper.php b/lib/Cake/View/Helper/FlashHelper.php index 6dae5f0caad..90eb9cb6c21 100644 --- a/lib/Cake/View/Helper/FlashHelper.php +++ b/lib/Cake/View/Helper/FlashHelper.php @@ -85,7 +85,7 @@ public function render($key = 'flash', $options = array()) { $flash = $options + $flash; CakeSession::delete("Message.$key"); - // backwards compatibility with Session->setFlash + // backwards compatibility with Session->setFlash() if($flash['element'] === 'default') { $class = 'message'; if (!empty($flash['params']['class'])) { From ef1fc7dfefabc764217e2f0c6fd52ba11f2b4e6a Mon Sep 17 00:00:00 2001 From: Highstrike Date: Wed, 24 Jun 2015 15:18:57 +0300 Subject: [PATCH 235/336] PHPCS --- lib/Cake/View/Helper/FlashHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/View/Helper/FlashHelper.php b/lib/Cake/View/Helper/FlashHelper.php index 90eb9cb6c21..c61765675b9 100644 --- a/lib/Cake/View/Helper/FlashHelper.php +++ b/lib/Cake/View/Helper/FlashHelper.php @@ -86,7 +86,7 @@ public function render($key = 'flash', $options = array()) { CakeSession::delete("Message.$key"); // backwards compatibility with Session->setFlash() - if($flash['element'] === 'default') { + if ($flash['element'] === 'default') { $class = 'message'; if (!empty($flash['params']['class'])) { $class = $flash['params']['class']; From 8257100f542cf4b7fe1eefc4918c62888d25390b Mon Sep 17 00:00:00 2001 From: Highstrike Date: Wed, 24 Jun 2015 15:46:48 +0300 Subject: [PATCH 236/336] How about this? --- .../Templates/skel/View/Elements/Flash/default.ctp | 1 + lib/Cake/Console/Templates/skel/View/Elements/empty | 0 lib/Cake/Controller/Component/AuthComponent.php | 4 ++-- lib/Cake/View/Elements/Flash/default.ctp | 1 + lib/Cake/View/Helper/FlashHelper.php | 9 --------- 5 files changed, 4 insertions(+), 11 deletions(-) create mode 100644 lib/Cake/Console/Templates/skel/View/Elements/Flash/default.ctp delete mode 100644 lib/Cake/Console/Templates/skel/View/Elements/empty create mode 100644 lib/Cake/View/Elements/Flash/default.ctp diff --git a/lib/Cake/Console/Templates/skel/View/Elements/Flash/default.ctp b/lib/Cake/Console/Templates/skel/View/Elements/Flash/default.ctp new file mode 100644 index 00000000000..ce0f613558a --- /dev/null +++ b/lib/Cake/Console/Templates/skel/View/Elements/Flash/default.ctp @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/lib/Cake/Console/Templates/skel/View/Elements/empty b/lib/Cake/Console/Templates/skel/View/Elements/empty deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index 3d2169b47c0..88a8d60b169 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -50,7 +50,7 @@ class AuthComponent extends Component { * * @var array */ - public $components = array('Session', 'RequestHandler'); + public $components = array('Session', 'Flash', 'RequestHandler'); /** * An array of authentication objects to use for authenticating users. You can configure @@ -840,7 +840,7 @@ public function flash($message) { if ($message === false) { return; } - $this->Session->setFlash($message, $this->flash['element'], $this->flash['params'], $this->flash['key']); + $this->Flash->set($message, $this->flash); } } diff --git a/lib/Cake/View/Elements/Flash/default.ctp b/lib/Cake/View/Elements/Flash/default.ctp new file mode 100644 index 00000000000..ce0f613558a --- /dev/null +++ b/lib/Cake/View/Elements/Flash/default.ctp @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/lib/Cake/View/Helper/FlashHelper.php b/lib/Cake/View/Helper/FlashHelper.php index c61765675b9..46dc67ac4bb 100644 --- a/lib/Cake/View/Helper/FlashHelper.php +++ b/lib/Cake/View/Helper/FlashHelper.php @@ -85,15 +85,6 @@ public function render($key = 'flash', $options = array()) { $flash = $options + $flash; CakeSession::delete("Message.$key"); - // backwards compatibility with Session->setFlash() - if ($flash['element'] === 'default') { - $class = 'message'; - if (!empty($flash['params']['class'])) { - $class = $flash['params']['class']; - } - return '
' . $flash['message'] . '
'; - } - return $this->_View->element($flash['element'], $flash); } } From 1c56c723f5e21ba1abf8977ba070ec97217382a5 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Thu, 25 Jun 2015 00:52:33 +0200 Subject: [PATCH 237/336] Backport param() access. --- lib/Cake/Console/Shell.php | 13 +++++++ lib/Cake/Test/Case/Console/ShellTest.php | 45 ++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/lib/Cake/Console/Shell.php b/lib/Cake/Console/Shell.php index 35b1bb5e487..8301819498c 100644 --- a/lib/Cake/Console/Shell.php +++ b/lib/Cake/Console/Shell.php @@ -499,6 +499,19 @@ public function __get($name) { return $this->{$name}; } +/** + * Safely access the values in $this->params. + * + * @param string $name The name of the parameter to get. + * @return string|bool|null Value. Will return null if it doesn't exist. + */ + public function param($name) { + if (!isset($this->params[$name])) { + return null; + } + return $this->params[$name]; + } + /** * Prompts the user for input, and returns it. * diff --git a/lib/Cake/Test/Case/Console/ShellTest.php b/lib/Cake/Test/Case/Console/ShellTest.php index bfd8c9e4e9e..e157054392a 100644 --- a/lib/Cake/Test/Case/Console/ShellTest.php +++ b/lib/Cake/Test/Case/Console/ShellTest.php @@ -855,6 +855,51 @@ public function testShellNaming() { $this->assertEquals($expected, $this->Shell->TestApple->name); } +/** + * Test reading params + * + * @dataProvider paramReadingDataProvider + */ + public function testParamReading($toRead, $expected) { + $this->Shell->params = array( + 'key' => 'value', + 'help' => false, + 'emptykey' => '', + 'truthy' => true + ); + $this->assertSame($expected, $this->Shell->param($toRead)); + } + +/** + * Data provider for testing reading values with Shell::param() + * + * @return array + */ + public function paramReadingDataProvider() { + return array( + array( + 'key', + 'value', + ), + array( + 'help', + false, + ), + array( + 'emptykey', + '', + ), + array( + 'truthy', + true, + ), + array( + 'does_not_exist', + null, + ) + ); + } + /** * Test that option parsers are created with the correct name/command. * From 2f616a9e0cdf1cba7ff657a232e7c5452af44091 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 24 Jun 2015 23:39:26 -0400 Subject: [PATCH 238/336] Fix greedy regex operators in Postgres driver. `*` is greedy in regex, and needs to be escaped so that SQL operators don't cause invalid SQL conditions to be created. Refs #6877 --- lib/Cake/Model/Datasource/Database/Postgres.php | 2 +- lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Model/Datasource/Database/Postgres.php b/lib/Cake/Model/Datasource/Database/Postgres.php index 21d82b1910f..033527ae0d1 100644 --- a/lib/Cake/Model/Datasource/Database/Postgres.php +++ b/lib/Cake/Model/Datasource/Database/Postgres.php @@ -98,7 +98,7 @@ class Postgres extends DboSource { * * @var array */ - protected $_sqlOps = array('like', 'ilike', 'or', 'not', 'in', 'between', '~', '~*', '!~', '!~*', 'similar to'); + protected $_sqlOps = array('like', 'ilike', 'or', 'not', 'in', 'between', '~', '~\*', '\!~', '\!~\*', 'similar to'); /** * Connects to the database using options in the given configuration array. diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php index d51fd7c8790..03a964de68f 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php @@ -490,6 +490,10 @@ public function testRegexpOperatorConditionsParsing() { $this->assertSame(' WHERE "name" ~* \'[a-z_]+\'', $this->Dbo->conditions(array('name ~*' => '[a-z_]+'))); $this->assertSame(' WHERE "name" !~ \'[a-z_]+\'', $this->Dbo->conditions(array('name !~' => '[a-z_]+'))); $this->assertSame(' WHERE "name" !~* \'[a-z_]+\'', $this->Dbo->conditions(array('name !~*' => '[a-z_]+'))); + $this->assertSame( + ' WHERE EXTRACT( \'YEAR\' FROM "User"."birthday" ) = 2015', + $this->Dbo->conditions(array('EXTRACT( \'YEAR\' FROM User.birthday )' => 2015)) + ); } /** From a9d77d26f036fcb964071e485343c81d1656c57d Mon Sep 17 00:00:00 2001 From: Highstrike Date: Thu, 25 Jun 2015 13:40:50 +0300 Subject: [PATCH 239/336] fix failing tests fixing... --- .../Console/Command/Task/ProjectTaskTest.php | 1 - .../Component/AuthComponentTest.php | 30 +++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/lib/Cake/Test/Case/Console/Command/Task/ProjectTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ProjectTaskTest.php index b288b9cd7c2..15ec7679825 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ProjectTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ProjectTaskTest.php @@ -197,7 +197,6 @@ public function testBakeEmptyFlag() { 'Test' . DS . 'Case' . DS . 'View' . DS . 'Helper' => 'empty', 'Test' . DS . 'Fixture' => 'empty', 'Vendor' => 'empty', - 'View' . DS . 'Elements' => 'empty', 'View' . DS . 'Scaffolds' => 'empty', 'tmp' . DS . 'cache' . DS . 'models' => 'empty', 'tmp' . DS . 'cache' . DS . 'persistent' => 'empty', diff --git a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php index 89341b4e0cd..27e20abfb4f 100644 --- a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php @@ -165,7 +165,7 @@ class AuthTestController extends Controller { * * @var array */ - public $components = array('Session', 'Auth'); + public $components = array('Session', 'Flash', 'Auth'); /** * testUrl property @@ -1093,9 +1093,9 @@ public function testRedirectToUnauthorizedRedirect() { array('on', 'redirect'), array($CakeRequest, $CakeResponse) ); - $this->Auth->Session = $this->getMock( - 'SessionComponent', - array('setFlash'), + $this->Auth->Flash = $this->getMock( + 'FlashComponent', + array('set'), array($Controller->Components) ); @@ -1105,8 +1105,8 @@ public function testRedirectToUnauthorizedRedirect() { $Controller->expects($this->once()) ->method('redirect') ->with($this->equalTo($expected)); - $this->Auth->Session->expects($this->once()) - ->method('setFlash'); + $this->Auth->Flash->expects($this->once()) + ->method('set'); $this->Auth->startup($Controller); } @@ -1132,9 +1132,9 @@ public function testRedirectToUnauthorizedRedirectSuppressedAuthError() { array('on', 'redirect'), array($CakeRequest, $CakeResponse) ); - $this->Auth->Session = $this->getMock( - 'SessionComponent', - array('setFlash'), + $this->Auth->Flash = $this->getMock( + 'FlashComponent', + array('set'), array($Controller->Components) ); @@ -1144,8 +1144,8 @@ public function testRedirectToUnauthorizedRedirectSuppressedAuthError() { $Controller->expects($this->once()) ->method('redirect') ->with($this->equalTo($expected)); - $this->Auth->Session->expects($this->never()) - ->method('setFlash'); + $this->Auth->Flash->expects($this->never()) + ->method('set'); $this->Auth->startup($Controller); } @@ -1514,10 +1514,10 @@ public function testLoginWithUserData() { * @return void */ public function testFlashSettings() { - $this->Auth->Session = $this->getMock('SessionComponent', array(), array(), '', false); - $this->Auth->Session->expects($this->once()) - ->method('setFlash') - ->with('Auth failure', 'custom', array(1), 'auth-key'); + $this->Auth->Flash = $this->getMock('FlashComponent', array(), array(), '', false); + $this->Auth->Flash->expects($this->once()) + ->method('set') + ->with('Auth failure', array('element' => 'custom', 'params' => array(1), 'key' => 'auth-key')); $this->Auth->flash = array( 'element' => 'custom', From 0b28c2e83959cb6066cca772d9878facd7328947 Mon Sep 17 00:00:00 2001 From: Lawrence Barsanti Date: Wed, 24 Jun 2015 13:48:58 -0400 Subject: [PATCH 240/336] Added negative lookahead It is possible to have multiple occurrences of 'as' in a field name. Use the last occurrence of 'as' when extracting field name. Tested with following examples: "WeldCheck"."weld_id" count(*) as WeldCheck__num_measurements count(case decision when 2 then 1 else null end) as WeldCheck__num_failures avg(cast (WeldMeasurement.surface_indentation as bigint)) as WeldCheck__avg_indentation avg(cast (WeldMeasurement.circle_diameter as bigint)) as WeldCheck__avg_diameter --- lib/Cake/Model/Datasource/Database/Sqlite.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Model/Datasource/Database/Sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php index e7394744809..9bdc81c4cf7 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlite.php +++ b/lib/Cake/Model/Datasource/Database/Sqlite.php @@ -323,7 +323,7 @@ public function resultSet($results) { $j++; continue; } - if (preg_match('/\bAS\s+(.*)/i', $selects[$j], $matches)) { + if (preg_match('/\bAS(?!.*\bAS\b)\s+(.*)/i', $selects[$j], $matches)) { $columnName = trim($matches[1], '"'); } else { $columnName = trim(str_replace('"', '', $selects[$j])); From e651d15df594018eca7f626fb3ea39d085c5ce8a Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 25 Jun 2015 22:21:23 -0400 Subject: [PATCH 241/336] Add tests for less greedy field parsing in SQLite. Refs #6887 --- .../Model/Datasource/Database/SqliteTest.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php index 48ca6851357..4d2c3898f8c 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php @@ -560,4 +560,30 @@ public function testFetchRowColumnParsing() { $this->assertEquals($expected, $result); } + /** + * Test parsing more complex field names. + * + * @return void + */ + public function testFetchColumnRowParsingMoreComplex() + { + $this->loadFixtures('User'); + $sql = 'SELECT + COUNT(*) AS User__count, + COUNT(CASE id WHEN 2 THEN 1 ELSE NULL END) as User__case, + AVG(CAST("User"."id" AS BIGINT)) AS User__bigint + FROM "users" AS "User" + WHERE "User"."id" > 0'; + $result = $this->Dbo->fetchRow($sql); + + $expected = array( + '0' => array( + 'User__count' => '4', + 'User__case' => '1', + 'User__bigint' => '2.5', + ), + ); + $this->assertEquals($expected, $result); + } + } From 97c5463387d8063793f0533ec65c68095ca9f501 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 26 Jun 2015 22:04:00 -0400 Subject: [PATCH 242/336] Fix failing tests. FlashHelper uses `Message` not flash now. This is more backwards compatible with 2.x Refs #6874 --- lib/Cake/Test/Case/View/Helper/FlashHelperTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php b/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php index ea9221ee6ac..b3d1d744036 100644 --- a/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php @@ -55,7 +55,7 @@ public function setUp() { CakeSession::start(); } CakeSession::write(array( - 'Flash' => array( + 'Message' => array( 'flash' => array( 'key' => 'flash', 'message' => 'This is a calling', @@ -108,7 +108,6 @@ public function testFlash() { $result = $this->Flash->render('notification'); $expected = "
\n\t

Alert!

\n\t

Notice!

\n\t

Broadcast message testing

\n
"; - $this->assertContains($expected, $result); $this->assertNull($this->Flash->render('non-existent')); From c037e04ace30f07d0b691e13fcf556d4570b4b88 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 29 Jun 2015 22:35:55 -0400 Subject: [PATCH 243/336] Update version number to 2.6.8 --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index ed91c106a38..47591144808 100644 --- a/lib/Cake/VERSION.txt +++ b/lib/Cake/VERSION.txt @@ -17,4 +17,4 @@ // @license http://www.opensource.org/licenses/mit-license.php MIT License // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -2.6.7 +2.6.8 From deb62c88875d1a81ab8e8fb7214d4af93bb06c58 Mon Sep 17 00:00:00 2001 From: hiromi2424 Date: Sat, 4 Jul 2015 06:10:58 +0000 Subject: [PATCH 244/336] #6935 Fix deep saving for hasMany could not handle validation errors correctly --- lib/Cake/Model/Model.php | 6 +- lib/Cake/Test/Case/Model/ModelWriteTest.php | 122 ++++++++++++++++++++ lib/Cake/Test/Case/Model/models.php | 47 ++++++++ 3 files changed, 172 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index c46f81160f9..73c1050acc8 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -2339,7 +2339,7 @@ public function saveMany($data = null, $options = array()) { } } - $validates = ($validates && ($saved === true || (is_array($saved) && !in_array(false, $saved, true)))); + $validates = ($validates && ($saved === true || (is_array($saved) && !in_array(false, Hash::flatten($saved), true)))); if (!$validates) { $validationErrors[$key] = $this->validationErrors; } @@ -2480,7 +2480,7 @@ public function saveAssociated($data = null, $options = array()) { } else { $saved = $Model->save($values, array('atomic' => false) + $options); } - $validates = ($saved === true || (is_array($saved) && !in_array(false, $saved, true))); + $validates = ($saved === true || (is_array($saved) && !in_array(false, Hash::flatten($saved), true))); } if ($validates) { @@ -2538,7 +2538,7 @@ public function saveAssociated($data = null, $options = array()) { } } - $validates = ($validates && ($saved === true || (is_array($saved) && !in_array(false, $saved, true)))); + $validates = ($validates && ($saved === true || (is_array($saved) && !in_array(false, Hash::flatten($saved), true)))); if (!$validates) { $validationErrors[$association] = $Model->validationErrors; } diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index c0349ed4890..b63a1828c8d 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -7684,6 +7684,128 @@ public function testSaveAllDeepEmptyHasManyHasMany() { $this->assertEquals(2, count($result['Attachment'])); } +/** + * testSaveManyDeepHasManyValidationFailure method + * + * @return void + */ + public function testSaveManyDeepHasManyValidationFailure() { + $this->loadFixtures('Article', 'Comment'); + $TestModel = new Article(); + $TestModel->Comment->validate = array( + 'comment' => array( + 'notEmpty' => array( + 'rule' => array('notEmpty'), + ) + ) + ); + + $result = $TestModel->saveMany(array( + array( + 'user_id' => 1, + 'title' => 'New Article', + 'body' => 'This article contains a invalid comment', + 'Comment' => array( + array( + 'user_id' => 1, + 'comment' => '' + ) + ) + ) + ), array('deep' => true)); + $this->assertFalse($result); + $this->assertEquals(array( + array( + 'Comment' => array( + array('comment' => array('notEmpty')) + ) + ) + ), $TestModel->validationErrors); + } + +/** + * testSaveAssociatedDeepHasOneHasManyValidateTrueValidationFailure method + * + * @return void + */ + public function testSaveAssociatedDeepHasOneHasManyValidateTrueValidationFailure() { + $this->loadFixtures('User', 'Article', 'Comment'); + $TestModel = new UserHasOneArticle(); + $TestModel->Article->Comment->validate = array( + 'comment' => array( + 'notEmpty' => array( + 'rule' => array('notEmpty'), + ) + ) + ); + + $result = $TestModel->saveAssociated(array( + 'User' => array( + 'user' => 'hiromi', + 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', + ), + 'Article' => array( + 'title' => 'Article with User', + 'body' => 'This article will be saved with an user and contains a invalid comment', + 'Comment' => array( + array( + 'user_id' => 1, + 'comment' => '' + ) + ) + ) + ), array('deep' => true, 'validate' => true)); + $this->assertFalse($result); + $this->assertEquals(array( + 'Article' => array( + 'Comment' => array( + array('comment' => array('notEmpty')) + ) + ) + ), $TestModel->validationErrors); + } + +/** + * testSaveAssociatedDeepBelongsToHasManyValidateTrueValidationFailure method + * + * @return void + */ + public function testSaveAssociatedDeepBelongsToHasManyValidateTrueValidationFailure() { + $this->loadFixtures('ArticlesTag', 'Article', 'Comment'); + $TestModel = new ArticlesTagBelongsToArticle(); + $TestModel->Article->Comment->validate = array( + 'comment' => array( + 'notEmpty' => array( + 'rule' => array('notEmpty'), + ) + ) + ); + + $result = $TestModel->saveAssociated(array( + 'ArticlesTagBelongsToArticle' => array( + 'tag_id' => 1, + ), + 'Article' => array( + 'title' => 'Article with User', + 'body' => 'This article will be saved with an user and contains a invalid comment', + 'Comment' => array( + array( + 'user_id' => 1, + 'comment' => '' + ) + ) + ) + ), array('deep' => true, 'validate' => true)); + $this->assertFalse($result); + $this->assertEquals(array( + 'Article' => array( + 'Comment' => array( + array('comment' => array('notEmpty')) + ) + ) + ), $TestModel->validationErrors); + } + /** * testUpdateAllBoolean * diff --git a/lib/Cake/Test/Case/Model/models.php b/lib/Cake/Test/Case/Model/models.php index ced7a56b367..ad7781115c1 100644 --- a/lib/Cake/Test/Case/Model/models.php +++ b/lib/Cake/Test/Case/Model/models.php @@ -5079,3 +5079,50 @@ class Example extends AppModel { ); } + +/** + * UserHasOneArticle class + * + * @package Cake.Test.Case.Model + */ +class UserHasOneArticle extends AppModel { + +/** + * useTable property + * + * @var string + */ + public $useTable = 'users'; + +/** + * hasOne property + * + * @var array + */ + public $hasOne = array('Article'); + +} + + +/** + * ArticlesTagBelongsToArticle class + * + * @package Cake.Test.Case.Model + */ +class ArticlesTagBelongsToArticle extends CakeTestModel { + +/** + * useTable property + * + * @var string + */ + public $useTable = 'articles_tags'; + +/** + * belongsTo property + * + * @var array + */ + public $belongsTo = array('Article'); + +} From 4102961cb5e31f88f74fa4794ade7c6509dabc4c Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 6 Jul 2015 22:43:52 -0400 Subject: [PATCH 245/336] Add tests for #6879 I wasn't able to reproduce the issue the reporter had, but we have more robust tests now. --- lib/Cake/Test/Case/Utility/InflectorTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/Cake/Test/Case/Utility/InflectorTest.php b/lib/Cake/Test/Case/Utility/InflectorTest.php index bf7cd11c08b..13a32ffa436 100644 --- a/lib/Cake/Test/Case/Utility/InflectorTest.php +++ b/lib/Cake/Test/Case/Utility/InflectorTest.php @@ -287,6 +287,9 @@ public function testInflectingPlurals() { public function testPluralizeMultiWordIrregular() { Inflector::rules('plural', array( 'irregular' => array( + 'mytable1' => 'mytables1', + 'mytable2' => 'mytables2', + 'mytable1_mytable2' => 'mytables1_mytables2', 'pregunta_frecuente' => 'preguntas_frecuentes', 'categoria_pregunta_frecuente' => 'categorias_preguntas_frecuentes', ) @@ -300,6 +303,10 @@ public function testPluralizeMultiWordIrregular() { 'faq_categorias_preguntas_frecuentes', Inflector::pluralize('faq_categoria_pregunta_frecuente') ); + $this->assertEquals('mytables1', Inflector::pluralize('mytable1')); + $this->assertEquals('mytables2', Inflector::pluralize('mytable2')); + $this->assertEquals('mytables1_mytables2', Inflector::pluralize('mytable1_mytable2')); + $this->assertEquals('mytables1_mytables2', Inflector::tableize('Mytable1Mytable2')); } /** From 94fbc6e5f28fd09ab1ebdbcc6d1382844de13c65 Mon Sep 17 00:00:00 2001 From: Chris Kim Date: Tue, 7 Jul 2015 15:00:50 -0400 Subject: [PATCH 246/336] Don't map text/plain to csv. Backport from 3.0. Refs #1696 Jquery sets accepts header similar to "text/plain, */*; q=0.01" by default for xhr requests. Due to this RequestHandler used to set extension to csv thereby causing View class to look for views under non-existent csv folders. --- lib/Cake/Network/CakeResponse.php | 2 +- .../Component/RequestHandlerComponentTest.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index d1081400367..3c5a3c46af0 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -96,7 +96,7 @@ class CakeResponse { 'cpio' => 'application/x-cpio', 'cpt' => 'application/mac-compactpro', 'csh' => 'application/x-csh', - 'csv' => array('text/csv', 'application/vnd.ms-excel', 'text/plain'), + 'csv' => array('text/csv', 'application/vnd.ms-excel'), 'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'dms' => 'application/octet-stream', diff --git a/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php b/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php index 3f330b60aa5..aa20baeff45 100644 --- a/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php @@ -197,6 +197,20 @@ public function testInitializeContentTypeWithjQueryAccept() { $this->assertEquals('json', $this->RequestHandler->ext); } +/** + * Test that RequestHandler does not set extension to csv for text/plain mimetype + * + * @return void + */ + public function testInitializeContentTypeWithjQueryTextPlainAccept() { + $_SERVER['HTTP_ACCEPT'] = 'text/plain, */*; q=0.01'; + $this->assertNull($this->RequestHandler->ext); + Router::parseExtensions('csv'); + + $this->RequestHandler->initialize($this->Controller); + $this->assertNull($this->RequestHandler->ext); + } + /** * Test that RequestHandler sets $this->ext when jQuery sends its wonky-ish headers * and the application is configured to handle multiple extensions From 7613e720e72be138dddb3f36d1ecf91f23f7f08c Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 7 Jul 2015 22:06:47 -0400 Subject: [PATCH 247/336] Fix PHPCS errors. --- .../Case/Model/Datasource/Database/SqliteTest.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php index 4d2c3898f8c..14758c7d7ac 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php @@ -560,13 +560,12 @@ public function testFetchRowColumnParsing() { $this->assertEquals($expected, $result); } - /** - * Test parsing more complex field names. - * - * @return void - */ - public function testFetchColumnRowParsingMoreComplex() - { +/** + * Test parsing more complex field names. + * + * @return void + */ + public function testFetchColumnRowParsingMoreComplex() { $this->loadFixtures('User'); $sql = 'SELECT COUNT(*) AS User__count, From 64951a3e7e72e2071eed4d3920fbca88f7ae6dc3 Mon Sep 17 00:00:00 2001 From: Anne Date: Wed, 8 Jul 2015 11:23:29 +0200 Subject: [PATCH 248/336] Added return types in PHP documenation in basics.php, since it raises warning in ie. PHPStorm, like: - Method _toString is not implemented for translated --- lib/Cake/basics.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/Cake/basics.php b/lib/Cake/basics.php index 9ca5a93dbad..3b807094281 100644 --- a/lib/Cake/basics.php +++ b/lib/Cake/basics.php @@ -625,7 +625,7 @@ function __n($singular, $plural, $count, $args = null) { * @param string $domain Domain * @param string $msg String to translate * @param mixed $args Array with arguments or multiple arguments in function - * @return translated string + * @return string translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__d */ function __d($domain, $msg, $args = null) { @@ -652,7 +652,7 @@ function __d($domain, $msg, $args = null) { * @param string $plural Plural * @param int $count Count * @param mixed $args Array with arguments or multiple arguments in function - * @return plural form of translated string + * @return string plural form of translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dn */ function __dn($domain, $singular, $plural, $count, $args = null) { @@ -690,7 +690,7 @@ function __dn($domain, $singular, $plural, $count, $args = null) { * @param string $msg Message to translate * @param int $category Category * @param mixed $args Array with arguments or multiple arguments in function - * @return translated string + * @return string translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dc */ function __dc($domain, $msg, $category, $args = null) { @@ -732,7 +732,7 @@ function __dc($domain, $msg, $category, $args = null) { * @param int $count Count * @param int $category Category * @param mixed $args Array with arguments or multiple arguments in function - * @return plural form of translated string + * @return string plural form of translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dcn */ function __dcn($domain, $singular, $plural, $count, $category, $args = null) { @@ -766,7 +766,7 @@ function __dcn($domain, $singular, $plural, $count, $category, $args = null) { * @param string $msg String to translate * @param int $category Category * @param mixed $args Array with arguments or multiple arguments in function - * @return translated string + * @return string translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__c */ function __c($msg, $category, $args = null) { @@ -841,7 +841,7 @@ function __xn($context, $singular, $plural, $count, $args = null) { * @param string $context Context of the text * @param string $msg String to translate * @param mixed $args Array with arguments or multiple arguments in function - * @return translated string + * @return string translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__d */ function __dx($domain, $context, $msg, $args = null) { @@ -869,7 +869,7 @@ function __dx($domain, $context, $msg, $args = null) { * @param string $plural Plural * @param int $count Count * @param mixed $args Array with arguments or multiple arguments in function - * @return plural form of translated string + * @return string plural form of translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dn */ function __dxn($domain, $context, $singular, $plural, $count, $args = null) { @@ -908,7 +908,7 @@ function __dxn($domain, $context, $singular, $plural, $count, $args = null) { * @param string $msg Message to translate * @param int $category Category * @param mixed $args Array with arguments or multiple arguments in function - * @return translated string + * @return string translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dc */ function __dxc($domain, $context, $msg, $category, $args = null) { @@ -951,7 +951,7 @@ function __dxc($domain, $context, $msg, $category, $args = null) { * @param int $count Count * @param int $category Category * @param mixed $args Array with arguments or multiple arguments in function - * @return plural form of translated string + * @return string plural form of translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dcn */ function __dxcn($domain, $context, $singular, $plural, $count, $category, $args = null) { @@ -986,7 +986,7 @@ function __dxcn($domain, $context, $singular, $plural, $count, $category, $args * @param string $msg String to translate * @param int $category Category * @param mixed $args Array with arguments or multiple arguments in function - * @return translated string + * @return string translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__c */ function __xc($context, $msg, $category, $args = null) { @@ -1025,7 +1025,7 @@ function LogError($message) { * Searches include path for files. * * @param string $file File to look for - * @return Full path to file if exists, otherwise false + * @return string Full path to file if exists, otherwise false * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#fileExistsInPath */ function fileExistsInPath($file) { From b4b10e75ac1c099fc6c5e0413d912347722e7772 Mon Sep 17 00:00:00 2001 From: Anne Date: Wed, 8 Jul 2015 11:23:29 +0200 Subject: [PATCH 249/336] Added return types in PHP documenation in basics.php, since it raises warning in ie. PHPStorm, like: - Method _toString is not implemented for translated --- lib/Cake/basics.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/Cake/basics.php b/lib/Cake/basics.php index 9ca5a93dbad..3b807094281 100644 --- a/lib/Cake/basics.php +++ b/lib/Cake/basics.php @@ -625,7 +625,7 @@ function __n($singular, $plural, $count, $args = null) { * @param string $domain Domain * @param string $msg String to translate * @param mixed $args Array with arguments or multiple arguments in function - * @return translated string + * @return string translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__d */ function __d($domain, $msg, $args = null) { @@ -652,7 +652,7 @@ function __d($domain, $msg, $args = null) { * @param string $plural Plural * @param int $count Count * @param mixed $args Array with arguments or multiple arguments in function - * @return plural form of translated string + * @return string plural form of translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dn */ function __dn($domain, $singular, $plural, $count, $args = null) { @@ -690,7 +690,7 @@ function __dn($domain, $singular, $plural, $count, $args = null) { * @param string $msg Message to translate * @param int $category Category * @param mixed $args Array with arguments or multiple arguments in function - * @return translated string + * @return string translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dc */ function __dc($domain, $msg, $category, $args = null) { @@ -732,7 +732,7 @@ function __dc($domain, $msg, $category, $args = null) { * @param int $count Count * @param int $category Category * @param mixed $args Array with arguments or multiple arguments in function - * @return plural form of translated string + * @return string plural form of translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dcn */ function __dcn($domain, $singular, $plural, $count, $category, $args = null) { @@ -766,7 +766,7 @@ function __dcn($domain, $singular, $plural, $count, $category, $args = null) { * @param string $msg String to translate * @param int $category Category * @param mixed $args Array with arguments or multiple arguments in function - * @return translated string + * @return string translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__c */ function __c($msg, $category, $args = null) { @@ -841,7 +841,7 @@ function __xn($context, $singular, $plural, $count, $args = null) { * @param string $context Context of the text * @param string $msg String to translate * @param mixed $args Array with arguments or multiple arguments in function - * @return translated string + * @return string translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__d */ function __dx($domain, $context, $msg, $args = null) { @@ -869,7 +869,7 @@ function __dx($domain, $context, $msg, $args = null) { * @param string $plural Plural * @param int $count Count * @param mixed $args Array with arguments or multiple arguments in function - * @return plural form of translated string + * @return string plural form of translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dn */ function __dxn($domain, $context, $singular, $plural, $count, $args = null) { @@ -908,7 +908,7 @@ function __dxn($domain, $context, $singular, $plural, $count, $args = null) { * @param string $msg Message to translate * @param int $category Category * @param mixed $args Array with arguments or multiple arguments in function - * @return translated string + * @return string translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dc */ function __dxc($domain, $context, $msg, $category, $args = null) { @@ -951,7 +951,7 @@ function __dxc($domain, $context, $msg, $category, $args = null) { * @param int $count Count * @param int $category Category * @param mixed $args Array with arguments or multiple arguments in function - * @return plural form of translated string + * @return string plural form of translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dcn */ function __dxcn($domain, $context, $singular, $plural, $count, $category, $args = null) { @@ -986,7 +986,7 @@ function __dxcn($domain, $context, $singular, $plural, $count, $category, $args * @param string $msg String to translate * @param int $category Category * @param mixed $args Array with arguments or multiple arguments in function - * @return translated string + * @return string translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__c */ function __xc($context, $msg, $category, $args = null) { @@ -1025,7 +1025,7 @@ function LogError($message) { * Searches include path for files. * * @param string $file File to look for - * @return Full path to file if exists, otherwise false + * @return string Full path to file if exists, otherwise false * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#fileExistsInPath */ function fileExistsInPath($file) { From 4a131bdcbfd0bc04c6ec863debfdb9b54121f2c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Thu, 9 Jul 2015 15:54:03 +0200 Subject: [PATCH 250/336] Capitalize Windows, the OS --- lib/Cake/Console/Command/ServerShell.php | 2 +- lib/Cake/Console/ConsoleOutput.php | 2 +- lib/Cake/Test/Case/Console/ShellTest.php | 2 +- lib/Cake/Test/Case/Utility/CakeTimeTest.php | 4 ++-- lib/Cake/Test/Case/Utility/FolderTest.php | 2 +- lib/Cake/Utility/CakeTime.php | 6 +++--- lib/Cake/Utility/Folder.php | 4 ++-- lib/Cake/Utility/Validation.php | 2 +- lib/Cake/View/Helper/TimeHelper.php | 4 ++-- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/Cake/Console/Command/ServerShell.php b/lib/Cake/Console/Command/ServerShell.php index 9ee1cecbb5f..f29863f5d64 100644 --- a/lib/Cake/Console/Command/ServerShell.php +++ b/lib/Cake/Console/Command/ServerShell.php @@ -91,7 +91,7 @@ public function startup() { $this->_documentRoot = $this->params['document_root']; } - // for windows + // for Windows if (substr($this->_documentRoot, -1, 1) === DIRECTORY_SEPARATOR) { $this->_documentRoot = substr($this->_documentRoot, 0, strlen($this->_documentRoot) - 1); } diff --git a/lib/Cake/Console/ConsoleOutput.php b/lib/Cake/Console/ConsoleOutput.php index 4f56fb5c4f8..d1fb2b9bd7b 100644 --- a/lib/Cake/Console/ConsoleOutput.php +++ b/lib/Cake/Console/ConsoleOutput.php @@ -154,7 +154,7 @@ class ConsoleOutput { * Construct the output object. * * Checks for a pretty console environment. Ansicon allows pretty consoles - * on windows, and is supported. + * on Windows, and is supported. * * @param string $stream The identifier of the stream to write output to. */ diff --git a/lib/Cake/Test/Case/Console/ShellTest.php b/lib/Cake/Test/Case/Console/ShellTest.php index bfd8c9e4e9e..3256acff687 100644 --- a/lib/Cake/Test/Case/Console/ShellTest.php +++ b/lib/Cake/Test/Case/Console/ShellTest.php @@ -668,7 +668,7 @@ public function testCreateFileInteractive() { * @return void */ public function testCreateFileNoPermissions() { - $this->skipIf(DIRECTORY_SEPARATOR === '\\', 'Cant perform operations using permissions on windows.'); + $this->skipIf(DIRECTORY_SEPARATOR === '\\', 'Cant perform operations using permissions on Windows.'); $path = TMP . 'shell_test'; $file = $path . DS . 'no_perms'; diff --git a/lib/Cake/Test/Case/Utility/CakeTimeTest.php b/lib/Cake/Test/Case/Utility/CakeTimeTest.php index 54fcc789bd1..447af6dca09 100644 --- a/lib/Cake/Test/Case/Utility/CakeTimeTest.php +++ b/lib/Cake/Test/Case/Utility/CakeTimeTest.php @@ -1075,12 +1075,12 @@ public function testConvertSpecifiers() { } /** - * test convert %e on windows. + * test convert %e on Windows. * * @return void */ public function testConvertPercentE() { - $this->skipIf(DIRECTORY_SEPARATOR !== '\\', 'Cannot run windows tests on non-windows OS.'); + $this->skipIf(DIRECTORY_SEPARATOR !== '\\', 'Cannot run Windows tests on non-Windows OS.'); $time = strtotime('Thu Jan 14 11:43:39 2010'); $result = $this->Time->convertSpecifiers('%e', $time); diff --git a/lib/Cake/Test/Case/Utility/FolderTest.php b/lib/Cake/Test/Case/Utility/FolderTest.php index 007d363797c..7169d27d063 100644 --- a/lib/Cake/Test/Case/Utility/FolderTest.php +++ b/lib/Cake/Test/Case/Utility/FolderTest.php @@ -192,7 +192,7 @@ public function testCreateRelative() { * @return void */ public function testRecursiveCreateFailure() { - $this->skipIf(DIRECTORY_SEPARATOR === '\\', 'Cant perform operations using permissions on windows.'); + $this->skipIf(DIRECTORY_SEPARATOR === '\\', 'Cant perform operations using permissions on Windows.'); $path = TMP . 'tests' . DS . 'one'; mkdir($path); diff --git a/lib/Cake/Utility/CakeTime.php b/lib/Cake/Utility/CakeTime.php index b22082320b7..d3b8f8d67bc 100644 --- a/lib/Cake/Utility/CakeTime.php +++ b/lib/Cake/Utility/CakeTime.php @@ -123,12 +123,12 @@ public function __get($name) { /** * Converts a string representing the format for the function strftime and returns a - * windows safe and i18n aware format. + * Windows safe and i18n aware format. * * @param string $format Format with specifiers for strftime function. * Accepts the special specifier %S which mimics the modifier S for date() * @param string $time UNIX timestamp - * @return string windows safe and date() function compatible format for strftime + * @return string Windows safe and date() function compatible format for strftime * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::convertSpecifiers */ public static function convertSpecifiers($format, $time = null) { @@ -141,7 +141,7 @@ public static function convertSpecifiers($format, $time = null) { /** * Auxiliary function to translate a matched specifier element from a regular expression into - * a windows safe and i18n aware specifier + * a Windows safe and i18n aware specifier * * @param array $specifier match from regular expression * @return string converted element diff --git a/lib/Cake/Utility/Folder.php b/lib/Cake/Utility/Folder.php index 088723cb2e8..fe4b943d2d5 100644 --- a/lib/Cake/Utility/Folder.php +++ b/lib/Cake/Utility/Folder.php @@ -64,7 +64,7 @@ class Folder { public $sort = false; /** - * Mode to be used on create. Does nothing on windows platforms. + * Mode to be used on create. Does nothing on Windows platforms. * * @var int * http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::$mode @@ -263,7 +263,7 @@ protected function _findRecursive($pattern, $sort = false) { * Returns true if given $path is a Windows path. * * @param string $path Path to check - * @return bool true if windows path, false otherwise + * @return bool true if Windows path, false otherwise * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::isWindowsPath */ public static function isWindowsPath($path) { diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index d5e0e459469..f6dad2bb0f3 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -455,7 +455,7 @@ public static function decimal($check, $places = null, $regex = null) { * Validates for an email address. * * Only uses getmxrr() checking for deep validation if PHP 5.3.0+ is used, or - * any PHP version on a non-windows distribution + * any PHP version on a non-Windows distribution * * @param string $check Value to check * @param bool $deep Perform a deeper validation (if true), by also checking availability of host diff --git a/lib/Cake/View/Helper/TimeHelper.php b/lib/Cake/View/Helper/TimeHelper.php index 5e91705bd93..2a191a4a4a8 100644 --- a/lib/Cake/View/Helper/TimeHelper.php +++ b/lib/Cake/View/Helper/TimeHelper.php @@ -126,12 +126,12 @@ public function __call($method, $params) { /** * Converts a string representing the format for the function strftime and returns a - * windows safe and i18n aware format. + * Windows safe and i18n aware format. * * @param string $format Format with specifiers for strftime function. * Accepts the special specifier %S which mimics the modifier S for date() * @param string $time UNIX timestamp - * @return string windows safe and date() function compatible format for strftime + * @return string Windows safe and date() function compatible format for strftime * @see CakeTime::convertSpecifiers() * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting */ From 65c1745349bd9136522af41482f266aa12827a58 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 10 Jul 2015 12:56:49 -0400 Subject: [PATCH 251/336] Add missing parameter to rawQuery() Previously bound parameters were put in the incorrect position. Refs #6992 --- lib/Cake/Model/Datasource/DboSource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 2e8e6574c74..bc41c525e76 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -402,7 +402,7 @@ public function expression($expression) { */ public function rawQuery($sql, $params = array()) { $this->took = $this->numRows = false; - return $this->execute($sql, $params); + return $this->execute($sql, array(), $params); } /** From e07b64f4e3257c4247a0ad269d349c4e0b797e1a Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 11 Jul 2015 21:34:20 -0400 Subject: [PATCH 252/336] Update version number to 2.7.0 --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index 0f4327170da..907ad6287e1 100644 --- a/lib/Cake/VERSION.txt +++ b/lib/Cake/VERSION.txt @@ -17,4 +17,4 @@ // @license http://www.opensource.org/licenses/mit-license.php MIT License // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -2.7.0-RC +2.7.0 From 2eea245491a64f14874990189470bebde0b399e0 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Mon, 13 Jul 2015 08:23:05 +0200 Subject: [PATCH 253/336] Backport utf fix for CakeText::tokenize(). --- lib/Cake/Test/Case/Utility/CakeTextTest.php | 5 +++++ lib/Cake/Utility/CakeText.php | 23 +++++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/CakeTextTest.php b/lib/Cake/Test/Case/Utility/CakeTextTest.php index e130e2832ff..7eface6e9e2 100644 --- a/lib/Cake/Test/Case/Utility/CakeTextTest.php +++ b/lib/Cake/Test/Case/Utility/CakeTextTest.php @@ -304,6 +304,11 @@ public function testTokenize() { $expected = array('tagA', '"single tag"', 'tagB'); $this->assertEquals($expected, $result); + // Ideographic width space. + $result = CakeText::tokenize("tagA\xe3\x80\x80\"single\xe3\x80\x80tag\"\xe3\x80\x80tagB", "\xe3\x80\x80", '"', '"'); + $expected = array('tagA', '"single tag"', 'tagB'); + $this->assertEquals($expected, $result); + $result = CakeText::tokenize(''); $expected = array(); $this->assertEquals($expected, $result); diff --git a/lib/Cake/Utility/CakeText.php b/lib/Cake/Utility/CakeText.php index 11e2e488502..1e72c913eb3 100644 --- a/lib/Cake/Utility/CakeText.php +++ b/lib/Cake/Utility/CakeText.php @@ -115,15 +115,15 @@ public static function tokenize($data, $separator = ',', $leftBound = '(', $righ $offset = 0; $buffer = ''; $results = array(); - $length = strlen($data); + $length = mb_strlen($data); $open = false; while ($offset <= $length) { $tmpOffset = -1; $offsets = array( - strpos($data, $separator, $offset), - strpos($data, $leftBound, $offset), - strpos($data, $rightBound, $offset) + mb_strpos($data, $separator, $offset), + mb_strpos($data, $leftBound, $offset), + mb_strpos($data, $rightBound, $offset) ); for ($i = 0; $i < 3; $i++) { if ($offsets[$i] !== false && ($offsets[$i] < $tmpOffset || $tmpOffset == -1)) { @@ -131,22 +131,23 @@ public static function tokenize($data, $separator = ',', $leftBound = '(', $righ } } if ($tmpOffset !== -1) { - $buffer .= substr($data, $offset, ($tmpOffset - $offset)); - if (!$depth && $data{$tmpOffset} === $separator) { + $buffer .= mb_substr($data, $offset, ($tmpOffset - $offset)); + $char = mb_substr($data, $tmpOffset, 1); + if (!$depth && $char === $separator) { $results[] = $buffer; $buffer = ''; } else { - $buffer .= $data{$tmpOffset}; + $buffer .= $char; } if ($leftBound !== $rightBound) { - if ($data{$tmpOffset} === $leftBound) { + if ($char === $leftBound) { $depth++; } - if ($data{$tmpOffset} === $rightBound) { + if ($char === $rightBound) { $depth--; } } else { - if ($data{$tmpOffset} === $leftBound) { + if ($char === $leftBound) { if (!$open) { $depth++; $open = true; @@ -157,7 +158,7 @@ public static function tokenize($data, $separator = ',', $leftBound = '(', $righ } $offset = ++$tmpOffset; } else { - $results[] = $buffer . substr($data, $offset); + $results[] = $buffer . mb_substr($data, $offset); $offset = $length + 1; } } From d98e7d8d27ac7ab6182f76f5d547ed310dc8de67 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Mon, 13 Jul 2015 08:37:11 +0200 Subject: [PATCH 254/336] Fix tests. --- lib/Cake/Test/Case/Model/ModelWriteTest.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index 77a137bfe23..62818f6f5fc 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -7694,8 +7694,8 @@ public function testSaveManyDeepHasManyValidationFailure() { $TestModel = new Article(); $TestModel->Comment->validate = array( 'comment' => array( - 'notEmpty' => array( - 'rule' => array('notEmpty'), + 'notBlank' => array( + 'rule' => array('notBlank'), ) ) ); @@ -7717,7 +7717,7 @@ public function testSaveManyDeepHasManyValidationFailure() { $this->assertEquals(array( array( 'Comment' => array( - array('comment' => array('notEmpty')) + array('comment' => array('notBlank')) ) ) ), $TestModel->validationErrors); @@ -7733,8 +7733,8 @@ public function testSaveAssociatedDeepHasOneHasManyValidateTrueValidationFailure $TestModel = new UserHasOneArticle(); $TestModel->Article->Comment->validate = array( 'comment' => array( - 'notEmpty' => array( - 'rule' => array('notEmpty'), + 'notBlank' => array( + 'rule' => array('notBlank'), ) ) ); @@ -7759,7 +7759,7 @@ public function testSaveAssociatedDeepHasOneHasManyValidateTrueValidationFailure $this->assertEquals(array( 'Article' => array( 'Comment' => array( - array('comment' => array('notEmpty')) + array('comment' => array('notBlank')) ) ) ), $TestModel->validationErrors); @@ -7775,8 +7775,8 @@ public function testSaveAssociatedDeepBelongsToHasManyValidateTrueValidationFail $TestModel = new ArticlesTagBelongsToArticle(); $TestModel->Article->Comment->validate = array( 'comment' => array( - 'notEmpty' => array( - 'rule' => array('notEmpty'), + 'notBlank' => array( + 'rule' => array('notBlank'), ) ) ); @@ -7800,7 +7800,7 @@ public function testSaveAssociatedDeepBelongsToHasManyValidateTrueValidationFail $this->assertEquals(array( 'Article' => array( 'Comment' => array( - array('comment' => array('notEmpty')) + array('comment' => array('notBlank')) ) ) ), $TestModel->validationErrors); From 8717352f15c6c183f1fde9bd25dfd25b8a6fb810 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 15 Jul 2015 21:22:16 -0400 Subject: [PATCH 255/336] Update version number to 2.6.9 --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index 47591144808..62f2905372b 100644 --- a/lib/Cake/VERSION.txt +++ b/lib/Cake/VERSION.txt @@ -17,4 +17,4 @@ // @license http://www.opensource.org/licenses/mit-license.php MIT License // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -2.6.8 +2.6.9 From 1922a18d077afe851737ec2cc0ee94d774d75879 Mon Sep 17 00:00:00 2001 From: adam1010 Date: Wed, 15 Jul 2015 19:32:58 -0500 Subject: [PATCH 256/336] Ajax requests not properly returning 403 When an AJAX request is made to a page that's not authorized, an infinite redirect loop to /status:403/exit:1 is triggered. This bug has existed at least since CakePHP v2.3.0. The main use case is when a user's session has expired and they try to use an authenticated feature as a logged-out user. --- lib/Cake/Controller/Component/AuthComponent.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index 88a8d60b169..082f900d2e9 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -373,7 +373,9 @@ protected function _unauthenticated(Controller $controller) { $this->_stop(); return false; } - $controller->redirect(null, 403); + $controller->response->statusCode(403); + $controller->response->send(); + $this->_stop(); return false; } From 9b313f86e43b9951b93b2344d54e169a49c1eef6 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 16 Jul 2015 23:00:20 -0400 Subject: [PATCH 257/336] Add tests for #7034 These tests ensure that redirect() is never called which ensures the Location header is never set. Ajax requests when no loginElement is defined should get an empty response with a 403 status code. --- .../Component/AuthComponentTest.php | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php index 27e20abfb4f..233116f3074 100644 --- a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php @@ -1282,14 +1282,47 @@ public function testAjaxLoginResponseCode() { $this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader')); $this->Controller->response->expects($this->at(0)) - ->method('_sendHeader') - ->with('HTTP/1.1 403 Forbidden', null); + ->method('_sendHeader') + ->with('HTTP/1.1 403 Forbidden', null); $this->Auth->initialize($this->Controller); + ob_start(); $result = $this->Auth->startup($this->Controller); + ob_end_clean(); $this->assertFalse($result); $this->assertEquals('this is the test element', $this->Controller->response->body()); + $this->assertArrayNotHasKey('Location', $this->Controller->response->header()); + $this->assertNull($this->Controller->testUrl, 'redirect() not called'); + unset($_SERVER['HTTP_X_REQUESTED_WITH']); + } + +/** + * test ajax login with no element + * + * @return void + */ + public function testAjaxLoginResponseCodeNoElement() { + $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; + + $url = '/ajax_auth/add'; + $this->Auth->request->addParams(Router::parse($url)); + $this->Auth->request->query['url'] = ltrim($url, '/'); + $this->Auth->request->base = ''; + $this->Auth->ajaxLogin = false; + + Router::setRequestInfo($this->Auth->request); + + $this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader')); + $this->Controller->response->expects($this->at(0)) + ->method('_sendHeader') + ->with('HTTP/1.1 403 Forbidden', null); + $this->Auth->initialize($this->Controller); + + $result = $this->Auth->startup($this->Controller); + + $this->assertArrayNotHasKey('Location', $this->Controller->response->header()); + $this->assertNull($this->Controller->testUrl, 'redirect() not called'); unset($_SERVER['HTTP_X_REQUESTED_WITH']); } From 4af2e5489bca022d63fb1c56a50ed6a1f02aa459 Mon Sep 17 00:00:00 2001 From: David Yell Date: Thu, 16 Jul 2015 11:37:41 +0100 Subject: [PATCH 258/336] Update deprecated method in docblocks So that the docblock doesn't point you to another deprecated method which then points you to the actual method. --- lib/Cake/Controller/Component/SecurityComponent.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Controller/Component/SecurityComponent.php b/lib/Cake/Controller/Component/SecurityComponent.php index cb41cf7ff41..12f225ff366 100644 --- a/lib/Cake/Controller/Component/SecurityComponent.php +++ b/lib/Cake/Controller/Component/SecurityComponent.php @@ -47,7 +47,7 @@ class SecurityComponent extends Component { * List of controller actions for which a POST request is required * * @var array - * @deprecated 3.0.0 Use CakeRequest::onlyAllow() instead. + * @deprecated 3.0.0 Use CakeRequest::allowMethod() instead. * @see SecurityComponent::requirePost() */ public $requirePost = array(); @@ -56,7 +56,7 @@ class SecurityComponent extends Component { * List of controller actions for which a GET request is required * * @var array - * @deprecated 3.0.0 Use CakeRequest::onlyAllow() instead. + * @deprecated 3.0.0 Use CakeRequest::allowMethod() instead. * @see SecurityComponent::requireGet() */ public $requireGet = array(); @@ -65,7 +65,7 @@ class SecurityComponent extends Component { * List of controller actions for which a PUT request is required * * @var array - * @deprecated 3.0.0 Use CakeRequest::onlyAllow() instead. + * @deprecated 3.0.0 Use CakeRequest::allowMethod() instead. * @see SecurityComponent::requirePut() */ public $requirePut = array(); @@ -74,7 +74,7 @@ class SecurityComponent extends Component { * List of controller actions for which a DELETE request is required * * @var array - * @deprecated 3.0.0 Use CakeRequest::onlyAllow() instead. + * @deprecated 3.0.0 Use CakeRequest::allowMethod() instead. * @see SecurityComponent::requireDelete() */ public $requireDelete = array(); From 7b2d7ad7481065b59cfecba6cde39ee4d89e616e Mon Sep 17 00:00:00 2001 From: Chris Valliere Date: Thu, 16 Jul 2015 09:36:46 -0400 Subject: [PATCH 259/336] Test Case for Hash::maxDimensions Added test case for Hash::maxDimensions using the example array in pull request #7040. --- lib/Cake/Test/Case/Utility/HashTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index 419a7f71ae1..ba736b474ec 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -303,6 +303,12 @@ public function testMaxDimensions() { $data = array('1' => array('1.1' => '1.1.1'), '2', '3' => array('3.1' => array('3.1.1' => '3.1.1.1'))); $result = Hash::maxDimensions($data); $this->assertEquals($result, 3); + + $data = array('1' => array('1.1' => '1.1.1', '1.2' => array('1.2.1' => '1.2.1.1')),'2' => array( + '2.1' => '2.1.1',) + ); + $result = Hash::maxDimensions($data); + $this->assertEquals($result, 3); $data = array( '1' => array('1.1' => '1.1.1'), From 64f0ca002888ffbf5922830ce981d7ff447b2151 Mon Sep 17 00:00:00 2001 From: Chris Valliere Date: Thu, 16 Jul 2015 08:50:32 -0400 Subject: [PATCH 260/336] Fix Hash::maxDimensions The current Hash::maxDimensions function calls Hash::dimensions to try to get the maximum depth of the passed in array. However, this ends up only getting the depth of the first element of each 1st dimension element in the array passed to maxDimensions. The function needs to be called recursively in order to get the depth of ALL of the elements in all of the dimensions of the passed in array. I made the maxDimensions function more closely resemble the deprecated Set::countDim function in order to restore the correct functionality. --- lib/Cake/Utility/Hash.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index 142c72b0a26..e4b80f1a125 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -756,18 +756,15 @@ public static function dimensions(array $data) { * number of dimensions in a mixed array. * * @param array $data Array to count dimensions on + * @param int $count counts current depth of this iteration * @return int The maximum number of dimensions in $data * @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::maxDimensions */ - public static function maxDimensions(array $data) { - $depth = array(); + public static function maxDimensions($data, $count = 0) { + $depth = array($count); if (is_array($data) && reset($data) !== false) { foreach ($data as $value) { - if (is_array($value)) { - $depth[] = self::dimensions($value) + 1; - } else { - $depth[] = 1; - } + $depth[] = static::maxDimensions($value, $count + 1 ); } } return empty($depth) ? 0 : max($depth); From bd23fdeebf845f229231a354970fc596aba5495c Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 20 Jul 2015 22:16:50 -0400 Subject: [PATCH 261/336] Simplify code and reduce test redundancy. We don't need the additional parameter, and some of the tests weren't covering unique scenarios. Refs #7040 --- lib/Cake/Test/Case/Utility/HashTest.php | 43 +++++++------------------ lib/Cake/Utility/Hash.php | 6 ++-- 2 files changed, 15 insertions(+), 34 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index ba736b474ec..7976929d3c2 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -300,44 +300,25 @@ public function testMaxDimensions() { $result = Hash::maxDimensions($data); $this->assertEquals($result, 2); - $data = array('1' => array('1.1' => '1.1.1'), '2', '3' => array('3.1' => array('3.1.1' => '3.1.1.1'))); - $result = Hash::maxDimensions($data); - $this->assertEquals($result, 3); - - $data = array('1' => array('1.1' => '1.1.1', '1.2' => array('1.2.1' => '1.2.1.1')),'2' => array( - '2.1' => '2.1.1',) - ); - $result = Hash::maxDimensions($data); - $this->assertEquals($result, 3); - $data = array( '1' => array('1.1' => '1.1.1'), - array('2' => array('2.1' => array('2.1.1' => '2.1.1.1'))), + '2', '3' => array('3.1' => array('3.1.1' => '3.1.1.1')) ); $result = Hash::maxDimensions($data); - $this->assertEquals($result, 4); - - $data = array( - '1' => array('1.1' => '1.1.1'), - array('2' => array('2.1' => array('2.1.1' => array('2.1.1.1')))), - '3' => array('3.1' => array('3.1.1' => '3.1.1.1')) - ); - $result = Hash::maxDimensions($data); - $this->assertEquals($result, 5); - - $data = array( - '1' => array('1.1' => '1.1.1'), - array('2' => array('2.1' => array('2.1.1' => array('2.1.1.1' => '2.1.1.1.1')))), - '3' => array('3.1' => array('3.1.1' => '3.1.1.1')) - ); - $result = Hash::maxDimensions($data); - $this->assertEquals($result, 5); + $this->assertEquals($result, 3); $data = array( - '1' => array('1.1' => '1.1.1'), - array('2' => array('2.1' => array('2.1.1' => array('2.1.1.1' => '2.1.1.1.1')))), - '3' => array('3.1' => array('3.1.1' => '3.1.1.1')) + '1' => array( + '1.1' => '1.1.1', + '1.2' => array( + '1.2.1' => array( + '1.2.1.1', + array('1.2.2.1') + ) + ) + ), + '2' => array('2.1' => '2.1.1',) ); $result = Hash::maxDimensions($data); $this->assertEquals($result, 5); diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index e4b80f1a125..6f5b32abc54 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -760,11 +760,11 @@ public static function dimensions(array $data) { * @return int The maximum number of dimensions in $data * @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::maxDimensions */ - public static function maxDimensions($data, $count = 0) { - $depth = array($count); + public static function maxDimensions($data) { + $depth = array(); if (is_array($data) && reset($data) !== false) { foreach ($data as $value) { - $depth[] = static::maxDimensions($value, $count + 1 ); + $depth[] = static::maxDimensions($value) + 1; } } return empty($depth) ? 0 : max($depth); From 52e79987a28c852753d590fa98d3adb858ee4f69 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Tue, 21 Jul 2015 10:22:53 +0200 Subject: [PATCH 262/336] Replacing self with static due to PHP5.3+. Following #7040. --- lib/Cake/Cache/Cache.php | 142 ++++++------- lib/Cake/Console/Command/ServerShell.php | 6 +- lib/Cake/Console/ConsoleErrorHandler.php | 10 +- lib/Cake/Console/ConsoleOutput.php | 30 +-- lib/Cake/Controller/Component/Acl/PhpAcl.php | 6 +- .../Controller/Component/AuthComponent.php | 14 +- lib/Cake/Core/App.php | 132 ++++++------ lib/Cake/Core/CakePlugin.php | 46 ++--- lib/Cake/Core/Configure.php | 74 +++---- lib/Cake/Error/ErrorHandler.php | 14 +- lib/Cake/Event/CakeEventManager.php | 14 +- lib/Cake/I18n/I18n.php | 12 +- lib/Cake/I18n/Multibyte.php | 26 +-- lib/Cake/Log/CakeLog.php | 104 +++++----- lib/Cake/Model/ConnectionManager.php | 74 +++---- lib/Cake/Model/Datasource/CakeSession.php | 188 +++++++++--------- .../Model/Datasource/Database/Sqlserver.php | 4 +- lib/Cake/Model/Datasource/DboSource.php | 12 +- lib/Cake/Network/CakeRequest.php | 2 +- lib/Cake/Network/Email/CakeEmail.php | 8 +- lib/Cake/Network/Http/BasicAuthentication.php | 4 +- .../Network/Http/DigestAuthentication.php | 4 +- lib/Cake/Routing/Router.php | 188 +++++++++--------- .../Auth/BlowfishAuthenticateTest.php | 2 +- .../Component/Auth/FormAuthenticateTest.php | 2 +- .../Component/AuthComponentTest.php | 2 +- .../Component/EmailComponentTest.php | 14 +- .../Component/SessionComponentTest.php | 4 +- .../Test/Case/Log/Engine/ConsoleLogTest.php | 2 +- .../Case/Model/Datasource/CakeSessionTest.php | 8 +- .../Datasource/Session/CacheSessionTest.php | 4 +- .../Session/DatabaseSessionTest.php | 4 +- .../Test/Case/Model/ModelIntegrationTest.php | 2 +- lib/Cake/Test/Case/Model/ModelWriteTest.php | 150 +++++++------- lib/Cake/Test/Case/Utility/FolderTest.php | 4 +- lib/Cake/Test/Case/Utility/HashTest.php | 36 ++-- lib/Cake/Test/Case/Utility/InflectorTest.php | 2 +- lib/Cake/TestSuite/CakeTestCase.php | 18 +- lib/Cake/TestSuite/CakeTestLoader.php | 4 +- lib/Cake/TestSuite/CakeTestRunner.php | 2 +- .../TestSuite/CakeTestSuiteDispatcher.php | 4 +- lib/Cake/Utility/CakeNumber.php | 40 ++-- lib/Cake/Utility/CakeText.php | 6 +- lib/Cake/Utility/CakeTime.php | 150 +++++++------- lib/Cake/Utility/Debugger.php | 26 +-- lib/Cake/Utility/Folder.php | 6 +- lib/Cake/Utility/Hash.php | 76 +++---- lib/Cake/Utility/Inflector.php | 144 +++++++------- lib/Cake/Utility/Security.php | 16 +- lib/Cake/Utility/Validation.php | 110 +++++----- lib/Cake/Utility/Xml.php | 20 +- lib/Cake/View/Helper/FormHelper.php | 12 +- lib/Cake/View/View.php | 12 +- 53 files changed, 998 insertions(+), 998 deletions(-) diff --git a/lib/Cake/Cache/Cache.php b/lib/Cake/Cache/Cache.php index cc8be6fce9a..fb7e45de662 100644 --- a/lib/Cake/Cache/Cache.php +++ b/lib/Cake/Cache/Cache.php @@ -125,33 +125,33 @@ public static function config($name = null, $settings = array()) { } $current = array(); - if (isset(self::$_config[$name])) { - $current = self::$_config[$name]; + if (isset(static::$_config[$name])) { + $current = static::$_config[$name]; } if (!empty($settings)) { - self::$_config[$name] = $settings + $current; + static::$_config[$name] = $settings + $current; } - if (empty(self::$_config[$name]['engine'])) { + if (empty(static::$_config[$name]['engine'])) { return false; } - if (!empty(self::$_config[$name]['groups'])) { - foreach (self::$_config[$name]['groups'] as $group) { - self::$_groups[$group][] = $name; - sort(self::$_groups[$group]); - self::$_groups[$group] = array_unique(self::$_groups[$group]); + if (!empty(static::$_config[$name]['groups'])) { + foreach (static::$_config[$name]['groups'] as $group) { + static::$_groups[$group][] = $name; + sort(static::$_groups[$group]); + static::$_groups[$group] = array_unique(static::$_groups[$group]); } } - $engine = self::$_config[$name]['engine']; + $engine = static::$_config[$name]['engine']; - if (!isset(self::$_engines[$name])) { - self::_buildEngine($name); - $settings = self::$_config[$name] = self::settings($name); - } elseif ($settings = self::set(self::$_config[$name], null, $name)) { - self::$_config[$name] = $settings; + if (!isset(static::$_engines[$name])) { + static::_buildEngine($name); + $settings = static::$_config[$name] = static::settings($name); + } elseif ($settings = static::set(static::$_config[$name], null, $name)) { + static::$_config[$name] = $settings; } return compact('engine', 'settings'); } @@ -164,7 +164,7 @@ public static function config($name = null, $settings = array()) { * @throws CacheException */ protected static function _buildEngine($name) { - $config = self::$_config[$name]; + $config = static::$_config[$name]; list($plugin, $class) = pluginSplit($config['engine'], true); $cacheClass = $class . 'Engine'; @@ -176,8 +176,8 @@ protected static function _buildEngine($name) { if (!is_subclass_of($cacheClass, 'CacheEngine')) { throw new CacheException(__d('cake_dev', 'Cache engines must use %s as a base class.', 'CacheEngine')); } - self::$_engines[$name] = new $cacheClass(); - if (!self::$_engines[$name]->init($config)) { + static::$_engines[$name] = new $cacheClass(); + if (!static::$_engines[$name]->init($config)) { $msg = __d( 'cake_dev', 'Cache engine "%s" is not properly configured. Ensure required extensions are installed, and credentials/permissions are correct', @@ -185,8 +185,8 @@ protected static function _buildEngine($name) { ); throw new CacheException($msg); } - if (self::$_engines[$name]->settings['probability'] && time() % self::$_engines[$name]->settings['probability'] === 0) { - self::$_engines[$name]->gc(); + if (static::$_engines[$name]->settings['probability'] && time() % static::$_engines[$name]->settings['probability'] === 0) { + static::$_engines[$name]->gc(); } return true; } @@ -197,7 +197,7 @@ protected static function _buildEngine($name) { * @return array Array of configured Cache config names. */ public static function configured() { - return array_keys(self::$_config); + return array_keys(static::$_config); } /** @@ -209,10 +209,10 @@ public static function configured() { * @return bool success of the removal, returns false when the config does not exist. */ public static function drop($name) { - if (!isset(self::$_config[$name])) { + if (!isset(static::$_config[$name])) { return false; } - unset(self::$_config[$name], self::$_engines[$name]); + unset(static::$_config[$name], static::$_engines[$name]); return true; } @@ -243,29 +243,29 @@ public static function set($settings = array(), $value = null, $config = 'defaul if (is_array($settings) && $value !== null) { $config = $value; } - if (!isset(self::$_config[$config]) || !isset(self::$_engines[$config])) { + if (!isset(static::$_config[$config]) || !isset(static::$_engines[$config])) { return false; } if (!empty($settings)) { - self::$_reset = true; + static::$_reset = true; } - if (self::$_reset === true) { + if (static::$_reset === true) { if (empty($settings)) { - self::$_reset = false; - $settings = self::$_config[$config]; + static::$_reset = false; + $settings = static::$_config[$config]; } else { if (is_string($settings) && $value !== null) { $settings = array($settings => $value); } - $settings += self::$_config[$config]; + $settings += static::$_config[$config]; if (isset($settings['duration']) && !is_numeric($settings['duration'])) { $settings['duration'] = strtotime($settings['duration']) - time(); } } - self::$_engines[$config]->settings = $settings; + static::$_engines[$config]->settings = $settings; } - return self::settings($config); + return static::settings($config); } /** @@ -278,7 +278,7 @@ public static function set($settings = array(), $value = null, $config = 'defaul * @return void */ public static function gc($config = 'default', $expires = null) { - self::$_engines[$config]->gc($expires); + static::$_engines[$config]->gc($expires); } /** @@ -300,29 +300,29 @@ public static function gc($config = 'default', $expires = null) { * @return bool True if the data was successfully cached, false on failure */ public static function write($key, $value, $config = 'default') { - $settings = self::settings($config); + $settings = static::settings($config); if (empty($settings)) { return false; } - if (!self::isInitialized($config)) { + if (!static::isInitialized($config)) { return false; } - $key = self::$_engines[$config]->key($key); + $key = static::$_engines[$config]->key($key); if (!$key || is_resource($value)) { return false; } - $success = self::$_engines[$config]->write($settings['prefix'] . $key, $value, $settings['duration']); - self::set(null, $config); + $success = static::$_engines[$config]->write($settings['prefix'] . $key, $value, $settings['duration']); + static::set(null, $config); if ($success === false && $value !== '') { trigger_error( __d('cake_dev', "%s cache was unable to write '%s' to %s cache", $config, $key, - self::$_engines[$config]->settings['engine'] + static::$_engines[$config]->settings['engine'] ), E_USER_WARNING ); @@ -348,19 +348,19 @@ public static function write($key, $value, $config = 'default') { * @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it */ public static function read($key, $config = 'default') { - $settings = self::settings($config); + $settings = static::settings($config); if (empty($settings)) { return false; } - if (!self::isInitialized($config)) { + if (!static::isInitialized($config)) { return false; } - $key = self::$_engines[$config]->key($key); + $key = static::$_engines[$config]->key($key); if (!$key) { return false; } - return self::$_engines[$config]->read($settings['prefix'] . $key); + return static::$_engines[$config]->read($settings['prefix'] . $key); } /** @@ -373,21 +373,21 @@ public static function read($key, $config = 'default') { * or if there was an error fetching it. */ public static function increment($key, $offset = 1, $config = 'default') { - $settings = self::settings($config); + $settings = static::settings($config); if (empty($settings)) { return false; } - if (!self::isInitialized($config)) { + if (!static::isInitialized($config)) { return false; } - $key = self::$_engines[$config]->key($key); + $key = static::$_engines[$config]->key($key); if (!$key || !is_int($offset) || $offset < 0) { return false; } - $success = self::$_engines[$config]->increment($settings['prefix'] . $key, $offset); - self::set(null, $config); + $success = static::$_engines[$config]->increment($settings['prefix'] . $key, $offset); + static::set(null, $config); return $success; } @@ -401,21 +401,21 @@ public static function increment($key, $offset = 1, $config = 'default') { * or if there was an error fetching it */ public static function decrement($key, $offset = 1, $config = 'default') { - $settings = self::settings($config); + $settings = static::settings($config); if (empty($settings)) { return false; } - if (!self::isInitialized($config)) { + if (!static::isInitialized($config)) { return false; } - $key = self::$_engines[$config]->key($key); + $key = static::$_engines[$config]->key($key); if (!$key || !is_int($offset) || $offset < 0) { return false; } - $success = self::$_engines[$config]->decrement($settings['prefix'] . $key, $offset); - self::set(null, $config); + $success = static::$_engines[$config]->decrement($settings['prefix'] . $key, $offset); + static::set(null, $config); return $success; } @@ -437,21 +437,21 @@ public static function decrement($key, $offset = 1, $config = 'default') { * @return bool True if the value was successfully deleted, false if it didn't exist or couldn't be removed */ public static function delete($key, $config = 'default') { - $settings = self::settings($config); + $settings = static::settings($config); if (empty($settings)) { return false; } - if (!self::isInitialized($config)) { + if (!static::isInitialized($config)) { return false; } - $key = self::$_engines[$config]->key($key); + $key = static::$_engines[$config]->key($key); if (!$key) { return false; } - $success = self::$_engines[$config]->delete($settings['prefix'] . $key); - self::set(null, $config); + $success = static::$_engines[$config]->delete($settings['prefix'] . $key); + static::set(null, $config); return $success; } @@ -463,11 +463,11 @@ public static function delete($key, $config = 'default') { * @return bool True if the cache was successfully cleared, false otherwise */ public static function clear($check = false, $config = 'default') { - if (!self::isInitialized($config)) { + if (!static::isInitialized($config)) { return false; } - $success = self::$_engines[$config]->clear($check); - self::set(null, $config); + $success = static::$_engines[$config]->clear($check); + static::set(null, $config); return $success; } @@ -479,11 +479,11 @@ public static function clear($check = false, $config = 'default') { * @return bool True if the cache group was successfully cleared, false otherwise */ public static function clearGroup($group, $config = 'default') { - if (!self::isInitialized($config)) { + if (!static::isInitialized($config)) { return false; } - $success = self::$_engines[$config]->clearGroup($group); - self::set(null, $config); + $success = static::$_engines[$config]->clearGroup($group); + static::set(null, $config); return $success; } @@ -497,7 +497,7 @@ public static function isInitialized($config = 'default') { if (Configure::read('Cache.disable')) { return false; } - return isset(self::$_engines[$config]); + return isset(static::$_engines[$config]); } /** @@ -508,8 +508,8 @@ public static function isInitialized($config = 'default') { * @see Cache::config() */ public static function settings($name = 'default') { - if (!empty(self::$_engines[$name])) { - return self::$_engines[$name]->settings(); + if (!empty(static::$_engines[$name])) { + return static::$_engines[$name]->settings(); } return array(); } @@ -535,10 +535,10 @@ public static function settings($name = 'default') { */ public static function groupConfigs($group = null) { if ($group === null) { - return self::$_groups; + return static::$_groups; } - if (isset(self::$_groups[$group])) { - return array($group => self::$_groups[$group]); + if (isset(static::$_groups[$group])) { + return array($group => static::$_groups[$group]); } throw new CacheException(__d('cake_dev', 'Invalid cache group %s', $group)); } @@ -569,12 +569,12 @@ public static function groupConfigs($group = null) { * @return mixed The results of the callable or unserialized results. */ public static function remember($key, $callable, $config = 'default') { - $existing = self::read($key, $config); + $existing = static::read($key, $config); if ($existing !== false) { return $existing; } $results = call_user_func($callable); - self::write($key, $results, $config); + static::write($key, $results, $config); return $results; } diff --git a/lib/Cake/Console/Command/ServerShell.php b/lib/Cake/Console/Command/ServerShell.php index f29863f5d64..8c7d5e5e365 100644 --- a/lib/Cake/Console/Command/ServerShell.php +++ b/lib/Cake/Console/Command/ServerShell.php @@ -65,8 +65,8 @@ class ServerShell extends AppShell { * @return void */ public function initialize() { - $this->_host = self::DEFAULT_HOST; - $this->_port = self::DEFAULT_PORT; + $this->_host = static::DEFAULT_HOST; + $this->_port = static::DEFAULT_PORT; $this->_documentRoot = WWW_ROOT; } @@ -135,7 +135,7 @@ public function main() { escapeshellarg($this->_documentRoot . '/index.php') ); - $port = ($this->_port == self::DEFAULT_PORT) ? '' : ':' . $this->_port; + $port = ($this->_port == static::DEFAULT_PORT) ? '' : ':' . $this->_port; $this->out(__d('cake_console', 'built-in server is running in http://%s%s/', $this->_host, $port)); system($command); } diff --git a/lib/Cake/Console/ConsoleErrorHandler.php b/lib/Cake/Console/ConsoleErrorHandler.php index d7182e2c047..a488b10f941 100644 --- a/lib/Cake/Console/ConsoleErrorHandler.php +++ b/lib/Cake/Console/ConsoleErrorHandler.php @@ -40,10 +40,10 @@ class ConsoleErrorHandler { * @return ConsoleOutput */ public static function getStderr() { - if (empty(self::$stderr)) { - self::$stderr = new ConsoleOutput('php://stderr'); + if (empty(static::$stderr)) { + static::$stderr = new ConsoleOutput('php://stderr'); } - return self::$stderr; + return static::$stderr; } /** @@ -53,7 +53,7 @@ public static function getStderr() { * @return void */ public function handleException(Exception $exception) { - $stderr = self::getStderr(); + $stderr = static::getStderr(); $stderr->write(__d('cake_console', "Error: %s\n%s", $exception->getMessage(), $exception->getTraceAsString() @@ -78,7 +78,7 @@ public function handleError($code, $description, $file = null, $line = null, $co if (error_reporting() === 0) { return; } - $stderr = self::getStderr(); + $stderr = static::getStderr(); list($name, $log) = ErrorHandler::mapErrorCode($code); $message = __d('cake_console', '%s in [%s, line %s]', $description, $file, $line); $stderr->write(__d('cake_console', "%s Error: %s\n", $name, $message)); diff --git a/lib/Cake/Console/ConsoleOutput.php b/lib/Cake/Console/ConsoleOutput.php index d1fb2b9bd7b..00111f8678c 100644 --- a/lib/Cake/Console/ConsoleOutput.php +++ b/lib/Cake/Console/ConsoleOutput.php @@ -165,7 +165,7 @@ public function __construct($stream = 'php://stdout') { $stream === 'php://output' || (function_exists('posix_isatty') && !posix_isatty($this->_output)) ) { - $this->_outputAs = self::PLAIN; + $this->_outputAs = static::PLAIN; } } @@ -179,9 +179,9 @@ public function __construct($stream = 'php://stdout') { */ public function write($message, $newlines = 1) { if (is_array($message)) { - $message = implode(self::LF, $message); + $message = implode(static::LF, $message); } - return $this->_write($this->styleText($message . str_repeat(self::LF, $newlines))); + return $this->_write($this->styleText($message . str_repeat(static::LF, $newlines))); } /** @@ -191,11 +191,11 @@ public function write($message, $newlines = 1) { * @return string String with color codes added. */ public function styleText($text) { - if ($this->_outputAs == self::RAW) { + if ($this->_outputAs == static::RAW) { return $text; } - if ($this->_outputAs == self::PLAIN) { - $tags = implode('|', array_keys(self::$_styles)); + if ($this->_outputAs == static::PLAIN) { + $tags = implode('|', array_keys(static::$_styles)); return preg_replace('##', '', $text); } return preg_replace_callback( @@ -216,16 +216,16 @@ protected function _replaceTags($matches) { } $styleInfo = array(); - if (!empty($style['text']) && isset(self::$_foregroundColors[$style['text']])) { - $styleInfo[] = self::$_foregroundColors[$style['text']]; + if (!empty($style['text']) && isset(static::$_foregroundColors[$style['text']])) { + $styleInfo[] = static::$_foregroundColors[$style['text']]; } - if (!empty($style['background']) && isset(self::$_backgroundColors[$style['background']])) { - $styleInfo[] = self::$_backgroundColors[$style['background']]; + if (!empty($style['background']) && isset(static::$_backgroundColors[$style['background']])) { + $styleInfo[] = static::$_backgroundColors[$style['background']]; } unset($style['text'], $style['background']); foreach ($style as $option => $value) { if ($value) { - $styleInfo[] = self::$_options[$option]; + $styleInfo[] = static::$_options[$option]; } } return "\033[" . implode($styleInfo, ';') . 'm' . $matches['text'] . "\033[0m"; @@ -268,16 +268,16 @@ protected function _write($message) { */ public function styles($style = null, $definition = null) { if ($style === null && $definition === null) { - return self::$_styles; + return static::$_styles; } if (is_string($style) && $definition === null) { - return isset(self::$_styles[$style]) ? self::$_styles[$style] : null; + return isset(static::$_styles[$style]) ? static::$_styles[$style] : null; } if ($definition === false) { - unset(self::$_styles[$style]); + unset(static::$_styles[$style]); return true; } - self::$_styles[$style] = $definition; + static::$_styles[$style] = $definition; return true; } diff --git a/lib/Cake/Controller/Component/Acl/PhpAcl.php b/lib/Cake/Controller/Component/Acl/PhpAcl.php index 8c24c08752c..b3b95d66658 100644 --- a/lib/Cake/Controller/Component/Acl/PhpAcl.php +++ b/lib/Cake/Controller/Component/Acl/PhpAcl.php @@ -68,7 +68,7 @@ class PhpAcl extends Object implements AclInterface { */ public function __construct() { $this->options = array( - 'policy' => self::DENY, + 'policy' => static::DENY, 'config' => APP . 'Config' . DS . 'acl.php', ); } @@ -252,7 +252,7 @@ public function path($aco) { } foreach ($root as $node => $elements) { - $pattern = '/^' . str_replace(array_keys(self::$modifiers), array_values(self::$modifiers), $node) . '$/'; + $pattern = '/^' . str_replace(array_keys(static::$modifiers), array_values(static::$modifiers), $node) . '$/'; if ($node == $aco[$level] || preg_match($pattern, $aco[$level])) { // merge allow/denies with $path of current level @@ -494,7 +494,7 @@ public function resolve($aro) { return $this->aliases[$mapped]; } } - return self::DEFAULT_ROLE; + return static::DEFAULT_ROLE; } /** diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index 082f900d2e9..e36114419ce 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -610,7 +610,7 @@ public function login($user = null) { } if ($user) { $this->Session->renew(); - $this->Session->write(self::$sessionKey, $user); + $this->Session->write(static::$sessionKey, $user); $event = new CakeEvent('Auth.afterIdentify', $this, array('user' => $user)); $this->_Collection->getController()->getEventManager()->dispatch($event); } @@ -639,7 +639,7 @@ public function logout() { foreach ($this->_authenticateObjects as $auth) { $auth->logout($user); } - $this->Session->delete(self::$sessionKey); + $this->Session->delete(static::$sessionKey); $this->Session->delete('Auth.redirect'); $this->Session->renew(); return Router::normalize($this->logoutRedirect); @@ -657,10 +657,10 @@ public function logout() { * @link http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#accessing-the-logged-in-user */ public static function user($key = null) { - if (!empty(self::$_user)) { - $user = self::$_user; - } elseif (self::$sessionKey && CakeSession::check(self::$sessionKey)) { - $user = CakeSession::read(self::$sessionKey); + if (!empty(static::$_user)) { + $user = static::$_user; + } elseif (static::$sessionKey && CakeSession::check(static::$sessionKey)) { + $user = CakeSession::read(static::$sessionKey); } else { return null; } @@ -689,7 +689,7 @@ protected function _getUser() { foreach ($this->_authenticateObjects as $auth) { $result = $auth->getUser($this->request); if (!empty($result) && is_array($result)) { - self::$_user = $result; + static::$_user = $result; return true; } } diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index f31bfc9377d..fa64f64f405 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -218,14 +218,14 @@ class App { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::path */ public static function path($type, $plugin = null) { - if (!empty(self::$legacy[$type])) { - $type = self::$legacy[$type]; + if (!empty(static::$legacy[$type])) { + $type = static::$legacy[$type]; } if (!empty($plugin)) { $path = array(); $pluginPath = CakePlugin::path($plugin); - $packageFormat = self::_packageFormat(); + $packageFormat = static::_packageFormat(); if (!empty($packageFormat[$type])) { foreach ($packageFormat[$type] as $f) { $path[] = sprintf($f, $pluginPath); @@ -234,10 +234,10 @@ public static function path($type, $plugin = null) { return $path; } - if (!isset(self::$_packages[$type])) { + if (!isset(static::$_packages[$type])) { return array(); } - return self::$_packages[$type]; + return static::$_packages[$type]; } /** @@ -249,7 +249,7 @@ public static function path($type, $plugin = null) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::paths */ public static function paths() { - return self::$_packages; + return static::$_packages; } /** @@ -279,8 +279,8 @@ public static function build($paths = array(), $mode = App::PREPEND) { //Provides Backwards compatibility for old-style package names $legacyPaths = array(); foreach ($paths as $type => $path) { - if (!empty(self::$legacy[$type])) { - $type = self::$legacy[$type]; + if (!empty(static::$legacy[$type])) { + $type = static::$legacy[$type]; } $legacyPaths[$type] = $path; } @@ -288,17 +288,17 @@ public static function build($paths = array(), $mode = App::PREPEND) { if ($mode === App::RESET) { foreach ($paths as $type => $new) { - self::$_packages[$type] = (array)$new; - self::objects($type, null, false); + static::$_packages[$type] = (array)$new; + static::objects($type, null, false); } return; } if (empty($paths)) { - self::$_packageFormat = null; + static::$_packageFormat = null; } - $packageFormat = self::_packageFormat(); + $packageFormat = static::_packageFormat(); if ($mode === App::REGISTER) { foreach ($paths as $package => $formats) { @@ -309,7 +309,7 @@ public static function build($paths = array(), $mode = App::PREPEND) { $packageFormat[$package] = array_values(array_unique($formats)); } } - self::$_packageFormat = $packageFormat; + static::$_packageFormat = $packageFormat; } $defaults = array(); @@ -320,7 +320,7 @@ public static function build($paths = array(), $mode = App::PREPEND) { } if (empty($paths)) { - self::$_packages = $defaults; + static::$_packages = $defaults; return; } @@ -329,8 +329,8 @@ public static function build($paths = array(), $mode = App::PREPEND) { } foreach ($defaults as $type => $default) { - if (!empty(self::$_packages[$type])) { - $path = self::$_packages[$type]; + if (!empty(static::$_packages[$type])) { + $path = static::$_packages[$type]; } else { $path = $default; } @@ -347,7 +347,7 @@ public static function build($paths = array(), $mode = App::PREPEND) { $path = array_values(array_unique($path)); } - self::$_packages[$type] = $path; + static::$_packages[$type] = $path; } } @@ -380,12 +380,12 @@ public static function pluginPath($plugin) { */ public static function themePath($theme) { $themeDir = 'Themed' . DS . Inflector::camelize($theme); - foreach (self::$_packages['View'] as $path) { + foreach (static::$_packages['View'] as $path) { if (is_dir($path . $themeDir)) { return $path . $themeDir . DS; } } - return self::$_packages['View'][0] . $themeDir . DS; + return static::$_packages['View'][0] . $themeDir . DS; } /** @@ -427,8 +427,8 @@ public static function core($type) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::objects */ public static function objects($type, $path = null, $cache = true) { - if (empty(self::$_objects) && $cache === true) { - self::$_objects = (array)Cache::read('object_map', '_cake_core_'); + if (empty(static::$_objects) && $cache === true) { + static::$_objects = (array)Cache::read('object_map', '_cake_core_'); } $extension = '/\.php$/'; @@ -446,8 +446,8 @@ public static function objects($type, $path = null, $cache = true) { list($plugin, $type) = pluginSplit($type); - if (isset(self::$legacy[$type . 's'])) { - $type = self::$legacy[$type . 's']; + if (isset(static::$legacy[$type . 's'])) { + $type = static::$legacy[$type . 's']; } if ($type === 'file' && !$path) { @@ -459,11 +459,11 @@ public static function objects($type, $path = null, $cache = true) { $cacheLocation = empty($plugin) ? 'app' : $plugin; - if ($cache !== true || !isset(self::$_objects[$cacheLocation][$name])) { + if ($cache !== true || !isset(static::$_objects[$cacheLocation][$name])) { $objects = array(); if (empty($path)) { - $path = self::path($type, $plugin); + $path = static::path($type, $plugin); } foreach ((array)$path as $dir) { @@ -494,13 +494,13 @@ public static function objects($type, $path = null, $cache = true) { return $objects; } - self::$_objects[$cacheLocation][$name] = $objects; + static::$_objects[$cacheLocation][$name] = $objects; if ($cache) { - self::$_objectCacheChange = true; + static::$_objectCacheChange = true; } } - return self::$_objects[$cacheLocation][$name]; + return static::$_objects[$cacheLocation][$name]; } /** @@ -519,7 +519,7 @@ public static function objects($type, $path = null, $cache = true) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::uses */ public static function uses($className, $location) { - self::$_classMap[$className] = $location; + static::$_classMap[$className] = $location; } /** @@ -532,24 +532,24 @@ public static function uses($className, $location) { * @return bool */ public static function load($className) { - if (!isset(self::$_classMap[$className])) { + if (!isset(static::$_classMap[$className])) { return false; } if (strpos($className, '..') !== false) { return false; } - $parts = explode('.', self::$_classMap[$className], 2); + $parts = explode('.', static::$_classMap[$className], 2); list($plugin, $package) = count($parts) > 1 ? $parts : array(null, current($parts)); - $file = self::_mapped($className, $plugin); + $file = static::_mapped($className, $plugin); if ($file) { return include $file; } - $paths = self::path($package, $plugin); + $paths = static::path($package, $plugin); if (empty($plugin)) { - $appLibs = empty(self::$_packages['Lib']) ? APPLIBS : current(self::$_packages['Lib']); + $appLibs = empty(static::$_packages['Lib']) ? APPLIBS : current(static::$_packages['Lib']); $paths[] = $appLibs . $package . DS; $paths[] = APP . $package . DS; $paths[] = CAKE . $package . DS; @@ -563,7 +563,7 @@ public static function load($className) { foreach ($paths as $path) { $file = $path . $normalizedClassName . '.php'; if (file_exists($file)) { - self::_map($file, $className, $plugin); + static::_map($file, $className, $plugin); return include $file; } } @@ -579,8 +579,8 @@ public static function load($className) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::location */ public static function location($className) { - if (!empty(self::$_classMap[$className])) { - return self::$_classMap[$className]; + if (!empty(static::$_classMap[$className])) { + return static::$_classMap[$className]; } return null; } @@ -629,8 +629,8 @@ public static function import($type = null, $name = null, $parent = true, $searc $originalType = strtolower($type); $specialPackage = in_array($originalType, array('file', 'vendor')); - if (!$specialPackage && isset(self::$legacy[$originalType . 's'])) { - $type = self::$legacy[$originalType . 's']; + if (!$specialPackage && isset(static::$legacy[$originalType . 's'])) { + $type = static::$legacy[$originalType . 's']; } list($plugin, $name) = pluginSplit($name); if (!empty($plugin)) { @@ -640,15 +640,15 @@ public static function import($type = null, $name = null, $parent = true, $searc } if (!$specialPackage) { - return self::_loadClass($name, $plugin, $type, $originalType, $parent); + return static::_loadClass($name, $plugin, $type, $originalType, $parent); } if ($originalType === 'file' && !empty($file)) { - return self::_loadFile($name, $plugin, $search, $file, $return); + return static::_loadFile($name, $plugin, $search, $file, $return); } if ($originalType === 'vendor') { - return self::_loadVendor($name, $plugin, $file, $ext); + return static::_loadVendor($name, $plugin, $file, $ext); } return false; @@ -668,12 +668,12 @@ public static function import($type = null, $name = null, $parent = true, $searc protected static function _loadClass($name, $plugin, $type, $originalType, $parent) { if ($type === 'Console/Command' && $name === 'Shell') { $type = 'Console'; - } elseif (isset(self::$types[$originalType]['suffix'])) { - $suffix = self::$types[$originalType]['suffix']; + } elseif (isset(static::$types[$originalType]['suffix'])) { + $suffix = static::$types[$originalType]['suffix']; $name .= ($suffix === $name) ? '' : $suffix; } - if ($parent && isset(self::$types[$originalType]['extends'])) { - $extends = self::$types[$originalType]['extends']; + if ($parent && isset(static::$types[$originalType]['extends'])) { + $extends = static::$types[$originalType]['extends']; $extendType = $type; if (strpos($extends, '/') !== false) { $parts = explode('/', $extends); @@ -704,7 +704,7 @@ protected static function _loadClass($name, $plugin, $type, $originalType, $pare * @return mixed if $return contents of the file after php parses it, boolean indicating success otherwise */ protected static function _loadFile($name, $plugin, $search, $file, $return) { - $mapped = self::_mapped($name, $plugin); + $mapped = static::_mapped($name, $plugin); if ($mapped) { $file = $mapped; } elseif (!empty($search)) { @@ -721,7 +721,7 @@ protected static function _loadFile($name, $plugin, $search, $file, $return) { } } if (!empty($file) && file_exists($file)) { - self::_map($file, $name, $plugin); + static::_map($file, $name, $plugin); $returnValue = include $file; if ($return) { return $returnValue; @@ -741,7 +741,7 @@ protected static function _loadFile($name, $plugin, $search, $file, $return) { * @return bool true if the file was loaded successfully, false otherwise */ protected static function _loadVendor($name, $plugin, $file, $ext) { - if ($mapped = self::_mapped($name, $plugin)) { + if ($mapped = static::_mapped($name, $plugin)) { return (bool)include_once $mapped; } $fileTries = array(); @@ -759,7 +759,7 @@ protected static function _loadVendor($name, $plugin, $file, $ext) { foreach ($fileTries as $file) { foreach ($paths as $path) { if (file_exists($path . $file)) { - self::_map($path . $file, $name, $plugin); + static::_map($path . $file, $name, $plugin); return (bool)include $path . $file; } } @@ -773,7 +773,7 @@ protected static function _loadVendor($name, $plugin, $file, $ext) { * @return void */ public static function init() { - self::$_map += (array)Cache::read('file_map', '_cake_core_'); + static::$_map += (array)Cache::read('file_map', '_cake_core_'); register_shutdown_function(array('App', 'shutdown')); } @@ -790,14 +790,14 @@ protected static function _map($file, $name, $plugin = null) { if ($plugin) { $key = 'plugin.' . $name; } - if ($plugin && empty(self::$_map[$name])) { - self::$_map[$key] = $file; + if ($plugin && empty(static::$_map[$name])) { + static::$_map[$key] = $file; } - if (!$plugin && empty(self::$_map['plugin.' . $name])) { - self::$_map[$key] = $file; + if (!$plugin && empty(static::$_map['plugin.' . $name])) { + static::$_map[$key] = $file; } - if (!self::$bootstrapping) { - self::$_cacheChange = true; + if (!static::$bootstrapping) { + static::$_cacheChange = true; } } @@ -813,7 +813,7 @@ protected static function _mapped($name, $plugin = null) { if ($plugin) { $key = 'plugin.' . $name; } - return isset(self::$_map[$key]) ? self::$_map[$key] : false; + return isset(static::$_map[$key]) ? static::$_map[$key] : false; } /** @@ -822,8 +822,8 @@ protected static function _mapped($name, $plugin = null) { * @return array templates for each customizable package path */ protected static function _packageFormat() { - if (empty(self::$_packageFormat)) { - self::$_packageFormat = array( + if (empty(static::$_packageFormat)) { + static::$_packageFormat = array( 'Model' => array( '%s' . 'Model' . DS ), @@ -885,7 +885,7 @@ protected static function _packageFormat() { ); } - return self::$_packageFormat; + return static::$_packageFormat; } /** @@ -897,13 +897,13 @@ protected static function _packageFormat() { * @return void */ public static function shutdown() { - if (self::$_cacheChange) { - Cache::write('file_map', array_filter(self::$_map), '_cake_core_'); + if (static::$_cacheChange) { + Cache::write('file_map', array_filter(static::$_map), '_cake_core_'); } - if (self::$_objectCacheChange) { - Cache::write('object_map', self::$_objects, '_cake_core_'); + if (static::$_objectCacheChange) { + Cache::write('object_map', static::$_objects, '_cake_core_'); } - self::_checkFatalError(); + static::_checkFatalError(); } /** diff --git a/lib/Cake/Core/CakePlugin.php b/lib/Cake/Core/CakePlugin.php index 1c2a31a4477..426e22a948b 100644 --- a/lib/Cake/Core/CakePlugin.php +++ b/lib/Cake/Core/CakePlugin.php @@ -91,7 +91,7 @@ public static function load($plugin, $config = array()) { if (is_array($plugin)) { foreach ($plugin as $name => $conf) { list($name, $conf) = (is_numeric($name)) ? array($conf, $config) : array($name, $conf); - self::load($name, $conf); + static::load($name, $conf); } return; } @@ -99,26 +99,26 @@ public static function load($plugin, $config = array()) { if (empty($config['path'])) { foreach (App::path('plugins') as $path) { if (is_dir($path . $plugin)) { - self::$_plugins[$plugin] = $config + array('path' => $path . $plugin . DS); + static::$_plugins[$plugin] = $config + array('path' => $path . $plugin . DS); break; } //Backwards compatibility to make easier to migrate to 2.0 $underscored = Inflector::underscore($plugin); if (is_dir($path . $underscored)) { - self::$_plugins[$plugin] = $config + array('path' => $path . $underscored . DS); + static::$_plugins[$plugin] = $config + array('path' => $path . $underscored . DS); break; } } } else { - self::$_plugins[$plugin] = $config; + static::$_plugins[$plugin] = $config; } - if (empty(self::$_plugins[$plugin]['path'])) { + if (empty(static::$_plugins[$plugin]['path'])) { throw new MissingPluginException(array('plugin' => $plugin)); } - if (!empty(self::$_plugins[$plugin]['bootstrap'])) { - self::bootstrap($plugin); + if (!empty(static::$_plugins[$plugin]['bootstrap'])) { + static::bootstrap($plugin); } } @@ -160,7 +160,7 @@ public static function loadAll($options = array()) { if (isset($options[0])) { $opts += $options[0]; } - self::load($p, $opts); + static::load($p, $opts); } } @@ -172,10 +172,10 @@ public static function loadAll($options = array()) { * @throws MissingPluginException if the folder for plugin was not found or plugin has not been loaded */ public static function path($plugin) { - if (empty(self::$_plugins[$plugin])) { + if (empty(static::$_plugins[$plugin])) { throw new MissingPluginException(array('plugin' => $plugin)); } - return self::$_plugins[$plugin]['path']; + return static::$_plugins[$plugin]['path']; } /** @@ -186,7 +186,7 @@ public static function path($plugin) { * @see CakePlugin::load() for examples of bootstrap configuration */ public static function bootstrap($plugin) { - $config = self::$_plugins[$plugin]; + $config = static::$_plugins[$plugin]; if ($config['bootstrap'] === false) { return false; } @@ -194,9 +194,9 @@ public static function bootstrap($plugin) { return call_user_func_array($config['bootstrap'], array($plugin, $config)); } - $path = self::path($plugin); + $path = static::path($plugin); if ($config['bootstrap'] === true) { - return self::_includeFile( + return static::_includeFile( $path . 'Config' . DS . 'bootstrap.php', $config['ignoreMissing'] ); @@ -204,7 +204,7 @@ public static function bootstrap($plugin) { $bootstrap = (array)$config['bootstrap']; foreach ($bootstrap as $file) { - self::_includeFile( + static::_includeFile( $path . 'Config' . DS . $file . '.php', $config['ignoreMissing'] ); @@ -222,17 +222,17 @@ public static function bootstrap($plugin) { */ public static function routes($plugin = null) { if ($plugin === null) { - foreach (self::loaded() as $p) { - self::routes($p); + foreach (static::loaded() as $p) { + static::routes($p); } return true; } - $config = self::$_plugins[$plugin]; + $config = static::$_plugins[$plugin]; if ($config['routes'] === false) { return false; } - return (bool)self::_includeFile( - self::path($plugin) . 'Config' . DS . 'routes.php', + return (bool)static::_includeFile( + static::path($plugin) . 'Config' . DS . 'routes.php', $config['ignoreMissing'] ); } @@ -247,9 +247,9 @@ public static function routes($plugin = null) { */ public static function loaded($plugin = null) { if ($plugin) { - return isset(self::$_plugins[$plugin]); + return isset(static::$_plugins[$plugin]); } - $return = array_keys(self::$_plugins); + $return = array_keys(static::$_plugins); sort($return); return $return; } @@ -262,9 +262,9 @@ public static function loaded($plugin = null) { */ public static function unload($plugin = null) { if ($plugin === null) { - self::$_plugins = array(); + static::$_plugins = array(); } else { - unset(self::$_plugins[$plugin]); + unset(static::$_plugins[$plugin]); } } diff --git a/lib/Cake/Core/Configure.php b/lib/Cake/Core/Configure.php index 49345aca1dc..464608e8f2f 100644 --- a/lib/Cake/Core/Configure.php +++ b/lib/Cake/Core/Configure.php @@ -67,7 +67,7 @@ class Configure { */ public static function bootstrap($boot = true) { if ($boot) { - self::_appDefaults(); + static::_appDefaults(); if (!include APP . 'Config' . DS . 'core.php') { trigger_error(__d('cake_dev', @@ -87,7 +87,7 @@ public static function bootstrap($boot = true) { 'handler' => 'ErrorHandler::handleError', 'level' => E_ALL & ~E_DEPRECATED, ); - self::_setErrorHandlers($error, $exception); + static::_setErrorHandlers($error, $exception); if (!include APP . 'Config' . DS . 'bootstrap.php') { trigger_error(__d('cake_dev', @@ -98,13 +98,13 @@ public static function bootstrap($boot = true) { } restore_error_handler(); - self::_setErrorHandlers( - self::$_values['Error'], - self::$_values['Exception'] + static::_setErrorHandlers( + static::$_values['Error'], + static::$_values['Exception'] ); // Preload Debugger + CakeText in case of E_STRICT errors when loading files. - if (self::$_values['debug'] > 0) { + if (static::$_values['debug'] > 0) { class_exists('Debugger'); class_exists('CakeText'); } @@ -117,7 +117,7 @@ class_exists('CakeText'); * @return void */ protected static function _appDefaults() { - self::write('App', (array)self::read('App') + array( + static::write('App', (array)static::read('App') + array( 'base' => false, 'baseUrl' => false, 'dir' => APP_DIR, @@ -156,11 +156,11 @@ public static function write($config, $value = null) { } foreach ($config as $name => $value) { - self::$_values = Hash::insert(self::$_values, $name, $value); + static::$_values = Hash::insert(static::$_values, $name, $value); } if (isset($config['debug']) && function_exists('ini_set')) { - if (self::$_values['debug']) { + if (static::$_values['debug']) { ini_set('display_errors', 1); } else { ini_set('display_errors', 0); @@ -185,9 +185,9 @@ public static function write($config, $value = null) { */ public static function read($var = null) { if ($var === null) { - return self::$_values; + return static::$_values; } - return Hash::get(self::$_values, $var); + return Hash::get(static::$_values, $var); } /** @@ -201,16 +201,16 @@ public static function read($var = null) { */ public static function consume($var) { $simple = strpos($var, '.') === false; - if ($simple && !isset(self::$_values[$var])) { + if ($simple && !isset(static::$_values[$var])) { return null; } if ($simple) { - $value = self::$_values[$var]; - unset(self::$_values[$var]); + $value = static::$_values[$var]; + unset(static::$_values[$var]); return $value; } - $value = Hash::get(self::$_values, $var); - self::$_values = Hash::remove(self::$_values, $var); + $value = Hash::get(static::$_values, $var); + static::$_values = Hash::remove(static::$_values, $var); return $value; } @@ -224,7 +224,7 @@ public static function check($var) { if (empty($var)) { return false; } - return Hash::get(self::$_values, $var) !== null; + return Hash::get(static::$_values, $var) !== null; } /** @@ -241,7 +241,7 @@ public static function check($var) { * @link http://book.cakephp.org/2.0/en/development/configuration.html#Configure::delete */ public static function delete($var) { - self::$_values = Hash::remove(self::$_values, $var); + static::$_values = Hash::remove(static::$_values, $var); } /** @@ -259,7 +259,7 @@ public static function delete($var) { * @return void */ public static function config($name, ConfigReaderInterface $reader) { - self::$_readers[$name] = $reader; + static::$_readers[$name] = $reader; } /** @@ -270,9 +270,9 @@ public static function config($name, ConfigReaderInterface $reader) { */ public static function configured($name = null) { if ($name) { - return isset(self::$_readers[$name]); + return isset(static::$_readers[$name]); } - return array_keys(self::$_readers); + return array_keys(static::$_readers); } /** @@ -283,10 +283,10 @@ public static function configured($name = null) { * @return bool Success */ public static function drop($name) { - if (!isset(self::$_readers[$name])) { + if (!isset(static::$_readers[$name])) { return false; } - unset(self::$_readers[$name]); + unset(static::$_readers[$name]); return true; } @@ -316,7 +316,7 @@ public static function drop($name) { * @link http://book.cakephp.org/2.0/en/development/configuration.html#Configure::load */ public static function load($key, $config = 'default', $merge = true) { - $reader = self::_getReader($config); + $reader = static::_getReader($config); if (!$reader) { return false; } @@ -325,13 +325,13 @@ public static function load($key, $config = 'default', $merge = true) { if ($merge) { $keys = array_keys($values); foreach ($keys as $key) { - if (($c = self::read($key)) && is_array($values[$key]) && is_array($c)) { + if (($c = static::read($key)) && is_array($values[$key]) && is_array($c)) { $values[$key] = Hash::merge($c, $values[$key]); } } } - return self::write($values); + return static::write($values); } /** @@ -360,14 +360,14 @@ public static function load($key, $config = 'default', $merge = true) { * @throws ConfigureException if the adapter does not implement a `dump` method. */ public static function dump($key, $config = 'default', $keys = array()) { - $reader = self::_getReader($config); + $reader = static::_getReader($config); if (!$reader) { throw new ConfigureException(__d('cake_dev', 'There is no "%s" adapter.', $config)); } if (!method_exists($reader, 'dump')) { throw new ConfigureException(__d('cake_dev', 'The "%s" adapter, does not have a %s method.', $config, 'dump()')); } - $values = self::$_values; + $values = static::$_values; if (!empty($keys) && is_array($keys)) { $values = array_intersect_key($values, array_flip($keys)); } @@ -382,14 +382,14 @@ public static function dump($key, $config = 'default', $keys = array()) { * @return mixed Reader instance or false */ protected static function _getReader($config) { - if (!isset(self::$_readers[$config])) { + if (!isset(static::$_readers[$config])) { if ($config !== 'default') { return false; } App::uses('PhpReader', 'Configure'); - self::config($config, new PhpReader()); + static::config($config, new PhpReader()); } - return self::$_readers[$config]; + return static::$_readers[$config]; } /** @@ -400,11 +400,11 @@ protected static function _getReader($config) { * @return string Current version of CakePHP */ public static function version() { - if (!isset(self::$_values['Cake']['version'])) { + if (!isset(static::$_values['Cake']['version'])) { require CAKE . 'Config' . DS . 'config.php'; - self::write($config); + static::write($config); } - return self::$_values['Cake']['version']; + return static::$_values['Cake']['version']; } /** @@ -419,7 +419,7 @@ public static function version() { */ public static function store($name, $cacheConfig = 'default', $data = null) { if ($data === null) { - $data = self::$_values; + $data = static::$_values; } return Cache::write($name, $data, $cacheConfig); } @@ -435,7 +435,7 @@ public static function store($name, $cacheConfig = 'default', $data = null) { public static function restore($name, $cacheConfig = 'default') { $values = Cache::read($name, $cacheConfig); if ($values) { - return self::write($values); + return static::write($values); } return false; } @@ -446,7 +446,7 @@ public static function restore($name, $cacheConfig = 'default') { * @return bool Success. */ public static function clear() { - self::$_values = array(); + static::$_values = array(); return true; } diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index 5ecba0960f2..bde45f51364 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -115,7 +115,7 @@ class ErrorHandler { */ public static function handleException(Exception $exception) { $config = Configure::read('Exception'); - self::_log($exception, $config); + static::_log($exception, $config); $renderer = isset($config['renderer']) ? $config['renderer'] : 'ExceptionRenderer'; if ($renderer !== 'ExceptionRenderer') { @@ -134,7 +134,7 @@ public static function handleException(Exception $exception) { $e->getTraceAsString() ); - self::$_bailExceptionRendering = true; + static::$_bailExceptionRendering = true; trigger_error($message, E_USER_ERROR); } } @@ -185,7 +185,7 @@ protected static function _log(Exception $exception, $config) { } } } - return CakeLog::write(LOG_ERR, self::_getMessage($exception)); + return CakeLog::write(LOG_ERR, static::_getMessage($exception)); } /** @@ -208,9 +208,9 @@ public static function handleError($code, $description, $file = null, $line = nu return false; } $errorConfig = Configure::read('Error'); - list($error, $log) = self::mapErrorCode($code); + list($error, $log) = static::mapErrorCode($code); if ($log === LOG_ERR) { - return self::handleFatalError($code, $description, $file, $line); + return static::handleFatalError($code, $description, $file, $line); } $debug = Configure::read('debug'); @@ -266,8 +266,8 @@ public static function handleFatalError($code, $description, $file, $line) { $exception = new InternalErrorException(); } - if (self::$_bailExceptionRendering) { - self::$_bailExceptionRendering = false; + if (static::$_bailExceptionRendering) { + static::$_bailExceptionRendering = false; throw $exception; } diff --git a/lib/Cake/Event/CakeEventManager.php b/lib/Cake/Event/CakeEventManager.php index 64d94ccd8bc..f647fd941d0 100644 --- a/lib/Cake/Event/CakeEventManager.php +++ b/lib/Cake/Event/CakeEventManager.php @@ -67,14 +67,14 @@ class CakeEventManager { */ public static function instance($manager = null) { if ($manager instanceof CakeEventManager) { - self::$_generalManager = $manager; + static::$_generalManager = $manager; } - if (empty(self::$_generalManager)) { - self::$_generalManager = new CakeEventManager(); + if (empty(static::$_generalManager)) { + static::$_generalManager = new CakeEventManager(); } - self::$_generalManager->_isGlobal = true; - return self::$_generalManager; + static::$_generalManager->_isGlobal = true; + return static::$_generalManager; } /** @@ -105,7 +105,7 @@ public function attach($callable, $eventKey = null, $options = array()) { $this->_attachSubscriber($callable); return; } - $options = $options + array('priority' => self::$defaultPriority, 'passParams' => false); + $options = $options + array('priority' => static::$defaultPriority, 'passParams' => false); $this->_listeners[$eventKey][$options['priority']][] = array( 'callable' => $callable, 'passParams' => $options['passParams'], @@ -265,7 +265,7 @@ public function listeners($eventKey) { $localListeners = $this->prioritisedListeners($eventKey); $localListeners = empty($localListeners) ? array() : $localListeners; } - $globalListeners = self::instance()->prioritisedListeners($eventKey); + $globalListeners = static::instance()->prioritisedListeners($eventKey); $globalListeners = empty($globalListeners) ? array() : $globalListeners; $priorities = array_merge(array_keys($globalListeners), array_keys($localListeners)); diff --git a/lib/Cake/I18n/I18n.php b/lib/Cake/I18n/I18n.php index 907adc5f40e..9f0d06fea08 100644 --- a/lib/Cake/I18n/I18n.php +++ b/lib/Cake/I18n/I18n.php @@ -223,7 +223,7 @@ public static function translate($singular, $plural = null, $domain = null, $cat } if ($domain === null) { - $domain = self::$defaultDomain; + $domain = static::$defaultDomain; } if ($domain === '') { throw new CakeException(__d('cake_dev', 'You cannot use "" as a domain.')); @@ -399,7 +399,7 @@ protected function _bindTextDomain($domain) { foreach ($this->l10n->languagePath as $lang) { $localeDef = $directory . $lang . DS . $this->category; if (is_file($localeDef)) { - $definitions = self::loadLocaleDefinition($localeDef); + $definitions = static::loadLocaleDefinition($localeDef); if ($definitions !== false) { $this->_domains[$domain][$this->_lang][$this->category] = $definitions; $this->_noLocale = false; @@ -412,10 +412,10 @@ protected function _bindTextDomain($domain) { $translations = false; if (is_file($app . '.mo')) { - $translations = self::loadMo($app . '.mo'); + $translations = static::loadMo($app . '.mo'); } if ($translations === false && is_file($app . '.po')) { - $translations = self::loadPo($app . '.po'); + $translations = static::loadPo($app . '.po'); } if ($translations !== false) { @@ -430,10 +430,10 @@ protected function _bindTextDomain($domain) { $translations = false; if (is_file($file . '.mo')) { - $translations = self::loadMo($file . '.mo'); + $translations = static::loadMo($file . '.mo'); } if ($translations === false && is_file($file . '.po')) { - $translations = self::loadPo($file . '.po'); + $translations = static::loadPo($file . '.po'); } if ($translations !== false) { diff --git a/lib/Cake/I18n/Multibyte.php b/lib/Cake/I18n/Multibyte.php index 9568065b56d..d11e15afab5 100644 --- a/lib/Cake/I18n/Multibyte.php +++ b/lib/Cake/I18n/Multibyte.php @@ -550,7 +550,7 @@ public static function strtolower($string) { $matched = true; } else { $matched = false; - $keys = self::_find($char, 'upper'); + $keys = static::_find($char, 'upper'); if (!empty($keys)) { foreach ($keys as $key => $value) { @@ -596,7 +596,7 @@ public static function strtoupper($string) { } else { $matched = false; - $keys = self::_find($char); + $keys = static::_find($char); $keyCount = count($keys); if (!empty($keys)) { @@ -815,7 +815,7 @@ protected static function _codepoint($decimal) { } else { $return = false; } - self::$_codeRange[$decimal] = $return; + static::$_codeRange[$decimal] = $return; return $return; } @@ -828,8 +828,8 @@ protected static function _codepoint($decimal) { */ protected static function _find($char, $type = 'lower') { $found = array(); - if (!isset(self::$_codeRange[$char])) { - $range = self::_codepoint($char); + if (!isset(static::$_codeRange[$char])) { + $range = static::_codepoint($char); if ($range === false) { return array(); } @@ -838,21 +838,21 @@ protected static function _find($char, $type = 'lower') { Configure::config('_cake_core_', new PhpReader(CAKE . 'Config' . DS)); } Configure::load('unicode' . DS . 'casefolding' . DS . $range, '_cake_core_'); - self::$_caseFold[$range] = Configure::read($range); + static::$_caseFold[$range] = Configure::read($range); Configure::delete($range); } - if (!self::$_codeRange[$char]) { + if (!static::$_codeRange[$char]) { return array(); } - self::$_table = self::$_codeRange[$char]; - $count = count(self::$_caseFold[self::$_table]); + static::$_table = static::$_codeRange[$char]; + $count = count(static::$_caseFold[static::$_table]); for ($i = 0; $i < $count; $i++) { - if ($type === 'lower' && self::$_caseFold[self::$_table][$i][$type][0] === $char) { - $found[] = self::$_caseFold[self::$_table][$i]; - } elseif ($type === 'upper' && self::$_caseFold[self::$_table][$i][$type] === $char) { - $found[] = self::$_caseFold[self::$_table][$i]; + if ($type === 'lower' && static::$_caseFold[static::$_table][$i][$type][0] === $char) { + $found[] = static::$_caseFold[static::$_table][$i]; + } elseif ($type === 'upper' && static::$_caseFold[static::$_table][$i][$type] === $char) { + $found[] = static::$_caseFold[static::$_table][$i]; } } return $found; diff --git a/lib/Cake/Log/CakeLog.php b/lib/Cake/Log/CakeLog.php index b8e4ed05869..0e8ae276041 100644 --- a/lib/Cake/Log/CakeLog.php +++ b/lib/Cake/Log/CakeLog.php @@ -118,8 +118,8 @@ class CakeLog { * @return void */ protected static function _init() { - self::$_levels = self::defaultLevels(); - self::$_Collection = new LogEngineCollection(); + static::$_levels = static::defaultLevels(); + static::$_Collection = new LogEngineCollection(); } /** @@ -193,10 +193,10 @@ public static function config($key, $config) { if (empty($config['engine'])) { throw new CakeLogException(__d('cake_dev', 'Missing logger class name')); } - if (empty(self::$_Collection)) { - self::_init(); + if (empty(static::$_Collection)) { + static::_init(); } - self::$_Collection->load($key, $config); + static::$_Collection->load($key, $config); return true; } @@ -206,10 +206,10 @@ public static function config($key, $config) { * @return array Array of configured log streams. */ public static function configured() { - if (empty(self::$_Collection)) { - self::_init(); + if (empty(static::$_Collection)) { + static::_init(); } - return self::$_Collection->loaded(); + return static::$_Collection->loaded(); } /** @@ -259,20 +259,20 @@ public static function configured() { * @return array Active log levels */ public static function levels($levels = array(), $append = true) { - if (empty(self::$_Collection)) { - self::_init(); + if (empty(static::$_Collection)) { + static::_init(); } if (empty($levels)) { - return self::$_levels; + return static::$_levels; } $levels = array_values($levels); if ($append) { - self::$_levels = array_merge(self::$_levels, $levels); + static::$_levels = array_merge(static::$_levels, $levels); } else { - self::$_levels = $levels; + static::$_levels = $levels; } - self::$_levelMap = array_flip(self::$_levels); - return self::$_levels; + static::$_levelMap = array_flip(static::$_levels); + return static::$_levels; } /** @@ -281,9 +281,9 @@ public static function levels($levels = array(), $append = true) { * @return array Default log levels */ public static function defaultLevels() { - self::$_levelMap = self::$_defaultLevels; - self::$_levels = array_flip(self::$_levelMap); - return self::$_levels; + static::$_levelMap = static::$_defaultLevels; + static::$_levels = array_flip(static::$_levelMap); + return static::$_levels; } /** @@ -294,10 +294,10 @@ public static function defaultLevels() { * @return void */ public static function drop($streamName) { - if (empty(self::$_Collection)) { - self::_init(); + if (empty(static::$_Collection)) { + static::_init(); } - self::$_Collection->unload($streamName); + static::$_Collection->unload($streamName); } /** @@ -308,13 +308,13 @@ public static function drop($streamName) { * @throws CakeLogException */ public static function enabled($streamName) { - if (empty(self::$_Collection)) { - self::_init(); + if (empty(static::$_Collection)) { + static::_init(); } - if (!isset(self::$_Collection->{$streamName})) { + if (!isset(static::$_Collection->{$streamName})) { throw new CakeLogException(__d('cake_dev', 'Stream %s not found', $streamName)); } - return self::$_Collection->enabled($streamName); + return static::$_Collection->enabled($streamName); } /** @@ -326,13 +326,13 @@ public static function enabled($streamName) { * @throws CakeLogException */ public static function enable($streamName) { - if (empty(self::$_Collection)) { - self::_init(); + if (empty(static::$_Collection)) { + static::_init(); } - if (!isset(self::$_Collection->{$streamName})) { + if (!isset(static::$_Collection->{$streamName})) { throw new CakeLogException(__d('cake_dev', 'Stream %s not found', $streamName)); } - self::$_Collection->enable($streamName); + static::$_Collection->enable($streamName); } /** @@ -345,13 +345,13 @@ public static function enable($streamName) { * @throws CakeLogException */ public static function disable($streamName) { - if (empty(self::$_Collection)) { - self::_init(); + if (empty(static::$_Collection)) { + static::_init(); } - if (!isset(self::$_Collection->{$streamName})) { + if (!isset(static::$_Collection->{$streamName})) { throw new CakeLogException(__d('cake_dev', 'Stream %s not found', $streamName)); } - self::$_Collection->disable($streamName); + static::$_Collection->disable($streamName); } /** @@ -362,11 +362,11 @@ public static function disable($streamName) { * @see BaseLog */ public static function stream($streamName) { - if (empty(self::$_Collection)) { - self::_init(); + if (empty(static::$_Collection)) { + static::_init(); } - if (!empty(self::$_Collection->{$streamName})) { - return self::$_Collection->{$streamName}; + if (!empty(static::$_Collection->{$streamName})) { + return static::$_Collection->{$streamName}; } return false; } @@ -403,19 +403,19 @@ public static function stream($streamName) { * @link http://book.cakephp.org/2.0/en/core-libraries/logging.html#writing-to-logs */ public static function write($type, $message, $scope = array()) { - if (empty(self::$_Collection)) { - self::_init(); + if (empty(static::$_Collection)) { + static::_init(); } - if (is_int($type) && isset(self::$_levels[$type])) { - $type = self::$_levels[$type]; + if (is_int($type) && isset(static::$_levels[$type])) { + $type = static::$_levels[$type]; } - if (is_string($type) && empty($scope) && !in_array($type, self::$_levels)) { + if (is_string($type) && empty($scope) && !in_array($type, static::$_levels)) { $scope = $type; } $logged = false; - foreach (self::$_Collection->enabled() as $streamName) { - $logger = self::$_Collection->{$streamName}; + foreach (static::$_Collection->enabled() as $streamName) { + $logger = static::$_Collection->{$streamName}; $types = $scopes = $config = array(); if (method_exists($logger, 'config')) { $config = $logger->config(); @@ -455,7 +455,7 @@ public static function write($type, $message, $scope = array()) { * @return bool Success */ public static function emergency($message, $scope = array()) { - return self::write(self::$_levelMap['emergency'], $message, $scope); + return static::write(static::$_levelMap['emergency'], $message, $scope); } /** @@ -467,7 +467,7 @@ public static function emergency($message, $scope = array()) { * @return bool Success */ public static function alert($message, $scope = array()) { - return self::write(self::$_levelMap['alert'], $message, $scope); + return static::write(static::$_levelMap['alert'], $message, $scope); } /** @@ -479,7 +479,7 @@ public static function alert($message, $scope = array()) { * @return bool Success */ public static function critical($message, $scope = array()) { - return self::write(self::$_levelMap['critical'], $message, $scope); + return static::write(static::$_levelMap['critical'], $message, $scope); } /** @@ -491,7 +491,7 @@ public static function critical($message, $scope = array()) { * @return bool Success */ public static function error($message, $scope = array()) { - return self::write(self::$_levelMap['error'], $message, $scope); + return static::write(static::$_levelMap['error'], $message, $scope); } /** @@ -503,7 +503,7 @@ public static function error($message, $scope = array()) { * @return bool Success */ public static function warning($message, $scope = array()) { - return self::write(self::$_levelMap['warning'], $message, $scope); + return static::write(static::$_levelMap['warning'], $message, $scope); } /** @@ -515,7 +515,7 @@ public static function warning($message, $scope = array()) { * @return bool Success */ public static function notice($message, $scope = array()) { - return self::write(self::$_levelMap['notice'], $message, $scope); + return static::write(static::$_levelMap['notice'], $message, $scope); } /** @@ -527,7 +527,7 @@ public static function notice($message, $scope = array()) { * @return bool Success */ public static function debug($message, $scope = array()) { - return self::write(self::$_levelMap['debug'], $message, $scope); + return static::write(static::$_levelMap['debug'], $message, $scope); } /** @@ -539,7 +539,7 @@ public static function debug($message, $scope = array()) { * @return bool Success */ public static function info($message, $scope = array()) { - return self::write(self::$_levelMap['info'], $message, $scope); + return static::write(static::$_levelMap['info'], $message, $scope); } } diff --git a/lib/Cake/Model/ConnectionManager.php b/lib/Cake/Model/ConnectionManager.php index 26a637b39b1..926b5f22ec9 100644 --- a/lib/Cake/Model/ConnectionManager.php +++ b/lib/Cake/Model/ConnectionManager.php @@ -66,9 +66,9 @@ class ConnectionManager { protected static function _init() { include_once APP . 'Config' . DS . 'database.php'; if (class_exists('DATABASE_CONFIG')) { - self::$config = new DATABASE_CONFIG(); + static::$config = new DATABASE_CONFIG(); } - self::$_init = true; + static::$_init = true; } /** @@ -79,20 +79,20 @@ protected static function _init() { * @throws MissingDatasourceException */ public static function getDataSource($name) { - if (empty(self::$_init)) { - self::_init(); + if (empty(static::$_init)) { + static::_init(); } - if (!empty(self::$_dataSources[$name])) { - return self::$_dataSources[$name]; + if (!empty(static::$_dataSources[$name])) { + return static::$_dataSources[$name]; } - if (empty(self::$_connectionsEnum[$name])) { - self::_getConnectionObject($name); + if (empty(static::$_connectionsEnum[$name])) { + static::_getConnectionObject($name); } - self::loadDataSource($name); - $conn = self::$_connectionsEnum[$name]; + static::loadDataSource($name); + $conn = static::$_connectionsEnum[$name]; $class = $conn['classname']; if (strpos(App::location($class), 'Datasource') === false) { @@ -102,10 +102,10 @@ public static function getDataSource($name) { 'message' => 'Datasource is not found in Model/Datasource package.' )); } - self::$_dataSources[$name] = new $class(self::$config->{$name}); - self::$_dataSources[$name]->configKeyName = $name; + static::$_dataSources[$name] = new $class(static::$config->{$name}); + static::$_dataSources[$name]->configKeyName = $name; - return self::$_dataSources[$name]; + return static::$_dataSources[$name]; } /** @@ -116,10 +116,10 @@ public static function getDataSource($name) { * @return array List of available connections */ public static function sourceList() { - if (empty(self::$_init)) { - self::_init(); + if (empty(static::$_init)) { + static::_init(); } - return array_keys(self::$_dataSources); + return array_keys(static::$_dataSources); } /** @@ -130,10 +130,10 @@ public static function sourceList() { * in the ConnectionManager. */ public static function getSourceName($source) { - if (empty(self::$_init)) { - self::_init(); + if (empty(static::$_init)) { + static::_init(); } - foreach (self::$_dataSources as $name => $ds) { + foreach (static::$_dataSources as $name => $ds) { if ($ds === $source) { return $name; } @@ -151,14 +151,14 @@ public static function getSourceName($source) { * @throws MissingDatasourceException */ public static function loadDataSource($connName) { - if (empty(self::$_init)) { - self::_init(); + if (empty(static::$_init)) { + static::_init(); } if (is_array($connName)) { $conn = $connName; } else { - $conn = self::$_connectionsEnum[$connName]; + $conn = static::$_connectionsEnum[$connName]; } if (class_exists($conn['classname'], false)) { @@ -190,10 +190,10 @@ public static function loadDataSource($connName) { * (as defined in Connections), and the value is an array with keys 'filename' and 'classname'. */ public static function enumConnectionObjects() { - if (empty(self::$_init)) { - self::_init(); + if (empty(static::$_init)) { + static::_init(); } - return (array)self::$config; + return (array)static::$config; } /** @@ -204,16 +204,16 @@ public static function enumConnectionObjects() { * @return DataSource|null A reference to the DataSource object, or null if creation failed */ public static function create($name = '', $config = array()) { - if (empty(self::$_init)) { - self::_init(); + if (empty(static::$_init)) { + static::_init(); } - if (empty($name) || empty($config) || array_key_exists($name, self::$_connectionsEnum)) { + if (empty($name) || empty($config) || array_key_exists($name, static::$_connectionsEnum)) { return null; } - self::$config->{$name} = $config; - self::$_connectionsEnum[$name] = self::_connectionData($config); - $return = self::getDataSource($name); + static::$config->{$name} = $config; + static::$_connectionsEnum[$name] = static::_connectionData($config); + $return = static::getDataSource($name); return $return; } @@ -224,14 +224,14 @@ public static function create($name = '', $config = array()) { * @return bool success if connection was removed, false if it does not exist */ public static function drop($name) { - if (empty(self::$_init)) { - self::_init(); + if (empty(static::$_init)) { + static::_init(); } - if (!isset(self::$config->{$name})) { + if (!isset(static::$config->{$name})) { return false; } - unset(self::$_connectionsEnum[$name], self::$_dataSources[$name], self::$config->{$name}); + unset(static::$_connectionsEnum[$name], static::$_dataSources[$name], static::$config->{$name}); return true; } @@ -243,8 +243,8 @@ public static function drop($name) { * @throws MissingDatasourceConfigException */ protected static function _getConnectionObject($name) { - if (!empty(self::$config->{$name})) { - self::$_connectionsEnum[$name] = self::_connectionData(self::$config->{$name}); + if (!empty(static::$config->{$name})) { + static::$_connectionsEnum[$name] = static::_connectionData(static::$config->{$name}); } else { throw new MissingDatasourceConfigException(array('config' => $name)); } diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index 108443ccef7..b6c20b209a5 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -141,20 +141,20 @@ class CakeSession { * @return void */ public static function init($base = null) { - self::$time = time(); + static::$time = time(); if (env('HTTP_USER_AGENT')) { - self::$_userAgent = md5(env('HTTP_USER_AGENT') . Configure::read('Security.salt')); + static::$_userAgent = md5(env('HTTP_USER_AGENT') . Configure::read('Security.salt')); } - self::_setPath($base); - self::_setHost(env('HTTP_HOST')); + static::_setPath($base); + static::_setHost(env('HTTP_HOST')); - if (!self::$_initialized) { + if (!static::$_initialized) { register_shutdown_function('session_write_close'); } - self::$_initialized = true; + static::$_initialized = true; } /** @@ -165,7 +165,7 @@ public static function init($base = null) { */ protected static function _setPath($base = null) { if (empty($base)) { - self::$path = '/'; + static::$path = '/'; return; } if (strpos($base, 'index.php') !== false) { @@ -174,7 +174,7 @@ protected static function _setPath($base = null) { if (strpos($base, '?') !== false) { $base = str_replace('?', '', $base); } - self::$path = $base; + static::$path = $base; } /** @@ -184,9 +184,9 @@ protected static function _setPath($base = null) { * @return void */ protected static function _setHost($host) { - self::$host = $host; - if (strpos(self::$host, ':') !== false) { - self::$host = substr(self::$host, 0, strpos(self::$host, ':')); + static::$host = $host; + if (strpos(static::$host, ':') !== false) { + static::$host = substr(static::$host, 0, strpos(static::$host, ':')); } } @@ -196,20 +196,20 @@ protected static function _setHost($host) { * @return bool True if session was started */ public static function start() { - if (self::started()) { + if (static::started()) { return true; } - $id = self::id(); - self::_startSession(); + $id = static::id(); + static::_startSession(); - if (!$id && self::started()) { - self::_checkValid(); + if (!$id && static::started()) { + static::_checkValid(); } - self::$error = false; - self::$valid = true; - return self::started(); + static::$error = false; + static::$valid = true; + return static::started(); } /** @@ -228,7 +228,7 @@ public static function started() { * @return bool True if variable is there */ public static function check($name) { - if (empty($name) || !self::_hasSession() || !self::start()) { + if (empty($name) || !static::_hasSession() || !static::start()) { return false; } @@ -251,13 +251,13 @@ public static function check($name) { */ public static function id($id = null) { if ($id) { - self::$id = $id; - session_id(self::$id); + static::$id = $id; + session_id(static::$id); } - if (self::started()) { + if (static::started()) { return session_id(); } - return self::$id; + return static::$id; } /** @@ -267,9 +267,9 @@ public static function id($id = null) { * @return bool Success */ public static function delete($name) { - if (self::check($name)) { - self::_overwrite($_SESSION, Hash::remove($_SESSION, $name)); - return !self::check($name); + if (static::check($name)) { + static::_overwrite($_SESSION, Hash::remove($_SESSION, $name)); + return !static::check($name); } return false; } @@ -301,10 +301,10 @@ protected static function _overwrite(&$old, $new) { * @return string Error as string */ protected static function _error($errorNumber) { - if (!is_array(self::$error) || !array_key_exists($errorNumber, self::$error)) { + if (!is_array(static::$error) || !array_key_exists($errorNumber, static::$error)) { return false; } - return self::$error[$errorNumber]; + return static::$error[$errorNumber]; } /** @@ -313,8 +313,8 @@ protected static function _error($errorNumber) { * @return mixed Error description as a string, or false. */ public static function error() { - if (self::$lastError) { - return self::_error(self::$lastError); + if (static::$lastError) { + return static::_error(static::$lastError); } return false; } @@ -325,32 +325,32 @@ public static function error() { * @return bool Success */ public static function valid() { - if (self::start() && self::read('Config')) { - if (self::_validAgentAndTime() && self::$error === false) { - self::$valid = true; + if (static::start() && static::read('Config')) { + if (static::_validAgentAndTime() && static::$error === false) { + static::$valid = true; } else { - self::$valid = false; - self::_setError(1, 'Session Highjacking Attempted !!!'); + static::$valid = false; + static::_setError(1, 'Session Highjacking Attempted !!!'); } } - return self::$valid; + return static::$valid; } /** * Tests that the user agent is valid and that the session hasn't 'timed out'. - * Since timeouts are implemented in CakeSession it checks the current self::$time + * Since timeouts are implemented in CakeSession it checks the current static::$time * against the time the session is set to expire. The User agent is only checked * if Session.checkAgent == true. * * @return bool */ protected static function _validAgentAndTime() { - $config = self::read('Config'); + $config = static::read('Config'); $validAgent = ( Configure::read('Session.checkAgent') === false || - isset($config['userAgent']) && self::$_userAgent === $config['userAgent'] + isset($config['userAgent']) && static::$_userAgent === $config['userAgent'] ); - return ($validAgent && self::$time <= $config['time']); + return ($validAgent && static::$time <= $config['time']); } /** @@ -361,12 +361,12 @@ protected static function _validAgentAndTime() { */ public static function userAgent($userAgent = null) { if ($userAgent) { - self::$_userAgent = $userAgent; + static::$_userAgent = $userAgent; } - if (empty(self::$_userAgent)) { - CakeSession::init(self::$path); + if (empty(static::$_userAgent)) { + CakeSession::init(static::$path); } - return self::$_userAgent; + return static::$_userAgent; } /** @@ -380,11 +380,11 @@ public static function read($name = null) { if (empty($name) && $name !== null) { return null; } - if (!self::_hasSession() || !self::start()) { + if (!static::_hasSession() || !static::start()) { return null; } if ($name === null) { - return self::_returnSessionVars(); + return static::_returnSessionVars(); } $result = Hash::get($_SESSION, $name); @@ -403,7 +403,7 @@ protected static function _returnSessionVars() { if (!empty($_SESSION)) { return $_SESSION; } - self::_setError(2, 'No Session vars set'); + static::_setError(2, 'No Session vars set'); return false; } @@ -415,7 +415,7 @@ protected static function _returnSessionVars() { * @return bool True if the write was successful, false if the write failed */ public static function write($name, $value = null) { - if (empty($name) || !self::start()) { + if (empty($name) || !static::start()) { return false; } @@ -424,7 +424,7 @@ public static function write($name, $value = null) { $write = array($name => $value); } foreach ($write as $key => $val) { - self::_overwrite($_SESSION, Hash::insert($_SESSION, $key, $val)); + static::_overwrite($_SESSION, Hash::insert($_SESSION, $key, $val)); if (Hash::get($_SESSION, $key) !== $val) { return false; } @@ -443,9 +443,9 @@ public static function consume($name) { if (empty($name)) { return null; } - $value = self::read($name); + $value = static::read($name); if ($value !== null) { - self::_overwrite($_SESSION, Hash::remove($_SESSION, $name)); + static::_overwrite($_SESSION, Hash::remove($_SESSION, $name)); } return $value; } @@ -456,17 +456,17 @@ public static function consume($name) { * @return void */ public static function destroy() { - if (!self::started()) { - self::_startSession(); + if (!static::started()) { + static::_startSession(); } - if (self::started()) { + if (static::started()) { session_destroy(); } $_SESSION = null; - self::$id = null; - self::$_cookieName = null; + static::$id = null; + static::$_cookieName = null; } /** @@ -484,8 +484,8 @@ public static function clear($renew = true) { } $_SESSION = null; - self::$id = null; - self::renew(); + static::$id = null; + static::renew(); } /** @@ -500,7 +500,7 @@ protected static function _configureSession() { $sessionConfig = Configure::read('Session'); if (isset($sessionConfig['defaults'])) { - $defaults = self::_defaultConfig($sessionConfig['defaults']); + $defaults = static::_defaultConfig($sessionConfig['defaults']); if ($defaults) { $sessionConfig = Hash::merge($defaults, $sessionConfig); } @@ -518,7 +518,7 @@ protected static function _configureSession() { if (!isset($sessionConfig['ini']['session.name'])) { $sessionConfig['ini']['session.name'] = $sessionConfig['cookie']; } - self::$_cookieName = $sessionConfig['ini']['session.name']; + static::$_cookieName = $sessionConfig['ini']['session.name']; if (!empty($sessionConfig['handler'])) { $sessionConfig['ini']['session.save_handler'] = 'user'; @@ -548,7 +548,7 @@ protected static function _configureSession() { call_user_func_array('session_set_save_handler', $sessionConfig['handler']); } if (!empty($sessionConfig['handler']['engine'])) { - $handler = self::_getHandler($sessionConfig['handler']['engine']); + $handler = static::_getHandler($sessionConfig['handler']['engine']); session_set_save_handler( array($handler, 'open'), array($handler, 'close'), @@ -559,7 +559,7 @@ protected static function _configureSession() { ); } Configure::write('Session', $sessionConfig); - self::$sessionTime = self::$time + ($sessionConfig['timeout'] * 60); + static::$sessionTime = static::$time + ($sessionConfig['timeout'] * 60); } /** @@ -568,14 +568,14 @@ protected static function _configureSession() { * @return string */ protected static function _cookieName() { - if (self::$_cookieName !== null) { - return self::$_cookieName; + if (static::$_cookieName !== null) { + return static::$_cookieName; } - self::init(); - self::_configureSession(); + static::init(); + static::_configureSession(); - return self::$_cookieName = session_name(); + return static::$_cookieName = session_name(); } /** @@ -584,7 +584,7 @@ protected static function _cookieName() { * @return bool */ protected static function _hasSession() { - return self::started() || isset($_COOKIE[self::_cookieName()]); + return static::started() || isset($_COOKIE[static::_cookieName()]); } /** @@ -620,7 +620,7 @@ protected static function _defaultConfig($name) { 'timeout' => 240, 'ini' => array( 'session.use_trans_sid' => 0, - 'session.cookie_path' => self::$path + 'session.cookie_path' => static::$path ) ), 'cake' => array( @@ -631,7 +631,7 @@ protected static function _defaultConfig($name) { 'url_rewriter.tags' => '', 'session.serialize_handler' => 'php', 'session.use_cookies' => 1, - 'session.cookie_path' => self::$path, + 'session.cookie_path' => static::$path, 'session.save_path' => TMP . 'sessions', 'session.save_handler' => 'files' ) @@ -643,7 +643,7 @@ protected static function _defaultConfig($name) { 'session.use_trans_sid' => 0, 'url_rewriter.tags' => '', 'session.use_cookies' => 1, - 'session.cookie_path' => self::$path, + 'session.cookie_path' => static::$path, 'session.save_handler' => 'user', ), 'handler' => array( @@ -658,7 +658,7 @@ protected static function _defaultConfig($name) { 'session.use_trans_sid' => 0, 'url_rewriter.tags' => '', 'session.use_cookies' => 1, - 'session.cookie_path' => self::$path, + 'session.cookie_path' => static::$path, 'session.save_handler' => 'user', 'session.serialize_handler' => 'php', ), @@ -680,9 +680,9 @@ protected static function _defaultConfig($name) { * @return bool Success */ protected static function _startSession() { - self::init(); + static::init(); session_write_close(); - self::_configureSession(); + static::_configureSession(); if (headers_sent()) { if (empty($_SESSION)) { @@ -702,31 +702,31 @@ protected static function _startSession() { * @return void */ protected static function _checkValid() { - $config = self::read('Config'); + $config = static::read('Config'); if ($config) { $sessionConfig = Configure::read('Session'); - if (self::valid()) { - self::write('Config.time', self::$sessionTime); + if (static::valid()) { + static::write('Config.time', static::$sessionTime); if (isset($sessionConfig['autoRegenerate']) && $sessionConfig['autoRegenerate'] === true) { $check = $config['countdown']; $check -= 1; - self::write('Config.countdown', $check); + static::write('Config.countdown', $check); if ($check < 1) { - self::renew(); - self::write('Config.countdown', self::$requestCountdown); + static::renew(); + static::write('Config.countdown', static::$requestCountdown); } } } else { $_SESSION = array(); - self::destroy(); - self::_setError(1, 'Session Highjacking Attempted !!!'); - self::_startSession(); - self::_writeConfig(); + static::destroy(); + static::_setError(1, 'Session Highjacking Attempted !!!'); + static::_startSession(); + static::_writeConfig(); } } else { - self::_writeConfig(); + static::_writeConfig(); } } @@ -736,9 +736,9 @@ protected static function _checkValid() { * @return void */ protected static function _writeConfig() { - self::write('Config.userAgent', self::$_userAgent); - self::write('Config.time', self::$sessionTime); - self::write('Config.countdown', self::$requestCountdown); + static::write('Config.userAgent', static::$_userAgent); + static::write('Config.time', static::$sessionTime); + static::write('Config.countdown', static::$requestCountdown); } /** @@ -751,7 +751,7 @@ public static function renew() { return; } if (isset($_COOKIE[session_name()])) { - setcookie(Configure::read('Session.cookie'), '', time() - 42000, self::$path); + setcookie(Configure::read('Session.cookie'), '', time() - 42000, static::$path); } session_regenerate_id(true); } @@ -764,11 +764,11 @@ public static function renew() { * @return void */ protected static function _setError($errorNumber, $errorMessage) { - if (self::$error === false) { - self::$error = array(); + if (static::$error === false) { + static::$error = array(); } - self::$error[$errorNumber] = $errorMessage; - self::$lastError = $errorNumber; + static::$error[$errorNumber] = $errorMessage; + static::$lastError = $errorNumber; } } diff --git a/lib/Cake/Model/Datasource/Database/Sqlserver.php b/lib/Cake/Model/Datasource/Database/Sqlserver.php index c9cfdf2debc..cb66267b585 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlserver.php +++ b/lib/Cake/Model/Datasource/Database/Sqlserver.php @@ -544,7 +544,7 @@ public function renderStatement($type, $data) { $page = (int)($limitOffset[1] / $limitOffset[2]); $offset = (int)($limitOffset[2] * $page); - $rowCounter = self::ROW_COUNTER; + $rowCounter = static::ROW_COUNTER; $sql = "SELECT {$limit} * FROM ( SELECT {$fields}, ROW_NUMBER() OVER ({$order}) AS {$rowCounter} FROM {$table} {$alias} {$joins} {$conditions} {$group} @@ -634,7 +634,7 @@ public function fetchResult() { $resultRow = array(); foreach ($this->map as $col => $meta) { list($table, $column, $type) = $meta; - if ($table === 0 && $column === self::ROW_COUNTER) { + if ($table === 0 && $column === static::ROW_COUNTER) { continue; } $resultRow[$table][$column] = $row[$col]; diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 137c4e685d5..927a6e369fb 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -759,7 +759,7 @@ public function field($name, $sql) { */ public function flushMethodCache() { $this->_methodCacheChange = true; - self::$methodCache = array(); + static::$methodCache = array(); } /** @@ -778,14 +778,14 @@ public function cacheMethod($method, $key, $value = null) { if ($this->cacheMethods === false) { return $value; } - if (!$this->_methodCacheChange && empty(self::$methodCache)) { - self::$methodCache = (array)Cache::read('method_cache', '_cake_core_'); + if (!$this->_methodCacheChange && empty(static::$methodCache)) { + static::$methodCache = (array)Cache::read('method_cache', '_cake_core_'); } if ($value === null) { - return (isset(self::$methodCache[$method][$key])) ? self::$methodCache[$method][$key] : null; + return (isset(static::$methodCache[$method][$key])) ? static::$methodCache[$method][$key] : null; } $this->_methodCacheChange = true; - return self::$methodCache[$method][$key] = $value; + return static::$methodCache[$method][$key] = $value; } /** @@ -3571,7 +3571,7 @@ public function getQueryCache($sql, $params = array()) { */ public function __destruct() { if ($this->_methodCacheChange) { - Cache::write('method_cache', self::$methodCache, '_cake_core_'); + Cache::write('method_cache', static::$methodCache, '_cake_core_'); } parent::__destruct(); } diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 94272851078..f14373370f3 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -853,7 +853,7 @@ public function parseAccept() { * @return mixed If a $language is provided, a boolean. Otherwise the array of accepted languages. */ public static function acceptLanguage($language = null) { - $raw = self::_parseAcceptWithQualifier(self::header('Accept-Language')); + $raw = static::_parseAcceptWithQualifier(static::header('Accept-Language')); $accept = array(); foreach ($raw as $languages) { foreach ($languages as &$lang) { diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index 4e984f45393..823c85f65fc 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -781,7 +781,7 @@ public function getHeaders($include = array()) { $headers += $this->_headers; if (!isset($headers['X-Mailer'])) { - $headers['X-Mailer'] = self::EMAIL_CLIENT; + $headers['X-Mailer'] = static::EMAIL_CLIENT; } if (!isset($headers['Date'])) { $headers['Date'] = date(DATE_RFC2822); @@ -1113,9 +1113,9 @@ public function addAttachments($attachments) { */ public function message($type = null) { switch ($type) { - case self::MESSAGE_HTML: + case static::MESSAGE_HTML: return $this->_htmlMessage; - case self::MESSAGE_TEXT: + case static::MESSAGE_TEXT: return $this->_textMessage; } return $this->_message; @@ -1315,7 +1315,7 @@ public function reset() { $this->headerCharset = null; $this->_attachments = array(); $this->_config = array(); - $this->_emailPattern = self::EMAIL_PATTERN; + $this->_emailPattern = static::EMAIL_PATTERN; return $this; } diff --git a/lib/Cake/Network/Http/BasicAuthentication.php b/lib/Cake/Network/Http/BasicAuthentication.php index 05588822508..df33252ff42 100644 --- a/lib/Cake/Network/Http/BasicAuthentication.php +++ b/lib/Cake/Network/Http/BasicAuthentication.php @@ -33,7 +33,7 @@ class BasicAuthentication { */ public static function authentication(HttpSocket $http, &$authInfo) { if (isset($authInfo['user'], $authInfo['pass'])) { - $http->request['header']['Authorization'] = self::_generateHeader($authInfo['user'], $authInfo['pass']); + $http->request['header']['Authorization'] = static::_generateHeader($authInfo['user'], $authInfo['pass']); } } @@ -47,7 +47,7 @@ public static function authentication(HttpSocket $http, &$authInfo) { */ public static function proxyAuthentication(HttpSocket $http, &$proxyInfo) { if (isset($proxyInfo['user'], $proxyInfo['pass'])) { - $http->request['header']['Proxy-Authorization'] = self::_generateHeader($proxyInfo['user'], $proxyInfo['pass']); + $http->request['header']['Proxy-Authorization'] = static::_generateHeader($proxyInfo['user'], $proxyInfo['pass']); } } diff --git a/lib/Cake/Network/Http/DigestAuthentication.php b/lib/Cake/Network/Http/DigestAuthentication.php index 2c43a3184ca..f38cfc0faaa 100644 --- a/lib/Cake/Network/Http/DigestAuthentication.php +++ b/lib/Cake/Network/Http/DigestAuthentication.php @@ -33,10 +33,10 @@ class DigestAuthentication { */ public static function authentication(HttpSocket $http, &$authInfo) { if (isset($authInfo['user'], $authInfo['pass'])) { - if (!isset($authInfo['realm']) && !self::_getServerInformation($http, $authInfo)) { + if (!isset($authInfo['realm']) && !static::_getServerInformation($http, $authInfo)) { return; } - $http->request['header']['Authorization'] = self::_generateHeader($http, $authInfo); + $http->request['header']['Authorization'] = static::_generateHeader($http, $authInfo); } } diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 595192f97f3..cfc9bbd1cad 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -213,10 +213,10 @@ class Router { */ public static function defaultRouteClass($routeClass = null) { if ($routeClass === null) { - return self::$_routeClass; + return static::$_routeClass; } - self::$_routeClass = self::_validateRouteClass($routeClass); + static::$_routeClass = static::_validateRouteClass($routeClass); } /** @@ -243,7 +243,7 @@ protected static function _validateRouteClass($routeClass) { protected static function _setPrefixes() { $routing = Configure::read('Routing'); if (!empty($routing['prefixes'])) { - self::$_prefixes = array_merge(self::$_prefixes, (array)$routing['prefixes']); + static::$_prefixes = array_merge(static::$_prefixes, (array)$routing['prefixes']); } } @@ -254,7 +254,7 @@ protected static function _setPrefixes() { * @see Router::$_namedExpressions */ public static function getNamedExpressions() { - return self::$_namedExpressions; + return static::$_namedExpressions; } /** @@ -266,9 +266,9 @@ public static function getNamedExpressions() { */ public static function resourceMap($resourceMap = null) { if ($resourceMap === null) { - return self::$_resourceMap; + return static::$_resourceMap; } - self::$_resourceMap = $resourceMap; + static::$_resourceMap = $resourceMap; } /** @@ -342,9 +342,9 @@ public static function resourceMap($resourceMap = null) { * @throws RouterException */ public static function connect($route, $defaults = array(), $options = array()) { - self::$initialized = true; + static::$initialized = true; - foreach (self::$_prefixes as $prefix) { + foreach (static::$_prefixes as $prefix) { if (isset($defaults[$prefix])) { if ($defaults[$prefix]) { $defaults['prefix'] = $prefix; @@ -354,28 +354,28 @@ public static function connect($route, $defaults = array(), $options = array()) break; } } - if (isset($defaults['prefix']) && !in_array($defaults['prefix'], self::$_prefixes)) { - self::$_prefixes[] = $defaults['prefix']; + if (isset($defaults['prefix']) && !in_array($defaults['prefix'], static::$_prefixes)) { + static::$_prefixes[] = $defaults['prefix']; } $defaults += array('plugin' => null); if (empty($options['action'])) { $defaults += array('action' => 'index'); } - $routeClass = self::$_routeClass; + $routeClass = static::$_routeClass; if (isset($options['routeClass'])) { if (strpos($options['routeClass'], '.') === false) { $routeClass = $options['routeClass']; } else { list(, $routeClass) = pluginSplit($options['routeClass'], true); } - $routeClass = self::_validateRouteClass($routeClass); + $routeClass = static::_validateRouteClass($routeClass); unset($options['routeClass']); } if ($routeClass === 'RedirectRoute' && isset($defaults['redirect'])) { $defaults = $defaults['redirect']; } - self::$routes[] = new $routeClass($route, $defaults, $options); - return self::$routes; + static::$routes[] = new $routeClass($route, $defaults, $options); + return static::$routes; } /** @@ -416,7 +416,7 @@ public static function redirect($route, $url, $options = array()) { if (is_string($url)) { $url = array('redirect' => $url); } - return self::connect($route, $url, $options); + return static::connect($route, $url, $options); } /** @@ -473,7 +473,7 @@ public static function redirect($route, $url, $options = array()) { */ public static function connectNamed($named, $options = array()) { if (isset($options['separator'])) { - self::$_namedConfig['separator'] = $options['separator']; + static::$_namedConfig['separator'] = $options['separator']; unset($options['separator']); } @@ -484,23 +484,23 @@ public static function connectNamed($named, $options = array()) { $options += array('default' => false, 'reset' => false, 'greedy' => true); } - if ($options['reset'] || self::$_namedConfig['rules'] === false) { - self::$_namedConfig['rules'] = array(); + if ($options['reset'] || static::$_namedConfig['rules'] === false) { + static::$_namedConfig['rules'] = array(); } if ($options['default']) { - $named = array_merge($named, self::$_namedConfig['default']); + $named = array_merge($named, static::$_namedConfig['default']); } foreach ($named as $key => $val) { if (is_numeric($key)) { - self::$_namedConfig['rules'][$val] = true; + static::$_namedConfig['rules'][$val] = true; } else { - self::$_namedConfig['rules'][$key] = $val; + static::$_namedConfig['rules'][$key] = $val; } } - self::$_namedConfig['greedyNamed'] = $options['greedy']; - return self::$_namedConfig; + static::$_namedConfig['greedyNamed'] = $options['greedy']; + return static::$_namedConfig; } /** @@ -510,7 +510,7 @@ public static function connectNamed($named, $options = array()) { * @see Router::$_namedConfig */ public static function namedConfig() { - return self::$_namedConfig; + return static::$_namedConfig; } /** @@ -533,7 +533,7 @@ public static function mapResources($controller, $options = array()) { $options += array( 'connectOptions' => array(), 'prefix' => '/', - 'id' => self::ID . '|' . self::UUID + 'id' => static::ID . '|' . static::UUID ); $prefix = $options['prefix']; @@ -554,7 +554,7 @@ public static function mapResources($controller, $options = array()) { $prefix = '/' . $plugin . '/'; } - foreach (self::$_resourceMap as $params) { + foreach (static::$_resourceMap as $params) { $url = $prefix . $urlName . (($params['id']) ? '/:id' : ''); Router::connect($url, @@ -570,9 +570,9 @@ public static function mapResources($controller, $options = array()) { ) ); } - self::$_resourceMapped[] = $urlName; + static::$_resourceMapped[] = $urlName; } - return self::$_resourceMapped; + return static::$_resourceMapped; } /** @@ -581,7 +581,7 @@ public static function mapResources($controller, $options = array()) { * @return array A list of prefixes used in connected routes */ public static function prefixes() { - return self::$_prefixes; + return static::$_prefixes; } /** @@ -591,8 +591,8 @@ public static function prefixes() { * @return array Parsed elements from URL */ public static function parse($url) { - if (!self::$initialized) { - self::_loadRoutes(); + if (!static::$initialized) { + static::_loadRoutes(); } $ext = null; @@ -606,11 +606,11 @@ public static function parse($url) { parse_str($queryParameters, $queryParameters); } - extract(self::_parseExtension($url)); + extract(static::_parseExtension($url)); - foreach (self::$routes as $route) { + foreach (static::$routes as $route) { if (($r = $route->parse($url)) !== false) { - self::$_currentRoute[] = $route; + static::$_currentRoute[] = $route; $out = $r; break; } @@ -638,14 +638,14 @@ public static function parse($url) { protected static function _parseExtension($url) { $ext = null; - if (self::$_parseExtensions) { + if (static::$_parseExtensions) { if (preg_match('/\.[0-9a-zA-Z]*$/', $url, $match) === 1) { $match = substr($match[0], 1); - if (empty(self::$_validExtensions)) { + if (empty(static::$_validExtensions)) { $url = substr($url, 0, strpos($url, '.' . $match)); $ext = $match; } else { - foreach (self::$_validExtensions as $name) { + foreach (static::$_validExtensions as $name) { if (strcasecmp($name, $match) === 0) { $url = substr($url, 0, strpos($url, '.' . $name)); $ext = $match; @@ -674,13 +674,13 @@ protected static function _parseExtension($url) { */ public static function setRequestInfo($request) { if ($request instanceof CakeRequest) { - self::$_requests[] = $request; + static::$_requests[] = $request; } else { $requestObj = new CakeRequest(); $request += array(array(), array()); $request[0] += array('controller' => false, 'action' => false, 'plugin' => null); $requestObj->addParams($request[0])->addPaths($request[1]); - self::$_requests[] = $requestObj; + static::$_requests[] = $requestObj; } } @@ -692,7 +692,7 @@ public static function setRequestInfo($request) { * @see Object::requestAction() */ public static function popRequest() { - return array_pop(self::$_requests); + return array_pop(static::$_requests); } /** @@ -703,10 +703,10 @@ public static function popRequest() { */ public static function getRequest($current = false) { if ($current) { - $i = count(self::$_requests) - 1; - return isset(self::$_requests[$i]) ? self::$_requests[$i] : null; + $i = count(static::$_requests) - 1; + return isset(static::$_requests[$i]) ? static::$_requests[$i] : null; } - return isset(self::$_requests[0]) ? self::$_requests[0] : null; + return isset(static::$_requests[0]) ? static::$_requests[0] : null; } /** @@ -716,11 +716,11 @@ public static function getRequest($current = false) { * @return array Parameter information */ public static function getParams($current = false) { - if ($current && self::$_requests) { - return self::$_requests[count(self::$_requests) - 1]->params; + if ($current && static::$_requests) { + return static::$_requests[count(static::$_requests) - 1]->params; } - if (isset(self::$_requests[0])) { - return self::$_requests[0]->params; + if (isset(static::$_requests[0])) { + return static::$_requests[0]->params; } return array(); } @@ -748,12 +748,12 @@ public static function getParam($name = 'controller', $current = false) { */ public static function getPaths($current = false) { if ($current) { - return self::$_requests[count(self::$_requests) - 1]; + return static::$_requests[count(static::$_requests) - 1]; } - if (!isset(self::$_requests[0])) { + if (!isset(static::$_requests[0])) { return array('base' => null); } - return array('base' => self::$_requests[0]->base); + return array('base' => static::$_requests[0]->base); } /** @@ -763,17 +763,17 @@ public static function getPaths($current = false) { * @return void */ public static function reload() { - if (empty(self::$_initialState)) { - self::$_initialState = get_class_vars('Router'); - self::_setPrefixes(); + if (empty(static::$_initialState)) { + static::$_initialState = get_class_vars('Router'); + static::_setPrefixes(); return; } - foreach (self::$_initialState as $key => $val) { + foreach (static::$_initialState as $key => $val) { if ($key !== '_initialState') { - self::${$key} = $val; + static::${$key} = $val; } } - self::_setPrefixes(); + static::_setPrefixes(); } /** @@ -785,14 +785,14 @@ public static function reload() { */ public static function promote($which = null) { if ($which === null) { - $which = count(self::$routes) - 1; + $which = count(static::$routes) - 1; } - if (!isset(self::$routes[$which])) { + if (!isset(static::$routes[$which])) { return false; } - $route =& self::$routes[$which]; - unset(self::$routes[$which]); - array_unshift(self::$routes, $route); + $route =& static::$routes[$which]; + unset(static::$routes[$which]); + array_unshift(static::$routes, $route); return true; } @@ -826,8 +826,8 @@ public static function promote($which = null) { * @return string Full translated URL with base path. */ public static function url($url = null, $full = false) { - if (!self::$initialized) { - self::_loadRoutes(); + if (!static::$initialized) { + static::_loadRoutes(); } $params = array('plugin' => null, 'controller' => null, 'action' => 'index'); @@ -839,8 +839,8 @@ public static function url($url = null, $full = false) { } $path = array('base' => null); - if (!empty(self::$_requests)) { - $request = self::$_requests[count(self::$_requests) - 1]; + if (!empty(static::$_requests)) { + $request = static::$_requests[count(static::$_requests) - 1]; $params = $request->params; $path = array('base' => $request->base, 'here' => $request->here); } @@ -854,7 +854,7 @@ public static function url($url = null, $full = false) { if (empty($url)) { $output = isset($path['here']) ? $path['here'] : '/'; if ($full) { - $output = self::fullBaseUrl() . $output; + $output = static::fullBaseUrl() . $output; } return $output; } elseif (is_array($url)) { @@ -886,8 +886,8 @@ public static function url($url = null, $full = false) { } } - $prefixExists = (array_intersect_key($url, array_flip(self::$_prefixes))); - foreach (self::$_prefixes as $prefix) { + $prefixExists = (array_intersect_key($url, array_flip(static::$_prefixes))); + foreach (static::$_prefixes as $prefix) { if (!empty($params[$prefix]) && !$prefixExists) { $url[$prefix] = true; } elseif (isset($url[$prefix]) && !$url[$prefix]) { @@ -902,7 +902,7 @@ public static function url($url = null, $full = false) { $match = false; - foreach (self::$routes as $route) { + foreach (static::$routes as $route) { $originalUrl = $url; $url = $route->persistParams($url, $params); @@ -914,7 +914,7 @@ public static function url($url = null, $full = false) { $url = $originalUrl; } if ($match === false) { - $output = self::_handleNoRoute($url); + $output = static::_handleNoRoute($url); } } else { if (preg_match('/^([a-z][a-z0-9.+\-]+:|:?\/\/|[#?])/i', $url)) { @@ -923,7 +923,7 @@ public static function url($url = null, $full = false) { if (substr($url, 0, 1) === '/') { $output = substr($url, 1); } else { - foreach (self::$_prefixes as $prefix) { + foreach (static::$_prefixes as $prefix) { if (isset($params[$prefix])) { $output .= $prefix . '/'; break; @@ -940,13 +940,13 @@ public static function url($url = null, $full = false) { $output = str_replace('//', '/', $base . '/' . $output); if ($full) { - $output = self::fullBaseUrl() . $output; + $output = static::fullBaseUrl() . $output; } if (!empty($extension)) { $output = rtrim($output, '/'); } } - return $output . $extension . self::queryString($q, array(), $escape) . $frag; + return $output . $extension . static::queryString($q, array(), $escape) . $frag; } /** @@ -966,13 +966,13 @@ public static function url($url = null, $full = false) { */ public static function fullBaseUrl($base = null) { if ($base !== null) { - self::$_fullBaseUrl = $base; + static::$_fullBaseUrl = $base; Configure::write('App.fullBaseUrl', $base); } - if (empty(self::$_fullBaseUrl)) { - self::$_fullBaseUrl = Configure::read('App.fullBaseUrl'); + if (empty(static::$_fullBaseUrl)) { + static::$_fullBaseUrl = Configure::read('App.fullBaseUrl'); } - return self::$_fullBaseUrl; + return static::$_fullBaseUrl; } /** @@ -987,7 +987,7 @@ protected static function _handleNoRoute($url) { $named = $args = array(); $skip = array_merge( array('bare', 'action', 'controller', 'plugin', 'prefix'), - self::$_prefixes + static::$_prefixes ); $keys = array_values(array_diff(array_keys($url), $skip)); @@ -1002,7 +1002,7 @@ protected static function _handleNoRoute($url) { } list($args, $named) = array(Hash::filter($args), Hash::filter($named)); - foreach (self::$_prefixes as $prefix) { + foreach (static::$_prefixes as $prefix) { $prefixed = $prefix . '_'; if (!empty($url[$prefix]) && strpos($url['action'], $prefixed) === 0) { $url['action'] = substr($url['action'], strlen($prefixed) * -1); @@ -1020,7 +1020,7 @@ protected static function _handleNoRoute($url) { array_unshift($urlOut, $url['plugin']); } - foreach (self::$_prefixes as $prefix) { + foreach (static::$_prefixes as $prefix) { if (isset($url[$prefix])) { array_unshift($urlOut, $prefix); break; @@ -1037,10 +1037,10 @@ protected static function _handleNoRoute($url) { if (is_array($value)) { $flattend = Hash::flatten($value, '%5D%5B'); foreach ($flattend as $namedKey => $namedValue) { - $output .= '/' . $name . "%5B{$namedKey}%5D" . self::$_namedConfig['separator'] . rawurlencode($namedValue); + $output .= '/' . $name . "%5B{$namedKey}%5D" . static::$_namedConfig['separator'] . rawurlencode($namedValue); } } else { - $output .= '/' . $name . self::$_namedConfig['separator'] . rawurlencode($value); + $output .= '/' . $name . static::$_namedConfig['separator'] . rawurlencode($value); } } } @@ -1163,7 +1163,7 @@ public static function normalize($url = '/') { * @return CakeRoute Matching route object. */ public static function requestRoute() { - return self::$_currentRoute[0]; + return static::$_currentRoute[0]; } /** @@ -1172,8 +1172,8 @@ public static function requestRoute() { * @return CakeRoute Matching route object. */ public static function currentRoute() { - $count = count(self::$_currentRoute) - 1; - return ($count >= 0) ? self::$_currentRoute[$count] : false; + $count = count(static::$_currentRoute) - 1; + return ($count >= 0) ? static::$_currentRoute[$count] : false; } /** @@ -1215,9 +1215,9 @@ public static function stripPlugin($base, $plugin = null) { * @see RequestHandler::startup() */ public static function parseExtensions() { - self::$_parseExtensions = true; + static::$_parseExtensions = true; if (func_num_args() > 0) { - self::setExtensions(func_get_args(), false); + static::setExtensions(func_get_args(), false); } } @@ -1230,11 +1230,11 @@ public static function parseExtensions() { * @return array Array of extensions Router is configured to parse. */ public static function extensions() { - if (!self::$initialized) { - self::_loadRoutes(); + if (!static::$initialized) { + static::_loadRoutes(); } - return self::$_validExtensions; + return static::$_validExtensions; } /** @@ -1248,12 +1248,12 @@ public static function extensions() { */ public static function setExtensions($extensions, $merge = true) { if (!is_array($extensions)) { - return self::$_validExtensions; + return static::$_validExtensions; } if (!$merge) { - return self::$_validExtensions = $extensions; + return static::$_validExtensions = $extensions; } - return self::$_validExtensions = array_merge(self::$_validExtensions, $extensions); + return static::$_validExtensions = array_merge(static::$_validExtensions, $extensions); } /** @@ -1262,7 +1262,7 @@ public static function setExtensions($extensions, $merge = true) { * @return void */ protected static function _loadRoutes() { - self::$initialized = true; + static::$initialized = true; include APP . 'Config' . DS . 'routes.php'; } diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/BlowfishAuthenticateTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/BlowfishAuthenticateTest.php index 747f0c9e8eb..7fc200db114 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/BlowfishAuthenticateTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/BlowfishAuthenticateTest.php @@ -200,7 +200,7 @@ public function testPluginModel() { 'username' => 'gwoo', 'created' => '2007-03-17 01:16:23' ); - $this->assertEquals(self::date(), $result['updated']); + $this->assertEquals(static::date(), $result['updated']); unset($result['updated']); $this->assertEquals($expected, $result); CakePlugin::unload(); diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/FormAuthenticateTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/FormAuthenticateTest.php index a8a17b2b860..9b0a196f1af 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/FormAuthenticateTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/FormAuthenticateTest.php @@ -288,7 +288,7 @@ public function testPluginModel() { 'username' => 'gwoo', 'created' => '2007-03-17 01:16:23' ); - $this->assertEquals(self::date(), $result['updated']); + $this->assertEquals(static::date(), $result['updated']); unset($result['updated']); $this->assertEquals($expected, $result); CakePlugin::unload(); diff --git a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php index 233116f3074..b66252f2410 100644 --- a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php @@ -125,7 +125,7 @@ protected function _stop($status = 0) { } public static function clearUser() { - self::$_user = array(); + static::$_user = array(); } } diff --git a/lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php b/lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php index c3dd8c1b135..7be4282b30e 100644 --- a/lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php @@ -77,7 +77,7 @@ public function send(CakeEmail $email) { $last .= sprintf("%s\n\n%s", 'Message:', $message); $last .= ''; - self::$lastEmail = $last; + static::$lastEmail = $last; return true; } @@ -149,7 +149,7 @@ public function setUp() { $this->Controller->Components->init($this->Controller); $this->Controller->EmailTest->initialize($this->Controller, array()); - self::$sentDate = date(DATE_RFC2822); + static::$sentDate = date(DATE_RFC2822); App::build(array( 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) @@ -170,7 +170,7 @@ public function testSendFormats() { $this->Controller->EmailTest->delivery = 'DebugComp'; $this->Controller->EmailTest->messageId = false; - $date = self::$sentDate; + $date = static::$sentDate; $message = <<To: postmaster@example.com From: noreply@example.com @@ -217,7 +217,7 @@ public function testTemplates() { $this->Controller->EmailTest->delivery = 'DebugComp'; $this->Controller->EmailTest->messageId = false; - $date = self::$sentDate; + $date = static::$sentDate; $header = <<assertRegExp('/From: noreply@example.com\n/', $result); $this->assertRegExp('/Cc: cc@example.com\n/', $result); $this->assertRegExp('/Bcc: bcc@example.com\n/', $result); - $this->assertRegExp('/Date: ' . preg_quote(self::$sentDate) . '\n/', $result); + $this->assertRegExp('/Date: ' . preg_quote(static::$sentDate) . '\n/', $result); $this->assertRegExp('/X-Mailer: CakePHP Email Component\n/', $result); $this->assertRegExp('/Content-Type: text\/plain; charset=UTF-8\n/', $result); $this->assertRegExp('/Content-Transfer-Encoding: 8bitMessage:\n/', $result); @@ -392,7 +392,7 @@ public function testSendDebugWithNoSessions() { $this->assertRegExp('/Subject: Cake Debug Test\n/', $result); $this->assertRegExp('/Reply-To: noreply@example.com\n/', $result); $this->assertRegExp('/From: noreply@example.com\n/', $result); - $this->assertRegExp('/Date: ' . preg_quote(self::$sentDate) . '\n/', $result); + $this->assertRegExp('/Date: ' . preg_quote(static::$sentDate) . '\n/', $result); $this->assertRegExp('/X-Mailer: CakePHP Email Component\n/', $result); $this->assertRegExp('/Content-Type: text\/plain; charset=UTF-8\n/', $result); $this->assertRegExp('/Content-Transfer-Encoding: 8bitMessage:\n/', $result); @@ -563,7 +563,7 @@ public function testDateProperty() { $this->Controller->EmailTest->to = 'postmaster@example.com'; $this->Controller->EmailTest->from = 'noreply@example.com'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; - $this->Controller->EmailTest->date = self::$sentDate = 'Today!'; + $this->Controller->EmailTest->date = static::$sentDate = 'Today!'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'DebugComp'; diff --git a/lib/Cake/Test/Case/Controller/Component/SessionComponentTest.php b/lib/Cake/Test/Case/Controller/Component/SessionComponentTest.php index 214ee9d3a26..fa7bae08b3d 100644 --- a/lib/Cake/Test/Case/Controller/Component/SessionComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/SessionComponentTest.php @@ -91,7 +91,7 @@ class SessionComponentTest extends CakeTestCase { * @return void */ public static function setupBeforeClass() { - self::$_sessionBackup = Configure::read('Session'); + static::$_sessionBackup = Configure::read('Session'); Configure::write('Session', array( 'defaults' => 'php', 'timeout' => 100, @@ -105,7 +105,7 @@ public static function setupBeforeClass() { * @return void */ public static function teardownAfterClass() { - Configure::write('Session', self::$_sessionBackup); + Configure::write('Session', static::$_sessionBackup); } /** diff --git a/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php b/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php index c9a06b7fc1c..dc622e10559 100644 --- a/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php +++ b/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php @@ -35,7 +35,7 @@ class TestConsoleLog extends ConsoleLog { class TestCakeLog extends CakeLog { public static function replace($key, &$engine) { - self::$_Collection->{$key} = $engine; + static::$_Collection->{$key} = $engine; } } diff --git a/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php b/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php index 2c691844d32..41111a898b0 100644 --- a/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php @@ -28,11 +28,11 @@ class TestCakeSession extends CakeSession { public static function setUserAgent($value) { - self::$_userAgent = $value; + static::$_userAgent = $value; } public static function setHost($host) { - self::_setHost($host); + static::_setHost($host); } } @@ -86,7 +86,7 @@ class CakeSessionTest extends CakeTestCase { */ public static function setupBeforeClass() { // Make sure garbage colector will be called - self::$_gcDivisor = ini_get('session.gc_divisor'); + static::$_gcDivisor = ini_get('session.gc_divisor'); ini_set('session.gc_divisor', '1'); } @@ -97,7 +97,7 @@ public static function setupBeforeClass() { */ public static function teardownAfterClass() { // Revert to the default setting - ini_set('session.gc_divisor', self::$_gcDivisor); + ini_set('session.gc_divisor', static::$_gcDivisor); } /** diff --git a/lib/Cake/Test/Case/Model/Datasource/Session/CacheSessionTest.php b/lib/Cake/Test/Case/Model/Datasource/Session/CacheSessionTest.php index 42b4e7120b6..553f70bf4bb 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Session/CacheSessionTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Session/CacheSessionTest.php @@ -39,7 +39,7 @@ public static function setupBeforeClass() { 'engine' => 'File', 'prefix' => 'session_test_' )); - self::$_sessionBackup = Configure::read('Session'); + static::$_sessionBackup = Configure::read('Session'); Configure::write('Session.handler.config', 'session_test'); } @@ -53,7 +53,7 @@ public static function teardownAfterClass() { Cache::clear(false, 'session_test'); Cache::drop('session_test'); - Configure::write('Session', self::$_sessionBackup); + Configure::write('Session', static::$_sessionBackup); } /** diff --git a/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php b/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php index 1a4b316f06f..da19cfcc6fc 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php @@ -54,7 +54,7 @@ class DatabaseSessionTest extends CakeTestCase { * @return void */ public static function setupBeforeClass() { - self::$_sessionBackup = Configure::read('Session'); + static::$_sessionBackup = Configure::read('Session'); Configure::write('Session.handler', array( 'model' => 'SessionTestModel', )); @@ -67,7 +67,7 @@ public static function setupBeforeClass() { * @return void */ public static function teardownAfterClass() { - Configure::write('Session', self::$_sessionBackup); + Configure::write('Session', static::$_sessionBackup); } /** diff --git a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php index fce6067b917..1aacd766285 100644 --- a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php +++ b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php @@ -1994,7 +1994,7 @@ public function testWithAssociation() { 'afterFind' => 'Successfully added by AfterFind' ) )); - $this->assertEquals(self::date(), $result['Something']['updated']); + $this->assertEquals(static::date(), $result['Something']['updated']); unset($result['Something']['updated']); $this->assertEquals($expected, $result); } diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index 62818f6f5fc..d6b7b21a3ea 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -2102,7 +2102,7 @@ public function testSaveHabtmNoPrimaryData() { 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', - 'updated' => self::date() + 'updated' => static::date() ), 'Tag' => array( array( @@ -3042,23 +3042,23 @@ public function testSaveMultipleHabtm() { 'JoinA' => array( 'id' => '1', 'name' => 'New name for Join A 1', - 'updated' => self::date() + 'updated' => static::date() ), 'JoinB' => array( array( 'id' => 1, 'join_b_id' => 2, 'other' => 'New data for Join A 1 Join B 2', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() )), 'JoinC' => array( array( 'id' => 1, 'join_c_id' => 2, 'other' => 'New data for Join A 1 Join C 2', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() ))); $TestModel->set($data); @@ -3071,7 +3071,7 @@ public function testSaveMultipleHabtm() { 'name' => 'New name for Join A 1', 'body' => 'Join A 1 Body', 'created' => '2008-01-03 10:54:23', - 'updated' => self::date() + 'updated' => static::date() ), 'JoinB' => array( 0 => array( @@ -3084,8 +3084,8 @@ public function testSaveMultipleHabtm() { 'join_a_id' => 1, 'join_b_id' => 2, 'other' => 'New data for Join A 1 Join B 2', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() ))), 'JoinC' => array( 0 => array( @@ -3098,8 +3098,8 @@ public function testSaveMultipleHabtm() { 'join_a_id' => 1, 'join_c_id' => 2, 'other' => 'New data for Join A 1 Join C 2', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() )))); $this->assertEquals($expected, $result); @@ -3143,10 +3143,10 @@ public function testSaveAll() { 'password' => '5f4dcc3b5aa765d61d8327deb882cf90', 'test' => 'working' )); - $this->assertEquals(self::date(), $result[3]['Post']['created']); - $this->assertEquals(self::date(), $result[3]['Post']['updated']); - $this->assertEquals(self::date(), $result[3]['Author']['created']); - $this->assertEquals(self::date(), $result[3]['Author']['updated']); + $this->assertEquals(static::date(), $result[3]['Post']['created']); + $this->assertEquals(static::date(), $result[3]['Post']['updated']); + $this->assertEquals(static::date(), $result[3]['Author']['created']); + $this->assertEquals(static::date(), $result[3]['Author']['updated']); unset($result[3]['Post']['created'], $result[3]['Post']['updated']); unset($result[3]['Author']['created'], $result[3]['Author']['updated']); $this->assertEquals($expected, $result[3]); @@ -3191,10 +3191,10 @@ public function testSaveAll() { 'body' => 'Second multi-record post', 'published' => 'N' ))); - $this->assertEquals(self::date(), $result[0]['Post']['created']); - $this->assertEquals(self::date(), $result[0]['Post']['updated']); - $this->assertEquals(self::date(), $result[1]['Post']['created']); - $this->assertEquals(self::date(), $result[1]['Post']['updated']); + $this->assertEquals(static::date(), $result[0]['Post']['created']); + $this->assertEquals(static::date(), $result[0]['Post']['updated']); + $this->assertEquals(static::date(), $result[1]['Post']['created']); + $this->assertEquals(static::date(), $result[1]['Post']['updated']); unset($result[0]['Post']['created'], $result[0]['Post']['updated']); unset($result[1]['Post']['created'], $result[1]['Post']['updated']); $this->assertEquals($expected, $result); @@ -3220,8 +3220,8 @@ public function testSaveAll() { 'comment' => 'New comment with attachment', 'published' => 'Y' ); - $this->assertEquals(self::date(), $result[6]['Comment']['created']); - $this->assertEquals(self::date(), $result[6]['Comment']['updated']); + $this->assertEquals(static::date(), $result[6]['Comment']['created']); + $this->assertEquals(static::date(), $result[6]['Comment']['updated']); unset($result[6]['Comment']['created'], $result[6]['Comment']['updated']); $this->assertEquals($expected, $result[6]['Comment']); @@ -3230,8 +3230,8 @@ public function testSaveAll() { 'comment_id' => '7', 'attachment' => 'some_file.tgz' ); - $this->assertEquals(self::date(), $result[6]['Attachment']['created']); - $this->assertEquals(self::date(), $result[6]['Attachment']['updated']); + $this->assertEquals(static::date(), $result[6]['Attachment']['created']); + $this->assertEquals(static::date(), $result[6]['Attachment']['updated']); unset($result[6]['Attachment']['created'], $result[6]['Attachment']['updated']); $this->assertEquals($expected, $result[6]['Attachment']); } @@ -4665,8 +4665,8 @@ public function testSaveAllTransaction() { 'title' => 'New Fourth Post', 'body' => null, 'published' => 'N', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() )); $expected[] = array( @@ -4676,8 +4676,8 @@ public function testSaveAllTransaction() { 'title' => 'New Fifth Post', 'body' => null, 'published' => 'N', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() )); $this->assertEquals($expected, $result); @@ -4733,8 +4733,8 @@ public function testSaveAllTransaction() { 'title' => 'New Fourth Post', 'body' => 'Third Post Body', 'published' => 'N', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() )); $expected[] = array( @@ -4744,8 +4744,8 @@ public function testSaveAllTransaction() { 'title' => 'Third Post', 'body' => 'Third Post Body', 'published' => 'N', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() )); } $this->assertEquals($expected, $result); @@ -4870,10 +4870,10 @@ public function testSaveAllValidation() { 'body' => 'Fourth post body', 'published' => 'N' ))); - $this->assertEquals(self::date(), $result[0]['Post']['updated']); - $this->assertEquals(self::date(), $result[1]['Post']['updated']); - $this->assertEquals(self::date(), $result[3]['Post']['created']); - $this->assertEquals(self::date(), $result[3]['Post']['updated']); + $this->assertEquals(static::date(), $result[0]['Post']['updated']); + $this->assertEquals(static::date(), $result[1]['Post']['updated']); + $this->assertEquals(static::date(), $result[3]['Post']['created']); + $this->assertEquals(static::date(), $result[3]['Post']['updated']); unset($result[0]['Post']['updated'], $result[1]['Post']['updated']); unset($result[3]['Post']['created'], $result[3]['Post']['updated']); $this->assertEquals($expected, $result); @@ -4964,10 +4964,10 @@ public function testSaveAllValidation() { ) ); - $this->assertEquals(self::date(), $result[0]['Post']['updated']); - $this->assertEquals(self::date(), $result[1]['Post']['updated']); - $this->assertEquals(self::date(), $result[3]['Post']['updated']); - $this->assertEquals(self::date(), $result[3]['Post']['created']); + $this->assertEquals(static::date(), $result[0]['Post']['updated']); + $this->assertEquals(static::date(), $result[1]['Post']['updated']); + $this->assertEquals(static::date(), $result[3]['Post']['updated']); + $this->assertEquals(static::date(), $result[3]['Post']['created']); unset( $result[0]['Post']['updated'], $result[1]['Post']['updated'], $result[3]['Post']['updated'], $result[3]['Post']['created'] @@ -5348,10 +5348,10 @@ public function testSaveAssociated() { 'password' => '5f4dcc3b5aa765d61d8327deb882cf90', 'test' => 'working' )); - $this->assertEquals(self::date(), $result[3]['Post']['updated']); - $this->assertEquals(self::date(), $result[3]['Post']['created']); - $this->assertEquals(self::date(), $result[3]['Author']['created']); - $this->assertEquals(self::date(), $result[3]['Author']['updated']); + $this->assertEquals(static::date(), $result[3]['Post']['updated']); + $this->assertEquals(static::date(), $result[3]['Post']['created']); + $this->assertEquals(static::date(), $result[3]['Author']['created']); + $this->assertEquals(static::date(), $result[3]['Author']['updated']); unset( $result[3]['Post']['updated'], $result[3]['Post']['created'], $result[3]['Author']['updated'], $result[3]['Author']['created'] @@ -5380,8 +5380,8 @@ public function testSaveAssociated() { 'comment' => 'New comment with attachment', 'published' => 'Y' ); - $this->assertEquals(self::date(), $result[6]['Comment']['updated']); - $this->assertEquals(self::date(), $result[6]['Comment']['created']); + $this->assertEquals(static::date(), $result[6]['Comment']['updated']); + $this->assertEquals(static::date(), $result[6]['Comment']['created']); unset($result[6]['Comment']['updated'], $result[6]['Comment']['created']); $this->assertEquals($expected, $result[6]['Comment']); @@ -5390,8 +5390,8 @@ public function testSaveAssociated() { 'comment_id' => '7', 'attachment' => 'some_file.tgz' ); - $this->assertEquals(self::date(), $result[6]['Attachment']['updated']); - $this->assertEquals(self::date(), $result[6]['Attachment']['created']); + $this->assertEquals(static::date(), $result[6]['Attachment']['updated']); + $this->assertEquals(static::date(), $result[6]['Attachment']['created']); unset($result[6]['Attachment']['updated'], $result[6]['Attachment']['created']); $this->assertEquals($expected, $result[6]['Attachment']); } @@ -5491,10 +5491,10 @@ public function testSaveMany() { ) ) ); - $this->assertEquals(self::date(), $result[0]['Post']['updated']); - $this->assertEquals(self::date(), $result[0]['Post']['created']); - $this->assertEquals(self::date(), $result[1]['Post']['updated']); - $this->assertEquals(self::date(), $result[1]['Post']['created']); + $this->assertEquals(static::date(), $result[0]['Post']['updated']); + $this->assertEquals(static::date(), $result[0]['Post']['created']); + $this->assertEquals(static::date(), $result[1]['Post']['updated']); + $this->assertEquals(static::date(), $result[1]['Post']['created']); unset($result[0]['Post']['updated'], $result[0]['Post']['created']); unset($result[1]['Post']['updated'], $result[1]['Post']['created']); $this->assertEquals($expected, $result); @@ -6184,10 +6184,10 @@ public function testSaveManyTransaction() { 'published' => 'N', )); - $this->assertEquals(self::date(), $result[3]['Post']['created']); - $this->assertEquals(self::date(), $result[3]['Post']['updated']); - $this->assertEquals(self::date(), $result[4]['Post']['created']); - $this->assertEquals(self::date(), $result[4]['Post']['updated']); + $this->assertEquals(static::date(), $result[3]['Post']['created']); + $this->assertEquals(static::date(), $result[3]['Post']['updated']); + $this->assertEquals(static::date(), $result[4]['Post']['created']); + $this->assertEquals(static::date(), $result[4]['Post']['updated']); unset($result[3]['Post']['created'], $result[3]['Post']['updated']); unset($result[4]['Post']['created'], $result[4]['Post']['updated']); $this->assertEquals($expected, $result); @@ -6253,10 +6253,10 @@ public function testSaveManyTransaction() { 'body' => 'Third Post Body', 'published' => 'N' )); - $this->assertEquals(self::date(), $result[3]['Post']['created']); - $this->assertEquals(self::date(), $result[3]['Post']['updated']); - $this->assertEquals(self::date(), $result[4]['Post']['created']); - $this->assertEquals(self::date(), $result[4]['Post']['updated']); + $this->assertEquals(static::date(), $result[3]['Post']['created']); + $this->assertEquals(static::date(), $result[3]['Post']['updated']); + $this->assertEquals(static::date(), $result[4]['Post']['created']); + $this->assertEquals(static::date(), $result[4]['Post']['updated']); unset($result[3]['Post']['created'], $result[3]['Post']['updated']); unset($result[4]['Post']['created'], $result[4]['Post']['updated']); } @@ -6387,10 +6387,10 @@ public function testSaveManyValidation() { ) ); - $this->assertEquals(self::date(), $result[0]['Post']['updated']); - $this->assertEquals(self::date(), $result[1]['Post']['updated']); - $this->assertEquals(self::date(), $result[3]['Post']['created']); - $this->assertEquals(self::date(), $result[3]['Post']['updated']); + $this->assertEquals(static::date(), $result[0]['Post']['updated']); + $this->assertEquals(static::date(), $result[1]['Post']['updated']); + $this->assertEquals(static::date(), $result[3]['Post']['created']); + $this->assertEquals(static::date(), $result[3]['Post']['updated']); unset($result[0]['Post']['updated'], $result[1]['Post']['updated']); unset($result[3]['Post']['created'], $result[3]['Post']['updated']); $this->assertEquals($expected, $result); @@ -7147,15 +7147,15 @@ public function testSaveAllFieldListValidateBelongsTo() { 'title' => 'Post without body', 'body' => null, 'published' => 'N', - 'created' => self::date(), - 'updated' => self::date(), + 'created' => static::date(), + 'updated' => static::date(), ), 'Author' => array( 'id' => '5', 'user' => 'bob', 'password' => null, - 'created' => self::date(), - 'updated' => self::date(), + 'created' => static::date(), + 'updated' => static::date(), 'test' => 'working', ), ); @@ -7210,15 +7210,15 @@ public function testSaveAllFieldListValidateBelongsTo() { 'title' => 'Post title', 'body' => 'Post body', 'published' => 'N', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() ), 'Author' => array( 'id' => '6', 'user' => 'jack', 'password' => 'foobar', - 'created' => self::date(), - 'updated' => self::date(), + 'created' => static::date(), + 'updated' => static::date(), 'test' => 'working' ), ); @@ -7252,8 +7252,8 @@ public function testSaveAllFieldListValidateBelongsTo() { 'title' => 'Multi-record post 1', 'body' => '', 'published' => 'N', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() ) ), array( @@ -7263,8 +7263,8 @@ public function testSaveAllFieldListValidateBelongsTo() { 'title' => 'Multi-record post 2', 'body' => '', 'published' => 'N', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() ) ) ); diff --git a/lib/Cake/Test/Case/Utility/FolderTest.php b/lib/Cake/Test/Case/Utility/FolderTest.php index 7169d27d063..67ab0cce990 100644 --- a/lib/Cake/Test/Case/Utility/FolderTest.php +++ b/lib/Cake/Test/Case/Utility/FolderTest.php @@ -41,7 +41,7 @@ public static function setUpBeforeClass() { foreach (scandir(TMP) as $file) { if (is_dir(TMP . $file) && !in_array($file, array('.', '..'))) { - self::$_tmp[] = $file; + static::$_tmp[] = $file; } } } @@ -62,7 +62,7 @@ public function setUp() { * @return void */ public function tearDown() { - $exclude = array_merge(self::$_tmp, array('.', '..')); + $exclude = array_merge(static::$_tmp, array('.', '..')); foreach (scandir(TMP) as $dir) { if (is_dir(TMP . $dir) && !in_array($dir, $exclude)) { $iterator = new RecursiveDirectoryIterator(TMP . $dir); diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index 7976929d3c2..03a00d4603b 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -198,7 +198,7 @@ public function testGet() { $result = Hash::get($data, '1'); $this->assertEquals('def', $result); - $data = self::articleData(); + $data = static::articleData(); $result = Hash::get(array(), '1.Article.title'); $this->assertNull($result); @@ -708,7 +708,7 @@ public function testNumeric() { * @return void */ public function testExtractBasic() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::extract($data, ''); $this->assertEquals($data, $result); @@ -729,7 +729,7 @@ public function testExtractBasic() { * @return void */ public function testExtractNumericKey() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::extract($data, '{n}.Article.title'); $expected = array( 'First Article', 'Second Article', @@ -808,7 +808,7 @@ public function testExtractNumericNonZero() { * @return void */ public function testExtractStringKey() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::extract($data, '{n}.{s}.user'); $expected = array( 'mariano', @@ -855,7 +855,7 @@ public function testExtractWildcard() { * @return void */ public function testExtractAttributePresence() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::extract($data, '{n}.Article[published]'); $expected = array($data[1]['Article']); @@ -872,7 +872,7 @@ public function testExtractAttributePresence() { * @return void */ public function testExtractAttributeEquality() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::extract($data, '{n}.Article[id=3]'); $expected = array($data[2]['Article']); @@ -957,7 +957,7 @@ public function testExtractAttributeEqualityOnScalarValue() { * @return void */ public function testExtractAttributeComparison() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::extract($data, '{n}.Comment.{n}[user_id > 2]'); $expected = array($data[0]['Comment'][1]); @@ -986,7 +986,7 @@ public function testExtractAttributeComparison() { * @return void */ public function testExtractAttributeMultiple() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::extract($data, '{n}.Comment.{n}[user_id > 2][id=1]'); $this->assertEmpty($result); @@ -1003,7 +1003,7 @@ public function testExtractAttributeMultiple() { * @return void */ public function testExtractAttributePattern() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::extract($data, '{n}.Article[title=/^First/]'); $expected = array($data[0]['Article']); @@ -1426,7 +1426,7 @@ public function testInsertSimple() { * @return void */ public function testInsertMulti() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::insert($data, '{n}.Article.insert', 'value'); $this->assertEquals('value', $result[0]['Article']['insert']); @@ -1552,7 +1552,7 @@ public function testRemove() { * @return void */ public function testRemoveMulti() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::remove($data, '{n}.Article.title'); $this->assertFalse(isset($result[0]['Article']['title'])); @@ -1619,7 +1619,7 @@ public function testCombine() { $result = Hash::combine(array(), '{n}.User.id', '{n}.User.Data'); $this->assertTrue(empty($result)); - $a = self::userData(); + $a = static::userData(); $result = Hash::combine($a, '{n}.User.id'); $expected = array(2 => null, 14 => null, 25 => null); @@ -1678,7 +1678,7 @@ public function testCombineErrorMissingKey() { * @return void */ public function testCombineWithGroupPath() { - $a = self::userData(); + $a = static::userData(); $result = Hash::combine($a, '{n}.User.id', '{n}.User.Data', '{n}.User.group_id'); $expected = array( @@ -1735,7 +1735,7 @@ public function testCombineWithGroupPath() { * @return void */ public function testCombineWithFormatting() { - $a = self::userData(); + $a = static::userData(); $result = Hash::combine( $a, @@ -1801,7 +1801,7 @@ public function testCombineWithFormatting() { * @return void */ public function testFormat() { - $data = self::userData(); + $data = static::userData(); $result = Hash::format( $data, @@ -1861,7 +1861,7 @@ public function testFormatNullValues() { * @return void */ public function testMap() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::map($data, '{n}.Article.id', array($this, 'mapCallback')); $expected = array(2, 4, 6, 8, 10); @@ -1874,7 +1874,7 @@ public function testMap() { * @return void */ public function testApply() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::apply($data, '{n}.Article.id', 'array_sum'); $this->assertEquals(15, $result); @@ -1886,7 +1886,7 @@ public function testApply() { * @return void */ public function testReduce() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::reduce($data, '{n}.Article.id', array($this, 'reduceCallback')); $this->assertEquals(15, $result); diff --git a/lib/Cake/Test/Case/Utility/InflectorTest.php b/lib/Cake/Test/Case/Utility/InflectorTest.php index 13a32ffa436..638ba54dc87 100644 --- a/lib/Cake/Test/Case/Utility/InflectorTest.php +++ b/lib/Cake/Test/Case/Utility/InflectorTest.php @@ -406,7 +406,7 @@ public function testInflectorSlug() { * @return void */ public function testInflectorSlugCharList() { - foreach (self::$maps as $language => $list) { + foreach (static::$maps as $language => $list) { foreach ($list as $from => $to) { $result = Inflector::slug($from); $this->assertEquals($to, $result, $from . ' (' . $language . ') should be ' . $to . ' - but is ' . $result); diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index 491a0f0aaaf..bcecc45a373 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -548,7 +548,7 @@ protected function _assertAttributes($assertions, $string) { * @return void */ protected static function assertEqual($result, $expected, $message = '') { - return self::assertEquals($expected, $result, $message); + return static::assertEquals($expected, $result, $message); } /** @@ -561,7 +561,7 @@ protected static function assertEqual($result, $expected, $message = '') { * @return void */ protected static function assertNotEqual($result, $expected, $message = '') { - return self::assertNotEquals($expected, $result, $message); + return static::assertNotEquals($expected, $result, $message); } /** @@ -574,7 +574,7 @@ protected static function assertNotEqual($result, $expected, $message = '') { * @return void */ protected static function assertPattern($pattern, $string, $message = '') { - return self::assertRegExp($pattern, $string, $message); + return static::assertRegExp($pattern, $string, $message); } /** @@ -587,7 +587,7 @@ protected static function assertPattern($pattern, $string, $message = '') { * @return void */ protected static function assertIdentical($actual, $expected, $message = '') { - return self::assertSame($expected, $actual, $message); + return static::assertSame($expected, $actual, $message); } /** @@ -600,7 +600,7 @@ protected static function assertIdentical($actual, $expected, $message = '') { * @return void */ protected static function assertNotIdentical($actual, $expected, $message = '') { - return self::assertNotSame($expected, $actual, $message); + return static::assertNotSame($expected, $actual, $message); } /** @@ -613,7 +613,7 @@ protected static function assertNotIdentical($actual, $expected, $message = '') * @return void */ protected static function assertNoPattern($pattern, $string, $message = '') { - return self::assertNotRegExp($pattern, $string, $message); + return static::assertNotRegExp($pattern, $string, $message); } /** @@ -662,7 +662,7 @@ protected function expectException($name = 'Exception', $message = '') { * @return void */ protected static function assertReference(&$first, &$second, $message = '') { - return self::assertSame($first, $second, $message); + return static::assertSame($first, $second, $message); } /** @@ -675,7 +675,7 @@ protected static function assertReference(&$first, &$second, $message = '') { * @return void */ protected static function assertIsA($object, $type, $message = '') { - return self::assertInstanceOf($type, $object, $message); + return static::assertInstanceOf($type, $object, $message); } /** @@ -690,7 +690,7 @@ protected static function assertIsA($object, $type, $message = '') { protected static function assertWithinMargin($result, $expected, $margin, $message = '') { $upper = $result + $margin; $lower = $result - $margin; - return self::assertTrue((($expected <= $upper) && ($expected >= $lower)), $message); + return static::assertTrue((($expected <= $upper) && ($expected >= $lower)), $message); } /** diff --git a/lib/Cake/TestSuite/CakeTestLoader.php b/lib/Cake/TestSuite/CakeTestLoader.php index d6f3d8df41e..c1fa85f106e 100644 --- a/lib/Cake/TestSuite/CakeTestLoader.php +++ b/lib/Cake/TestSuite/CakeTestLoader.php @@ -85,8 +85,8 @@ protected static function _basePath($params) { * @return array */ public static function generateTestList($params) { - $directory = self::_basePath($params); - $fileList = self::_getRecursiveFileList($directory); + $directory = static::_basePath($params); + $fileList = static::_getRecursiveFileList($directory); $testCases = array(); foreach ($fileList as $testCaseFile) { diff --git a/lib/Cake/TestSuite/CakeTestRunner.php b/lib/Cake/TestSuite/CakeTestRunner.php index 3aafdc198cc..d512724cc04 100644 --- a/lib/Cake/TestSuite/CakeTestRunner.php +++ b/lib/Cake/TestSuite/CakeTestRunner.php @@ -48,7 +48,7 @@ public function __construct($loader, $params) { */ public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array()) { if (isset($arguments['printer'])) { - self::$versionStringPrinted = true; + static::$versionStringPrinted = true; } $fixture = $this->_getFixtureManager($arguments); diff --git a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php index d61b232a46a..85c6e2278e3 100644 --- a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php +++ b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php @@ -254,7 +254,7 @@ protected function _runTestCase() { restore_error_handler(); try { - self::time(); + static::time(); $command = new CakeTestSuiteCommand('CakeTestLoader', $commandArgs); $command->run($options); } catch (MissingConnectionException $exception) { @@ -287,7 +287,7 @@ public static function time($reset = false) { * @return string formatted date */ public static function date($format) { - return date($format, self::time()); + return date($format, static::time()); } } diff --git a/lib/Cake/Utility/CakeNumber.php b/lib/Cake/Utility/CakeNumber.php index 61a3daf5942..970f734e9d6 100644 --- a/lib/Cake/Utility/CakeNumber.php +++ b/lib/Cake/Utility/CakeNumber.php @@ -116,13 +116,13 @@ public static function toReadableSize($size) { case $size < 1024: return __dn('cake', '%d Byte', '%d Bytes', $size, $size); case round($size / 1024) < 1024: - return __d('cake', '%s KB', self::precision($size / 1024, 0)); + return __d('cake', '%s KB', static::precision($size / 1024, 0)); case round($size / 1024 / 1024, 2) < 1024: - return __d('cake', '%s MB', self::precision($size / 1024 / 1024, 2)); + return __d('cake', '%s MB', static::precision($size / 1024 / 1024, 2)); case round($size / 1024 / 1024 / 1024, 2) < 1024: - return __d('cake', '%s GB', self::precision($size / 1024 / 1024 / 1024, 2)); + return __d('cake', '%s GB', static::precision($size / 1024 / 1024 / 1024, 2)); default: - return __d('cake', '%s TB', self::precision($size / 1024 / 1024 / 1024 / 1024, 2)); + return __d('cake', '%s TB', static::precision($size / 1024 / 1024 / 1024 / 1024, 2)); } } @@ -181,7 +181,7 @@ public static function toPercentage($value, $precision = 2, $options = array()) if ($options['multiply']) { $value *= 100; } - return self::precision($value, $precision) . '%'; + return static::precision($value, $precision) . '%'; } /** @@ -221,8 +221,8 @@ public static function format($value, $options = false) { extract($options); } - $value = self::_numberFormat($value, $places, '.', ''); - $out = $before . self::_numberFormat($value, $places, $decimals, $thousands) . $after; + $value = static::_numberFormat($value, $places, '.', ''); + $out = $before . static::_numberFormat($value, $places, $decimals, $thousands) . $after; if ($escape) { return h($out); @@ -249,10 +249,10 @@ public static function format($value, $options = false) { */ public static function formatDelta($value, $options = array()) { $places = isset($options['places']) ? $options['places'] : 0; - $value = self::_numberFormat($value, $places, '.', ''); + $value = static::_numberFormat($value, $places, '.', ''); $sign = $value > 0 ? '+' : ''; $options['before'] = isset($options['before']) ? $options['before'] . $sign : $sign; - return self::format($value, $options); + return static::format($value, $options); } /** @@ -265,10 +265,10 @@ public static function formatDelta($value, $options = array()) { * @return string */ protected static function _numberFormat($value, $places = 0, $decimals = '.', $thousands = ',') { - if (!isset(self::$_numberFormatSupport)) { - self::$_numberFormatSupport = version_compare(PHP_VERSION, '5.4.0', '>='); + if (!isset(static::$_numberFormatSupport)) { + static::$_numberFormatSupport = version_compare(PHP_VERSION, '5.4.0', '>='); } - if (self::$_numberFormatSupport) { + if (static::$_numberFormatSupport) { return number_format($value, $places, $decimals, $thousands); } $value = number_format($value, $places, '.', ''); @@ -323,13 +323,13 @@ protected static function _numberFormat($value, $places = 0, $decimals = '.', $t * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::currency */ public static function currency($value, $currency = null, $options = array()) { - $defaults = self::$_currencyDefaults; + $defaults = static::$_currencyDefaults; if ($currency === null) { - $currency = self::defaultCurrency(); + $currency = static::defaultCurrency(); } - if (isset(self::$_currencies[$currency])) { - $defaults = self::$_currencies[$currency]; + if (isset(static::$_currencies[$currency])) { + $defaults = static::$_currencies[$currency]; } elseif (is_string($currency)) { $options['before'] = $currency; } @@ -364,7 +364,7 @@ public static function currency($value, $currency = null, $options = array()) { $options[$position] = $options[$symbolKey . 'Symbol']; $abs = abs($value); - $result = self::format($abs, $options); + $result = static::format($abs, $options); if ($value < 0) { if ($options['negative'] === '()') { @@ -396,7 +396,7 @@ public static function currency($value, $currency = null, $options = array()) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::addFormat */ public static function addFormat($formatName, $options) { - self::$_currencies[$formatName] = $options + self::$_currencyDefaults; + static::$_currencies[$formatName] = $options + static::$_currencyDefaults; } /** @@ -408,9 +408,9 @@ public static function addFormat($formatName, $options) { */ public static function defaultCurrency($currency = null) { if ($currency) { - self::$_defaultCurrency = $currency; + static::$_defaultCurrency = $currency; } - return self::$_defaultCurrency; + return static::$_defaultCurrency; } } diff --git a/lib/Cake/Utility/CakeText.php b/lib/Cake/Utility/CakeText.php index 1e72c913eb3..ff60cffa7a9 100644 --- a/lib/Cake/Utility/CakeText.php +++ b/lib/Cake/Utility/CakeText.php @@ -332,7 +332,7 @@ public static function wrap($text, $options = array()) { } $options += array('width' => 72, 'wordWrap' => true, 'indent' => null, 'indentAt' => 0); if ($options['wordWrap']) { - $wrapped = self::wordWrap($text, $options['width'], "\n"); + $wrapped = static::wordWrap($text, $options['width'], "\n"); } else { $wrapped = trim(chunk_split($text, $options['width'] - 1, "\n")); } @@ -358,7 +358,7 @@ public static function wrap($text, $options = array()) { public static function wordWrap($text, $width = 72, $break = "\n", $cut = false) { $paragraphs = explode($break, $text); foreach ($paragraphs as &$paragraph) { - $paragraph = self::_wordWrap($paragraph, $width, $break, $cut); + $paragraph = static::_wordWrap($paragraph, $width, $break, $cut); } return implode($break, $paragraphs); } @@ -657,7 +657,7 @@ class_exists('Multibyte'); */ public static function excerpt($text, $phrase, $radius = 100, $ellipsis = '...') { if (empty($text) || empty($phrase)) { - return self::truncate($text, $radius * 2, array('ellipsis' => $ellipsis)); + return static::truncate($text, $radius * 2, array('ellipsis' => $ellipsis)); } $append = $prepend = $ellipsis; diff --git a/lib/Cake/Utility/CakeTime.php b/lib/Cake/Utility/CakeTime.php index d3b8f8d67bc..0987dce3c16 100644 --- a/lib/Cake/Utility/CakeTime.php +++ b/lib/Cake/Utility/CakeTime.php @@ -100,7 +100,7 @@ class CakeTime { public function __set($name, $value) { switch ($name) { case 'niceFormat': - self::${$name} = $value; + static::${$name} = $value; break; } } @@ -115,7 +115,7 @@ public function __set($name, $value) { public function __get($name) { switch ($name) { case 'niceFormat': - return self::${$name}; + return static::${$name}; default: return null; } @@ -135,7 +135,7 @@ public static function convertSpecifiers($format, $time = null) { if (!$time) { $time = time(); } - self::$_time = $time; + static::$_time = $time; return preg_replace_callback('/\%(\w+)/', array('CakeTime', '_translateSpecifier'), $format); } @@ -151,47 +151,47 @@ protected static function _translateSpecifier($specifier) { case 'a': $abday = __dc('cake', 'abday', 5); if (is_array($abday)) { - return $abday[date('w', self::$_time)]; + return $abday[date('w', static::$_time)]; } break; case 'A': $day = __dc('cake', 'day', 5); if (is_array($day)) { - return $day[date('w', self::$_time)]; + return $day[date('w', static::$_time)]; } break; case 'c': $format = __dc('cake', 'd_t_fmt', 5); if ($format !== 'd_t_fmt') { - return self::convertSpecifiers($format, self::$_time); + return static::convertSpecifiers($format, static::$_time); } break; case 'C': - return sprintf("%02d", date('Y', self::$_time) / 100); + return sprintf("%02d", date('Y', static::$_time) / 100); case 'D': return '%m/%d/%y'; case 'e': if (DS === '/') { return '%e'; } - $day = date('j', self::$_time); + $day = date('j', static::$_time); if ($day < 10) { $day = ' ' . $day; } return $day; case 'eS' : - return date('jS', self::$_time); + return date('jS', static::$_time); case 'b': case 'h': $months = __dc('cake', 'abmon', 5); if (is_array($months)) { - return $months[date('n', self::$_time) - 1]; + return $months[date('n', static::$_time) - 1]; } return '%b'; case 'B': $months = __dc('cake', 'mon', 5); if (is_array($months)) { - return $months[date('n', self::$_time) - 1]; + return $months[date('n', static::$_time) - 1]; } break; case 'n': @@ -199,7 +199,7 @@ protected static function _translateSpecifier($specifier) { case 'p': case 'P': $default = array('am' => 0, 'pm' => 1); - $meridiem = $default[date('a', self::$_time)]; + $meridiem = $default[date('a', static::$_time)]; $format = __dc('cake', 'am_pm', 5); if (is_array($format)) { $meridiem = $format[$meridiem]; @@ -209,27 +209,27 @@ protected static function _translateSpecifier($specifier) { case 'r': $complete = __dc('cake', 't_fmt_ampm', 5); if ($complete !== 't_fmt_ampm') { - return str_replace('%p', self::_translateSpecifier(array('%p', 'p')), $complete); + return str_replace('%p', static::_translateSpecifier(array('%p', 'p')), $complete); } break; case 'R': - return date('H:i', self::$_time); + return date('H:i', static::$_time); case 't': return "\t"; case 'T': return '%H:%M:%S'; case 'u': - return ($weekDay = date('w', self::$_time)) ? $weekDay : 7; + return ($weekDay = date('w', static::$_time)) ? $weekDay : 7; case 'x': $format = __dc('cake', 'd_fmt', 5); if ($format !== 'd_fmt') { - return self::convertSpecifiers($format, self::$_time); + return static::convertSpecifiers($format, static::$_time); } break; case 'X': $format = __dc('cake', 't_fmt', 5); if ($format !== 't_fmt') { - return self::convertSpecifiers($format, self::$_time); + return static::convertSpecifiers($format, static::$_time); } break; } @@ -254,7 +254,7 @@ public static function convert($serverTime, $timezone) { if (is_numeric($timezone)) { $userOffset = $timezone * (60 * 60); } else { - $timezone = self::timezone($timezone); + $timezone = static::timezone($timezone); $userOffset = $timezone->getOffset(new DateTime('@' . $gmtTime)); } $userTime = $gmtTime + $userOffset; @@ -343,7 +343,7 @@ public static function fromString($dateString, $timezone = null) { } if ($timezone !== null) { - return self::convert($date, $timezone); + return static::convert($date, $timezone); } return $date; } @@ -364,12 +364,12 @@ public static function nice($dateString = null, $timezone = null, $format = null if (!$dateString) { $dateString = time(); } - $date = self::fromString($dateString, $timezone); + $date = static::fromString($dateString, $timezone); if (!$format) { - $format = self::$niceFormat; + $format = static::$niceFormat; } - return self::_strftime(self::convertSpecifiers($format, $date), $date); + return static::_strftime(static::convertSpecifiers($format, $date), $date); } /** @@ -391,19 +391,19 @@ public static function niceShort($dateString = null, $timezone = null) { if (!$dateString) { $dateString = time(); } - $date = self::fromString($dateString, $timezone); + $date = static::fromString($dateString, $timezone); - if (self::isToday($dateString, $timezone)) { - return __d('cake', 'Today, %s', self::_strftime("%H:%M", $date)); + if (static::isToday($dateString, $timezone)) { + return __d('cake', 'Today, %s', static::_strftime("%H:%M", $date)); } - if (self::wasYesterday($dateString, $timezone)) { - return __d('cake', 'Yesterday, %s', self::_strftime("%H:%M", $date)); + if (static::wasYesterday($dateString, $timezone)) { + return __d('cake', 'Yesterday, %s', static::_strftime("%H:%M", $date)); } - if (self::isTomorrow($dateString, $timezone)) { - return __d('cake', 'Tomorrow, %s', self::_strftime("%H:%M", $date)); + if (static::isTomorrow($dateString, $timezone)) { + return __d('cake', 'Tomorrow, %s', static::_strftime("%H:%M", $date)); } - $d = self::_strftime("%w", $date); + $d = static::_strftime("%w", $date); $day = array( __d('cake', 'Sunday'), __d('cake', 'Monday'), @@ -413,18 +413,18 @@ public static function niceShort($dateString = null, $timezone = null) { __d('cake', 'Friday'), __d('cake', 'Saturday') ); - if (self::wasWithinLast('7 days', $dateString, $timezone)) { - return sprintf('%s %s', $day[$d], self::_strftime(self::$niceShortFormat, $date)); + if (static::wasWithinLast('7 days', $dateString, $timezone)) { + return sprintf('%s %s', $day[$d], static::_strftime(static::$niceShortFormat, $date)); } - if (self::isWithinNext('7 days', $dateString, $timezone)) { - return __d('cake', 'On %s %s', $day[$d], self::_strftime(self::$niceShortFormat, $date)); + if (static::isWithinNext('7 days', $dateString, $timezone)) { + return __d('cake', 'On %s %s', $day[$d], static::_strftime(static::$niceShortFormat, $date)); } $y = ''; - if (!self::isThisYear($date)) { + if (!static::isThisYear($date)) { $y = ' %Y'; } - return self::_strftime(self::convertSpecifiers("%b %eS{$y}, %H:%M", $date), $date); + return static::_strftime(static::convertSpecifiers("%b %eS{$y}, %H:%M", $date), $date); } /** @@ -438,8 +438,8 @@ public static function niceShort($dateString = null, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::daysAsSql */ public static function daysAsSql($begin, $end, $fieldName, $timezone = null) { - $begin = self::fromString($begin, $timezone); - $end = self::fromString($end, $timezone); + $begin = static::fromString($begin, $timezone); + $end = static::fromString($end, $timezone); $begin = date('Y-m-d', $begin) . ' 00:00:00'; $end = date('Y-m-d', $end) . ' 23:59:59'; @@ -457,7 +457,7 @@ public static function daysAsSql($begin, $end, $fieldName, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::dayAsSql */ public static function dayAsSql($dateString, $fieldName, $timezone = null) { - return self::daysAsSql($dateString, $dateString, $fieldName, $timezone); + return static::daysAsSql($dateString, $dateString, $fieldName, $timezone); } /** @@ -469,8 +469,8 @@ public static function dayAsSql($dateString, $fieldName, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isToday */ public static function isToday($dateString, $timezone = null) { - $timestamp = self::fromString($dateString, $timezone); - $now = self::fromString('now', $timezone); + $timestamp = static::fromString($dateString, $timezone); + $now = static::fromString('now', $timezone); return date('Y-m-d', $timestamp) === date('Y-m-d', $now); } @@ -483,7 +483,7 @@ public static function isToday($dateString, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isFuture */ public static function isFuture($dateString, $timezone = null) { - $timestamp = self::fromString($dateString, $timezone); + $timestamp = static::fromString($dateString, $timezone); return $timestamp > time(); } @@ -496,7 +496,7 @@ public static function isFuture($dateString, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isPast */ public static function isPast($dateString, $timezone = null) { - $timestamp = self::fromString($dateString, $timezone); + $timestamp = static::fromString($dateString, $timezone); return $timestamp < time(); } @@ -509,8 +509,8 @@ public static function isPast($dateString, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isThisWeek */ public static function isThisWeek($dateString, $timezone = null) { - $timestamp = self::fromString($dateString, $timezone); - $now = self::fromString('now', $timezone); + $timestamp = static::fromString($dateString, $timezone); + $now = static::fromString('now', $timezone); return date('W o', $timestamp) === date('W o', $now); } @@ -523,8 +523,8 @@ public static function isThisWeek($dateString, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isThisMonth */ public static function isThisMonth($dateString, $timezone = null) { - $timestamp = self::fromString($dateString, $timezone); - $now = self::fromString('now', $timezone); + $timestamp = static::fromString($dateString, $timezone); + $now = static::fromString('now', $timezone); return date('m Y', $timestamp) === date('m Y', $now); } @@ -537,8 +537,8 @@ public static function isThisMonth($dateString, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isThisYear */ public static function isThisYear($dateString, $timezone = null) { - $timestamp = self::fromString($dateString, $timezone); - $now = self::fromString('now', $timezone); + $timestamp = static::fromString($dateString, $timezone); + $now = static::fromString('now', $timezone); return date('Y', $timestamp) === date('Y', $now); } @@ -551,8 +551,8 @@ public static function isThisYear($dateString, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::wasYesterday */ public static function wasYesterday($dateString, $timezone = null) { - $timestamp = self::fromString($dateString, $timezone); - $yesterday = self::fromString('yesterday', $timezone); + $timestamp = static::fromString($dateString, $timezone); + $yesterday = static::fromString('yesterday', $timezone); return date('Y-m-d', $timestamp) === date('Y-m-d', $yesterday); } @@ -565,8 +565,8 @@ public static function wasYesterday($dateString, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isTomorrow */ public static function isTomorrow($dateString, $timezone = null) { - $timestamp = self::fromString($dateString, $timezone); - $tomorrow = self::fromString('tomorrow', $timezone); + $timestamp = static::fromString($dateString, $timezone); + $tomorrow = static::fromString('tomorrow', $timezone); return date('Y-m-d', $timestamp) === date('Y-m-d', $tomorrow); } @@ -579,7 +579,7 @@ public static function isTomorrow($dateString, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::toQuarter */ public static function toQuarter($dateString, $range = false) { - $time = self::fromString($dateString); + $time = static::fromString($dateString); $date = (int)ceil(date('m', $time) / 3); if ($range === false) { return $date; @@ -607,7 +607,7 @@ public static function toQuarter($dateString, $range = false) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::toUnix */ public static function toUnix($dateString, $timezone = null) { - return self::fromString($dateString, $timezone); + return static::fromString($dateString, $timezone); } /** @@ -658,7 +658,7 @@ public static function toServer($dateString, $timezone = null, $format = 'Y-m-d * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::toAtom */ public static function toAtom($dateString, $timezone = null) { - return date('Y-m-d\TH:i:s\Z', self::fromString($dateString, $timezone)); + return date('Y-m-d\TH:i:s\Z', static::fromString($dateString, $timezone)); } /** @@ -670,7 +670,7 @@ public static function toAtom($dateString, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::toRSS */ public static function toRSS($dateString, $timezone = null) { - $date = self::fromString($dateString, $timezone); + $date = static::fromString($dateString, $timezone); if ($timezone === null) { return date("r", $date); @@ -737,9 +737,9 @@ public static function toRSS($dateString, $timezone = null) { */ public static function timeAgoInWords($dateTime, $options = array()) { $timezone = null; - $accuracies = self::$wordAccuracy; - $format = self::$wordFormat; - $relativeEnd = self::$wordEnd; + $accuracies = static::$wordAccuracy; + $format = static::$wordFormat; + $relativeEnd = static::$wordEnd; $relativeStringPast = __d('cake', '%s ago'); $relativeStringFuture = __d('cake', 'in %s'); $absoluteString = __d('cake', 'on %s'); @@ -784,8 +784,8 @@ public static function timeAgoInWords($dateTime, $options = array()) { unset($options['end'], $options['format']); } - $now = self::fromString(time(), $timezone); - $inSeconds = self::fromString($dateTime, $timezone); + $now = static::fromString(time(), $timezone); + $inSeconds = static::fromString($dateTime, $timezone); $isFuture = ($inSeconds > $now); if ($isFuture) { @@ -801,12 +801,12 @@ public static function timeAgoInWords($dateTime, $options = array()) { return __d('cake', 'just now', 'just now'); } - $isAbsoluteDate = $diff > abs($now - self::fromString($relativeEnd)); + $isAbsoluteDate = $diff > abs($now - static::fromString($relativeEnd)); if ($isAbsoluteDate) { if (strpos($format, '%') === false) { $date = date($format, $inSeconds); } else { - $date = self::_strftime($format, $inSeconds); + $date = static::_strftime($format, $inSeconds); } return sprintf($absoluteString, $date); } @@ -958,9 +958,9 @@ public static function wasWithinLast($timeInterval, $dateString, $timezone = nul $timeInterval = $tmp . ' ' . __d('cake', 'days'); } - $date = self::fromString($dateString, $timezone); - $interval = self::fromString('-' . $timeInterval); - $now = self::fromString('now', $timezone); + $date = static::fromString($dateString, $timezone); + $interval = static::fromString('-' . $timeInterval); + $now = static::fromString('now', $timezone); return $date >= $interval && $date <= $now; } @@ -980,9 +980,9 @@ public static function isWithinNext($timeInterval, $dateString, $timezone = null $timeInterval = $tmp . ' ' . __d('cake', 'days'); } - $date = self::fromString($dateString, $timezone); - $interval = self::fromString('+' . $timeInterval); - $now = self::fromString('now', $timezone); + $date = static::fromString($dateString, $timezone); + $interval = static::fromString('+' . $timeInterval); + $now = static::fromString('now', $timezone); return $date <= $interval && $date >= $now; } @@ -997,7 +997,7 @@ public static function isWithinNext($timeInterval, $dateString, $timezone = null public static function gmt($dateString = null) { $time = time(); if ($dateString) { - $time = self::fromString($dateString); + $time = static::fromString($dateString); } return gmmktime( (int)date('G', $time), @@ -1035,10 +1035,10 @@ public static function gmt($dateString = null) { */ public static function format($date, $format = null, $default = false, $timezone = null) { //Backwards compatible params re-order test - $time = self::fromString($format, $timezone); + $time = static::fromString($format, $timezone); if ($time === false) { - return self::i18nFormat($date, $format, $default, $timezone); + return static::i18nFormat($date, $format, $default, $timezone); } return date($date, $time); } @@ -1055,7 +1055,7 @@ public static function format($date, $format = null, $default = false, $timezone * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::i18nFormat */ public static function i18nFormat($date, $format = null, $default = false, $timezone = null) { - $date = self::fromString($date, $timezone); + $date = static::fromString($date, $timezone); if ($date === false && $default !== false) { return $default; } @@ -1065,7 +1065,7 @@ public static function i18nFormat($date, $format = null, $default = false, $time if (empty($format)) { $format = '%x'; } - return self::_strftime(self::convertSpecifiers($format, $date), $date); + return static::_strftime(static::convertSpecifiers($format, $date), $date); } /** diff --git a/lib/Cake/Utility/Debugger.php b/lib/Cake/Utility/Debugger.php index 69f0f8cea95..b6fccf2aa95 100644 --- a/lib/Cake/Utility/Debugger.php +++ b/lib/Cake/Utility/Debugger.php @@ -174,7 +174,7 @@ public static function getInstance($class = null) { * @link http://book.cakephp.org/2.0/en/development/debugging.html#Debugger::dump */ public static function dump($var, $depth = 3) { - pr(self::exportVar($var, $depth)); + pr(static::exportVar($var, $depth)); } /** @@ -188,8 +188,8 @@ public static function dump($var, $depth = 3) { * @link http://book.cakephp.org/2.0/en/development/debugging.html#Debugger::log */ public static function log($var, $level = LOG_DEBUG, $depth = 3) { - $source = self::trace(array('start' => 1)) . "\n"; - CakeLog::write($level, "\n" . $source . self::exportVar($var, $depth)); + $source = static::trace(array('start' => 1)) . "\n"; + CakeLog::write($level, "\n" . $source . static::exportVar($var, $depth)); } /** @@ -334,7 +334,7 @@ public static function trace($options = array()) { } else { $tpl = $self->_templates['base']['traceLine']; } - $trace['path'] = self::trimPath($trace['file']); + $trace['path'] = static::trimPath($trace['file']); $trace['reference'] = $reference; unset($trace['object'], $trace['args']); $back[] = CakeText::insert($tpl, $trace, array('before' => '{:', 'after' => '}')); @@ -408,7 +408,7 @@ public static function excerpt($file, $line, $context = 2) { if (!isset($data[$i])) { continue; } - $string = str_replace(array("\r\n", "\n"), "", self::_highlight($data[$i])); + $string = str_replace(array("\r\n", "\n"), "", static::_highlight($data[$i])); if ($i == $line) { $lines[] = '' . $string . ''; } else { @@ -468,7 +468,7 @@ protected static function _highlight($str) { * @link http://book.cakephp.org/2.0/en/development/debugging.html#Debugger::exportVar */ public static function exportVar($var, $depth = 3) { - return self::_export($var, $depth, 0); + return static::_export($var, $depth, 0); } /** @@ -480,7 +480,7 @@ public static function exportVar($var, $depth = 3) { * @return string The dumped variable. */ protected static function _export($var, $depth, $indent) { - switch (self::getType($var)) { + switch (static::getType($var)) { case 'boolean': return ($var) ? 'true' : 'false'; case 'integer': @@ -493,7 +493,7 @@ protected static function _export($var, $depth, $indent) { } return "'" . $var . "'"; case 'array': - return self::_array($var, $depth - 1, $indent + 1); + return static::_array($var, $depth - 1, $indent + 1); case 'resource': return strtolower(gettype($var)); case 'null': @@ -501,7 +501,7 @@ protected static function _export($var, $depth, $indent) { case 'unknown': return 'unknown'; default: - return self::_object($var, $depth - 1, $indent + 1); + return static::_object($var, $depth - 1, $indent + 1); } } @@ -550,9 +550,9 @@ protected static function _array(array $var, $depth, $indent) { if ($key === 'GLOBALS' && is_array($val) && isset($val['GLOBALS'])) { $val = '[recursion]'; } elseif ($val !== $var) { - $val = self::_export($val, $depth, $indent); + $val = static::_export($val, $depth, $indent); } - $vars[] = $break . self::exportVar($key) . + $vars[] = $break . static::exportVar($key) . ' => ' . $val; } @@ -583,7 +583,7 @@ protected static function _object($var, $depth, $indent) { $break = "\n" . str_repeat("\t", $indent); $objectVars = get_object_vars($var); foreach ($objectVars as $key => $value) { - $value = self::_export($value, $depth - 1, $indent); + $value = static::_export($value, $depth - 1, $indent); $props[] = "$key => " . $value; } @@ -600,7 +600,7 @@ protected static function _object($var, $depth, $indent) { $reflectionProperty->setAccessible(true); $property = $reflectionProperty->getValue($var); - $value = self::_export($property, $depth - 1, $indent); + $value = static::_export($property, $depth - 1, $indent); $key = $reflectionProperty->name; $props[] = sprintf('[%s] %s => %s', $visibility, $key, $value); } diff --git a/lib/Cake/Utility/Folder.php b/lib/Cake/Utility/Folder.php index fe4b943d2d5..20058f17449 100644 --- a/lib/Cake/Utility/Folder.php +++ b/lib/Cake/Utility/Folder.php @@ -285,7 +285,7 @@ public static function isAbsolute($path) { return $path[0] === '/' || preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) === '\\\\' || - self::isRegisteredStreamWrapper($path); + static::isRegisteredStreamWrapper($path); } /** @@ -525,8 +525,8 @@ public function create($pathname, $mode = false) { return true; } - if (!self::isAbsolute($pathname)) { - $pathname = self::addPathElement($this->pwd(), $pathname); + if (!static::isAbsolute($pathname)) { + $pathname = static::addPathElement($this->pwd(), $pathname); } if (!$mode) { diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index 6f5b32abc54..1577119c459 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -106,7 +106,7 @@ public static function extract(array $data, $path) { // Simple paths. if (!preg_match('/[{\[]/', $path)) { - return (array)self::get($data, $path); + return (array)static::get($data, $path); } if (strpos($path, '[') === false) { @@ -122,11 +122,11 @@ public static function extract(array $data, $path) { foreach ($tokens as $token) { $next = array(); - list($token, $conditions) = self::_splitConditions($token); + list($token, $conditions) = static::_splitConditions($token); foreach ($context[$_key] as $item) { foreach ((array)$item as $k => $v) { - if (self::_matchToken($k, $token)) { + if (static::_matchToken($k, $token)) { $next[] = $v; } } @@ -136,7 +136,7 @@ public static function extract(array $data, $path) { if ($conditions) { $filter = array(); foreach ($next as $item) { - if (is_array($item) && self::_matches($item, $conditions)) { + if (is_array($item) && static::_matches($item, $conditions)) { $filter[] = $item; } } @@ -262,22 +262,22 @@ public static function insert(array $data, $path, $values = null) { } if (strpos($path, '{') === false && strpos($path, '[') === false) { - return self::_simpleOp('insert', $data, $tokens, $values); + return static::_simpleOp('insert', $data, $tokens, $values); } $token = array_shift($tokens); $nextPath = implode('.', $tokens); - list($token, $conditions) = self::_splitConditions($token); + list($token, $conditions) = static::_splitConditions($token); foreach ($data as $k => $v) { - if (self::_matchToken($k, $token)) { - if ($conditions && self::_matches($v, $conditions)) { + if (static::_matchToken($k, $token)) { + if ($conditions && static::_matches($v, $conditions)) { $data[$k] = array_merge($v, $values); continue; } if (!$conditions) { - $data[$k] = self::insert($v, $nextPath, $values); + $data[$k] = static::insert($v, $nextPath, $values); } } } @@ -345,22 +345,22 @@ public static function remove(array $data, $path) { } if (strpos($path, '{') === false && strpos($path, '[') === false) { - return self::_simpleOp('remove', $data, $tokens); + return static::_simpleOp('remove', $data, $tokens); } $token = array_shift($tokens); $nextPath = implode('.', $tokens); - list($token, $conditions) = self::_splitConditions($token); + list($token, $conditions) = static::_splitConditions($token); foreach ($data as $k => $v) { - $match = self::_matchToken($k, $token); + $match = static::_matchToken($k, $token); if ($match && is_array($v)) { - if ($conditions && self::_matches($v, $conditions)) { + if ($conditions && static::_matches($v, $conditions)) { unset($data[$k]); continue; } - $data[$k] = self::remove($v, $nextPath); + $data[$k] = static::remove($v, $nextPath); if (empty($data[$k])) { unset($data[$k]); } @@ -392,9 +392,9 @@ public static function combine(array $data, $keyPath, $valuePath = null, $groupP if (is_array($keyPath)) { $format = array_shift($keyPath); - $keys = self::format($data, $keyPath, $format); + $keys = static::format($data, $keyPath, $format); } else { - $keys = self::extract($data, $keyPath); + $keys = static::extract($data, $keyPath); } if (empty($keys)) { return array(); @@ -402,9 +402,9 @@ public static function combine(array $data, $keyPath, $valuePath = null, $groupP if (!empty($valuePath) && is_array($valuePath)) { $format = array_shift($valuePath); - $vals = self::format($data, $valuePath, $format); + $vals = static::format($data, $valuePath, $format); } elseif (!empty($valuePath)) { - $vals = self::extract($data, $valuePath); + $vals = static::extract($data, $valuePath); } if (empty($vals)) { $vals = array_fill(0, count($keys), null); @@ -418,7 +418,7 @@ public static function combine(array $data, $keyPath, $valuePath = null, $groupP } if ($groupPath !== null) { - $group = self::extract($data, $groupPath); + $group = static::extract($data, $groupPath); if (!empty($group)) { $c = count($keys); for ($i = 0; $i < $c; $i++) { @@ -469,7 +469,7 @@ public static function format(array $data, array $paths, $format) { } for ($i = 0; $i < $count; $i++) { - $extracted[] = self::extract($data, $paths[$i]); + $extracted[] = static::extract($data, $paths[$i]); } $out = array(); $data = $extracted; @@ -539,7 +539,7 @@ public static function contains(array $data, array $needle) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::check */ public static function check(array $data, $path) { - $results = self::extract($data, $path); + $results = static::extract($data, $path); if (!is_array($results)) { return false; } @@ -551,14 +551,14 @@ public static function check(array $data, $path) { * * @param array $data Either an array to filter, or value when in callback * @param callable $callback A function to filter the data with. Defaults to - * `self::_filter()` Which strips out all non-zero empty values. + * `static::_filter()` Which strips out all non-zero empty values. * @return array Filtered array * @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::filter */ public static function filter(array $data, $callback = array('self', '_filter')) { foreach ($data as $k => $v) { if (is_array($v)) { - $data[$k] = self::filter($v, $callback); + $data[$k] = static::filter($v, $callback); } } return array_filter($data, $callback); @@ -781,7 +781,7 @@ public static function maxDimensions($data) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::map */ public static function map(array $data, $path, $function) { - $values = (array)self::extract($data, $path); + $values = (array)static::extract($data, $path); return array_map($function, $values); } @@ -795,7 +795,7 @@ public static function map(array $data, $path, $function) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::reduce */ public static function reduce(array $data, $path, $function) { - $values = (array)self::extract($data, $path); + $values = (array)static::extract($data, $path); return array_reduce($values, $function); } @@ -820,7 +820,7 @@ public static function reduce(array $data, $path, $function) { * @return mixed The results of the applied method. */ public static function apply(array $data, $path, $function) { - $values = (array)self::extract($data, $path); + $values = (array)static::extract($data, $path); return call_user_func($function, $values); } @@ -856,7 +856,7 @@ public static function sort(array $data, $path, $dir = 'asc', $type = 'regular') if ($numeric) { $data = array_values($data); } - $sortValues = self::extract($data, $path); + $sortValues = static::extract($data, $path); $sortCount = count($sortValues); $dataCount = count($data); @@ -865,9 +865,9 @@ public static function sort(array $data, $path, $dir = 'asc', $type = 'regular') if ($sortCount < $dataCount) { $sortValues = array_pad($sortValues, $dataCount, null); } - $result = self::_squash($sortValues); - $keys = self::extract($result, '{n}.id'); - $values = self::extract($result, '{n}.value'); + $result = static::_squash($sortValues); + $keys = static::extract($result, '{n}.id'); + $values = static::extract($result, '{n}.value'); $dir = strtolower($dir); $type = strtolower($type); @@ -922,7 +922,7 @@ protected static function _squash($data, $key = null) { $id = $key; } if (is_array($r) && !empty($r)) { - $stack = array_merge($stack, self::_squash($r, $id)); + $stack = array_merge($stack, static::_squash($r, $id)); } else { $stack[] = array('id' => $id, 'value' => $r); } @@ -978,7 +978,7 @@ public static function mergeDiff(array $data, $compare) { if (!array_key_exists($key, $data)) { $data[$key] = $value; } elseif (is_array($value)) { - $data[$key] = self::mergeDiff($data[$key], $compare[$key]); + $data[$key] = static::mergeDiff($data[$key], $compare[$key]); } } return $data; @@ -1052,7 +1052,7 @@ public static function nest(array $data, $options = array()) { ); $return = $idMap = array(); - $ids = self::extract($data, $options['idPath']); + $ids = static::extract($data, $options['idPath']); $idKeys = explode('.', $options['idPath']); array_shift($idKeys); @@ -1063,8 +1063,8 @@ public static function nest(array $data, $options = array()) { foreach ($data as $result) { $result[$options['children']] = array(); - $id = self::get($result, $idKeys); - $parentId = self::get($result, $parentKeys); + $id = static::get($result, $idKeys); + $parentId = static::get($result, $parentKeys); if (isset($idMap[$id][$options['children']])) { $idMap[$id] = array_merge($result, (array)$idMap[$id]); @@ -1087,12 +1087,12 @@ public static function nest(array $data, $options = array()) { if ($options['root']) { $root = $options['root']; } else { - $root = self::get($return[0], $parentKeys); + $root = static::get($return[0], $parentKeys); } foreach ($return as $i => $result) { - $id = self::get($result, $idKeys); - $parentId = self::get($result, $parentKeys); + $id = static::get($result, $idKeys); + $parentId = static::get($result, $parentKeys); if ($id !== $root && $parentId != $root) { unset($return[$i]); } diff --git a/lib/Cake/Utility/Inflector.php b/lib/Cake/Utility/Inflector.php index 6863d95bb19..6644661c349 100644 --- a/lib/Cake/Utility/Inflector.php +++ b/lib/Cake/Utility/Inflector.php @@ -274,13 +274,13 @@ protected static function _cache($type, $key, $value = false) { $key = '_' . $key; $type = '_' . $type; if ($value !== false) { - self::$_cache[$type][$key] = $value; + static::$_cache[$type][$key] = $value; return $value; } - if (!isset(self::$_cache[$type][$key])) { + if (!isset(static::$_cache[$type][$key])) { return false; } - return self::$_cache[$type][$key]; + return static::$_cache[$type][$key]; } /** @@ -290,13 +290,13 @@ protected static function _cache($type, $key, $value = false) { * @return void */ public static function reset() { - if (empty(self::$_initialState)) { - self::$_initialState = get_class_vars('Inflector'); + if (empty(static::$_initialState)) { + static::$_initialState = get_class_vars('Inflector'); return; } - foreach (self::$_initialState as $key => $val) { + foreach (static::$_initialState as $key => $val) { if ($key !== '_initialState') { - self::${$key} = $val; + static::${$key} = $val; } } } @@ -328,9 +328,9 @@ public static function rules($type, $rules, $reset = false) { switch ($type) { case 'transliteration': if ($reset) { - self::$_transliteration = $rules; + static::$_transliteration = $rules; } else { - self::$_transliteration = $rules + self::$_transliteration; + static::$_transliteration = $rules + static::$_transliteration; } break; @@ -338,26 +338,26 @@ public static function rules($type, $rules, $reset = false) { foreach ($rules as $rule => $pattern) { if (is_array($pattern)) { if ($reset) { - self::${$var}[$rule] = $pattern; + static::${$var}[$rule] = $pattern; } else { if ($rule === 'uninflected') { - self::${$var}[$rule] = array_merge($pattern, self::${$var}[$rule]); + static::${$var}[$rule] = array_merge($pattern, static::${$var}[$rule]); } else { - self::${$var}[$rule] = $pattern + self::${$var}[$rule]; + static::${$var}[$rule] = $pattern + static::${$var}[$rule]; } } - unset($rules[$rule], self::${$var}['cache' . ucfirst($rule)]); - if (isset(self::${$var}['merged'][$rule])) { - unset(self::${$var}['merged'][$rule]); + unset($rules[$rule], static::${$var}['cache' . ucfirst($rule)]); + if (isset(static::${$var}['merged'][$rule])) { + unset(static::${$var}['merged'][$rule]); } if ($type === 'plural') { - self::$_cache['pluralize'] = self::$_cache['tableize'] = array(); + static::$_cache['pluralize'] = static::$_cache['tableize'] = array(); } elseif ($type === 'singular') { - self::$_cache['singularize'] = array(); + static::$_cache['singularize'] = array(); } } } - self::${$var}['rules'] = $rules + self::${$var}['rules']; + static::${$var}['rules'] = $rules + static::${$var}['rules']; } } @@ -369,39 +369,39 @@ public static function rules($type, $rules, $reset = false) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::pluralize */ public static function pluralize($word) { - if (isset(self::$_cache['pluralize'][$word])) { - return self::$_cache['pluralize'][$word]; + if (isset(static::$_cache['pluralize'][$word])) { + return static::$_cache['pluralize'][$word]; } - if (!isset(self::$_plural['merged']['irregular'])) { - self::$_plural['merged']['irregular'] = self::$_plural['irregular']; + if (!isset(static::$_plural['merged']['irregular'])) { + static::$_plural['merged']['irregular'] = static::$_plural['irregular']; } - if (!isset(self::$_plural['merged']['uninflected'])) { - self::$_plural['merged']['uninflected'] = array_merge(self::$_plural['uninflected'], self::$_uninflected); + if (!isset(static::$_plural['merged']['uninflected'])) { + static::$_plural['merged']['uninflected'] = array_merge(static::$_plural['uninflected'], static::$_uninflected); } - if (!isset(self::$_plural['cacheUninflected']) || !isset(self::$_plural['cacheIrregular'])) { - self::$_plural['cacheUninflected'] = '(?:' . implode('|', self::$_plural['merged']['uninflected']) . ')'; - self::$_plural['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$_plural['merged']['irregular'])) . ')'; + if (!isset(static::$_plural['cacheUninflected']) || !isset(static::$_plural['cacheIrregular'])) { + static::$_plural['cacheUninflected'] = '(?:' . implode('|', static::$_plural['merged']['uninflected']) . ')'; + static::$_plural['cacheIrregular'] = '(?:' . implode('|', array_keys(static::$_plural['merged']['irregular'])) . ')'; } - if (preg_match('/(.*?(?:\\b|_))(' . self::$_plural['cacheIrregular'] . ')$/i', $word, $regs)) { - self::$_cache['pluralize'][$word] = $regs[1] . + if (preg_match('/(.*?(?:\\b|_))(' . static::$_plural['cacheIrregular'] . ')$/i', $word, $regs)) { + static::$_cache['pluralize'][$word] = $regs[1] . substr($regs[2], 0, 1) . - substr(self::$_plural['merged']['irregular'][strtolower($regs[2])], 1); - return self::$_cache['pluralize'][$word]; + substr(static::$_plural['merged']['irregular'][strtolower($regs[2])], 1); + return static::$_cache['pluralize'][$word]; } - if (preg_match('/^(' . self::$_plural['cacheUninflected'] . ')$/i', $word, $regs)) { - self::$_cache['pluralize'][$word] = $word; + if (preg_match('/^(' . static::$_plural['cacheUninflected'] . ')$/i', $word, $regs)) { + static::$_cache['pluralize'][$word] = $word; return $word; } - foreach (self::$_plural['rules'] as $rule => $replacement) { + foreach (static::$_plural['rules'] as $rule => $replacement) { if (preg_match($rule, $word)) { - self::$_cache['pluralize'][$word] = preg_replace($rule, $replacement, $word); - return self::$_cache['pluralize'][$word]; + static::$_cache['pluralize'][$word] = preg_replace($rule, $replacement, $word); + return static::$_cache['pluralize'][$word]; } } } @@ -414,48 +414,48 @@ public static function pluralize($word) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::singularize */ public static function singularize($word) { - if (isset(self::$_cache['singularize'][$word])) { - return self::$_cache['singularize'][$word]; + if (isset(static::$_cache['singularize'][$word])) { + return static::$_cache['singularize'][$word]; } - if (!isset(self::$_singular['merged']['uninflected'])) { - self::$_singular['merged']['uninflected'] = array_merge( - self::$_singular['uninflected'], - self::$_uninflected + if (!isset(static::$_singular['merged']['uninflected'])) { + static::$_singular['merged']['uninflected'] = array_merge( + static::$_singular['uninflected'], + static::$_uninflected ); } - if (!isset(self::$_singular['merged']['irregular'])) { - self::$_singular['merged']['irregular'] = array_merge( - self::$_singular['irregular'], - array_flip(self::$_plural['irregular']) + if (!isset(static::$_singular['merged']['irregular'])) { + static::$_singular['merged']['irregular'] = array_merge( + static::$_singular['irregular'], + array_flip(static::$_plural['irregular']) ); } - if (!isset(self::$_singular['cacheUninflected']) || !isset(self::$_singular['cacheIrregular'])) { - self::$_singular['cacheUninflected'] = '(?:' . implode('|', self::$_singular['merged']['uninflected']) . ')'; - self::$_singular['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$_singular['merged']['irregular'])) . ')'; + if (!isset(static::$_singular['cacheUninflected']) || !isset(static::$_singular['cacheIrregular'])) { + static::$_singular['cacheUninflected'] = '(?:' . implode('|', static::$_singular['merged']['uninflected']) . ')'; + static::$_singular['cacheIrregular'] = '(?:' . implode('|', array_keys(static::$_singular['merged']['irregular'])) . ')'; } - if (preg_match('/(.*?(?:\\b|_))(' . self::$_singular['cacheIrregular'] . ')$/i', $word, $regs)) { - self::$_cache['singularize'][$word] = $regs[1] . + if (preg_match('/(.*?(?:\\b|_))(' . static::$_singular['cacheIrregular'] . ')$/i', $word, $regs)) { + static::$_cache['singularize'][$word] = $regs[1] . substr($regs[2], 0, 1) . - substr(self::$_singular['merged']['irregular'][strtolower($regs[2])], 1); - return self::$_cache['singularize'][$word]; + substr(static::$_singular['merged']['irregular'][strtolower($regs[2])], 1); + return static::$_cache['singularize'][$word]; } - if (preg_match('/^(' . self::$_singular['cacheUninflected'] . ')$/i', $word, $regs)) { - self::$_cache['singularize'][$word] = $word; + if (preg_match('/^(' . static::$_singular['cacheUninflected'] . ')$/i', $word, $regs)) { + static::$_cache['singularize'][$word] = $word; return $word; } - foreach (self::$_singular['rules'] as $rule => $replacement) { + foreach (static::$_singular['rules'] as $rule => $replacement) { if (preg_match($rule, $word)) { - self::$_cache['singularize'][$word] = preg_replace($rule, $replacement, $word); - return self::$_cache['singularize'][$word]; + static::$_cache['singularize'][$word] = preg_replace($rule, $replacement, $word); + return static::$_cache['singularize'][$word]; } } - self::$_cache['singularize'][$word] = $word; + static::$_cache['singularize'][$word] = $word; return $word; } @@ -467,9 +467,9 @@ public static function singularize($word) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::camelize */ public static function camelize($lowerCaseAndUnderscoredWord) { - if (!($result = self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) { + if (!($result = static::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) { $result = str_replace(' ', '', Inflector::humanize($lowerCaseAndUnderscoredWord)); - self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord, $result); + static::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord, $result); } return $result; } @@ -482,10 +482,10 @@ public static function camelize($lowerCaseAndUnderscoredWord) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::underscore */ public static function underscore($camelCasedWord) { - if (!($result = self::_cache(__FUNCTION__, $camelCasedWord))) { + if (!($result = static::_cache(__FUNCTION__, $camelCasedWord))) { $underscoredWord = preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $camelCasedWord); $result = mb_strtolower($underscoredWord); - self::_cache(__FUNCTION__, $camelCasedWord, $result); + static::_cache(__FUNCTION__, $camelCasedWord, $result); } return $result; } @@ -499,13 +499,13 @@ public static function underscore($camelCasedWord) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::humanize */ public static function humanize($lowerCaseAndUnderscoredWord) { - if (!($result = self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) { + if (!($result = static::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) { $result = explode(' ', str_replace('_', ' ', $lowerCaseAndUnderscoredWord)); foreach ($result as &$word) { $word = mb_strtoupper(mb_substr($word, 0, 1)) . mb_substr($word, 1); } $result = implode(' ', $result); - self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord, $result); + static::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord, $result); } return $result; } @@ -518,9 +518,9 @@ public static function humanize($lowerCaseAndUnderscoredWord) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::tableize */ public static function tableize($className) { - if (!($result = self::_cache(__FUNCTION__, $className))) { + if (!($result = static::_cache(__FUNCTION__, $className))) { $result = Inflector::pluralize(Inflector::underscore($className)); - self::_cache(__FUNCTION__, $className, $result); + static::_cache(__FUNCTION__, $className, $result); } return $result; } @@ -533,9 +533,9 @@ public static function tableize($className) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::classify */ public static function classify($tableName) { - if (!($result = self::_cache(__FUNCTION__, $tableName))) { + if (!($result = static::_cache(__FUNCTION__, $tableName))) { $result = Inflector::camelize(Inflector::singularize($tableName)); - self::_cache(__FUNCTION__, $tableName, $result); + static::_cache(__FUNCTION__, $tableName, $result); } return $result; } @@ -548,11 +548,11 @@ public static function classify($tableName) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::variable */ public static function variable($string) { - if (!($result = self::_cache(__FUNCTION__, $string))) { + if (!($result = static::_cache(__FUNCTION__, $string))) { $camelized = Inflector::camelize(Inflector::underscore($string)); $replace = strtolower(substr($camelized, 0, 1)); $result = preg_replace('/\\w/', $replace, $camelized, 1); - self::_cache(__FUNCTION__, $string, $result); + static::_cache(__FUNCTION__, $string, $result); } return $result; } @@ -575,7 +575,7 @@ public static function slug($string, $replacement = '_') { sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '', ); - $map = self::$_transliteration + $merge; + $map = static::$_transliteration + $merge; return preg_replace(array_keys($map), array_values($map), $string); } diff --git a/lib/Cake/Utility/Security.php b/lib/Cake/Utility/Security.php index fe237b842bb..6ad3c01c14d 100644 --- a/lib/Cake/Utility/Security.php +++ b/lib/Cake/Utility/Security.php @@ -105,12 +105,12 @@ public static function validateAuthKey($authKey) { */ public static function hash($string, $type = null, $salt = false) { if (empty($type)) { - $type = self::$hashType; + $type = static::$hashType; } $type = strtolower($type); if ($type === 'blowfish') { - return self::_crypt($string, $salt); + return static::_crypt($string, $salt); } if ($salt) { if (!is_string($salt)) { @@ -145,7 +145,7 @@ public static function hash($string, $type = null, $salt = false) { * @see Security::hash() */ public static function setHash($hash) { - self::$hashType = $hash; + static::$hashType = $hash; } /** @@ -163,7 +163,7 @@ public static function setCost($cost) { ), E_USER_WARNING); return null; } - self::$hashCost = $cost; + static::$hashCost = $cost; } /** @@ -273,8 +273,8 @@ protected static function _salt($length = 22) { */ protected static function _crypt($password, $salt = false) { if ($salt === false) { - $salt = self::_salt(22); - $salt = vsprintf('$2a$%02d$%s', array(self::$hashCost, $salt)); + $salt = static::_salt(22); + $salt = vsprintf('$2a$%02d$%s', array(static::$hashCost, $salt)); } $invalidCipher = ( @@ -307,7 +307,7 @@ protected static function _crypt($password, $salt = false) { * @throws CakeException On invalid data or key. */ public static function encrypt($plain, $key, $hmacSalt = null) { - self::_checkKey($key, 'encrypt()'); + static::_checkKey($key, 'encrypt()'); if ($hmacSalt === null) { $hmacSalt = Configure::read('Security.salt'); @@ -350,7 +350,7 @@ protected static function _checkKey($key, $method) { * @throws CakeException On invalid data or key. */ public static function decrypt($cipher, $key, $hmacSalt = null) { - self::_checkKey($key, 'decrypt()'); + static::_checkKey($key, 'decrypt()'); if (empty($cipher)) { throw new CakeException(__d('cake_dev', 'The data to decrypt cannot be empty.')); } diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index 53d791ce4b1..6cdd745b0b2 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -58,7 +58,7 @@ class Validation { */ public static function notEmpty($check) { trigger_error('Validation::notEmpty() is deprecated. Use Validation::notBlank() instead.', E_USER_DEPRECATED); - return self::notBlank($check); + return static::notBlank($check); } /** @@ -74,13 +74,13 @@ public static function notEmpty($check) { */ public static function notBlank($check) { if (is_array($check)) { - extract(self::_defaults($check)); + extract(static::_defaults($check)); } if (empty($check) && (string)$check !== '0') { return false; } - return self::_check($check, '/[^\s]+/m'); + return static::_check($check, '/[^\s]+/m'); } /** @@ -96,13 +96,13 @@ public static function notBlank($check) { */ public static function alphaNumeric($check) { if (is_array($check)) { - extract(self::_defaults($check)); + extract(static::_defaults($check)); } if (empty($check) && $check != '0') { return false; } - return self::_check($check, '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]+$/Du'); + return static::_check($check, '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]+$/Du'); } /** @@ -131,7 +131,7 @@ public static function lengthBetween($check, $min, $max) { * @deprecated Deprecated 2.6. Use Validator::lengthBetween() instead. */ public static function between($check, $min, $max) { - return self::lengthBetween($check, $min, $max); + return static::lengthBetween($check, $min, $max); } /** @@ -146,9 +146,9 @@ public static function between($check, $min, $max) { */ public static function blank($check) { if (is_array($check)) { - extract(self::_defaults($check)); + extract(static::_defaults($check)); } - return !self::_check($check, '/[^\\s]/'); + return !static::_check($check, '/[^\\s]/'); } /** @@ -167,7 +167,7 @@ public static function blank($check) { */ public static function cc($check, $type = 'fast', $deep = false, $regex = null) { if (is_array($check)) { - extract(self::_defaults($check)); + extract(static::_defaults($check)); } $check = str_replace(array('-', ' '), '', $check); @@ -176,8 +176,8 @@ public static function cc($check, $type = 'fast', $deep = false, $regex = null) } if ($regex !== null) { - if (self::_check($check, $regex)) { - return self::luhn($check, $deep); + if (static::_check($check, $regex)) { + return static::luhn($check, $deep); } } $cards = array( @@ -205,23 +205,23 @@ public static function cc($check, $type = 'fast', $deep = false, $regex = null) foreach ($type as $value) { $regex = $cards['all'][strtolower($value)]; - if (self::_check($check, $regex)) { - return self::luhn($check, $deep); + if (static::_check($check, $regex)) { + return static::luhn($check, $deep); } } } elseif ($type === 'all') { foreach ($cards['all'] as $value) { $regex = $value; - if (self::_check($check, $regex)) { - return self::luhn($check, $deep); + if (static::_check($check, $regex)) { + return static::luhn($check, $deep); } } } else { $regex = $cards['fast']; - if (self::_check($check, $regex)) { - return self::luhn($check, $deep); + if (static::_check($check, $regex)) { + return static::luhn($check, $deep); } } return false; @@ -282,7 +282,7 @@ public static function comparison($check1, $operator = null, $check2 = null) { } break; default: - self::$errors[] = __d('cake_dev', 'You must define the $operator parameter for %s', 'Validation::comparison()'); + static::$errors[] = __d('cake_dev', 'You must define the $operator parameter for %s', 'Validation::comparison()'); } return false; } @@ -297,13 +297,13 @@ public static function comparison($check1, $operator = null, $check2 = null) { */ public static function custom($check, $regex = null) { if (is_array($check)) { - extract(self::_defaults($check)); + extract(static::_defaults($check)); } if ($regex === null) { - self::$errors[] = __d('cake_dev', 'You must define a regular expression for %s', 'Validation::custom()'); + static::$errors[] = __d('cake_dev', 'You must define a regular expression for %s', 'Validation::custom()'); return false; } - return self::_check($check, $regex); + return static::_check($check, $regex); } /** @@ -332,7 +332,7 @@ public static function custom($check, $regex = null) { */ public static function date($check, $format = 'ymd', $regex = null) { if ($regex !== null) { - return self::_check($check, $regex); + return static::_check($check, $regex); } $month = '(0[123456789]|10|11|12)'; $separator = '([- /.])'; @@ -366,7 +366,7 @@ public static function date($check, $format = 'ymd', $regex = null) { $format = (is_array($format)) ? array_values($format) : array($format); foreach ($format as $key) { - if (self::_check($check, $regex[$key]) === true) { + if (static::_check($check, $regex[$key]) === true) { return true; } } @@ -391,7 +391,7 @@ public static function datetime($check, $dateFormat = 'ymd', $regex = null) { if (!empty($parts) && count($parts) > 1) { $time = array_pop($parts); $date = implode(' ', $parts); - $valid = self::date($date, $dateFormat, $regex) && self::time($time); + $valid = static::date($date, $dateFormat, $regex) && static::time($time); } return $valid; } @@ -405,7 +405,7 @@ public static function datetime($check, $dateFormat = 'ymd', $regex = null) { * @return bool Success */ public static function time($check) { - return self::_check($check, '%^((0?[1-9]|1[012])(:[0-5]\d){0,2} ?([AP]M|[ap]m))$|^([01]\d|2[0-3])(:[0-5]\d){0,2}$%'); + return static::_check($check, '%^((0?[1-9]|1[012])(:[0-5]\d){0,2} ?([AP]M|[ap]m))$|^([01]\d|2[0-3])(:[0-5]\d){0,2}$%'); } /** @@ -461,7 +461,7 @@ public static function decimal($check, $places = null, $regex = null) { $check = str_replace($data['thousands_sep'], '', $check); $check = str_replace($data['decimal_point'], '.', $check); - return self::_check($check, $regex); + return static::_check($check, $regex); } /** @@ -477,18 +477,18 @@ public static function decimal($check, $places = null, $regex = null) { */ public static function email($check, $deep = false, $regex = null) { if (is_array($check)) { - extract(self::_defaults($check)); + extract(static::_defaults($check)); } if ($regex === null) { - $regex = '/^[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . self::$_pattern['hostname'] . '$/ui'; + $regex = '/^[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . static::$_pattern['hostname'] . '$/ui'; } - $return = self::_check($check, $regex); + $return = static::_check($check, $regex); if ($deep === false || $deep === null) { return $return; } - if ($return === true && preg_match('/@(' . self::$_pattern['hostname'] . ')$/i', $check, $regs)) { + if ($return === true && preg_match('/@(' . static::$_pattern['hostname'] . ')$/i', $check, $regs)) { if (function_exists('getmxrr') && getmxrr($regs[1], $mxhosts)) { return true; } @@ -520,7 +520,7 @@ public static function equalTo($check, $comparedTo) { */ public static function extension($check, $extensions = array('gif', 'jpeg', 'png', 'jpg')) { if (is_array($check)) { - return self::extension(array_shift($check), $extensions); + return static::extension(array_shift($check), $extensions); } $extension = strtolower(pathinfo($check, PATHINFO_EXTENSION)); foreach ($extensions as $value) { @@ -586,7 +586,7 @@ public static function money($check, $symbolPosition = 'left') { } else { $regex = '/^(?!\x{00a2})\p{Sc}?' . $money . '$/u'; } - return self::_check($check, $regex); + return static::_check($check, $regex); } /** @@ -654,7 +654,7 @@ public static function numeric($check) { */ public static function naturalNumber($check, $allowZero = false) { $regex = $allowZero ? '/^(?:0|[1-9][0-9]*)$/' : '/^[1-9][0-9]*$/'; - return self::_check($check, $regex); + return static::_check($check, $regex); } /** @@ -667,7 +667,7 @@ public static function naturalNumber($check, $allowZero = false) { */ public static function phone($check, $regex = null, $country = 'all') { if (is_array($check)) { - extract(self::_defaults($check)); + extract(static::_defaults($check)); } if ($regex === null) { @@ -697,9 +697,9 @@ public static function phone($check, $regex = null, $country = 'all') { } } if (empty($regex)) { - return self::_pass('phone', $check, $country); + return static::_pass('phone', $check, $country); } - return self::_check($check, $regex); + return static::_check($check, $regex); } /** @@ -712,7 +712,7 @@ public static function phone($check, $regex = null, $country = 'all') { */ public static function postal($check, $regex = null, $country = 'us') { if (is_array($check)) { - extract(self::_defaults($check)); + extract(static::_defaults($check)); } if ($regex === null) { @@ -738,9 +738,9 @@ public static function postal($check, $regex = null, $country = 'us') { } } if (empty($regex)) { - return self::_pass('postal', $check, $country); + return static::_pass('postal', $check, $country); } - return self::_check($check, $regex); + return static::_check($check, $regex); } /** @@ -774,7 +774,7 @@ public static function range($check, $lower = null, $upper = null) { */ public static function ssn($check, $regex = null, $country = null) { if (is_array($check)) { - extract(self::_defaults($check)); + extract(static::_defaults($check)); } if ($regex === null) { @@ -791,9 +791,9 @@ public static function ssn($check, $regex = null, $country = null) { } } if (empty($regex)) { - return self::_pass('ssn', $check, $country); + return static::_pass('ssn', $check, $country); } - return self::_check($check, $regex); + return static::_check($check, $regex); } /** @@ -814,14 +814,14 @@ public static function ssn($check, $regex = null, $country = null) { * @return bool Success */ public static function url($check, $strict = false) { - self::_populateIp(); + static::_populateIp(); $validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~[]') . '\/0-9\p{L}\p{N}]|(%[0-9a-f]{2}))'; $regex = '/^(?:(?:https?|ftps?|sftp|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') . - '(?:' . self::$_pattern['IPv4'] . '|\[' . self::$_pattern['IPv6'] . '\]|' . self::$_pattern['hostname'] . ')(?::[1-9][0-9]{0,4})?' . + '(?:' . static::$_pattern['IPv4'] . '|\[' . static::$_pattern['IPv6'] . '\]|' . static::$_pattern['hostname'] . ')(?::[1-9][0-9]{0,4})?' . '(?:\/?|\/' . $validChars . '*)?' . '(?:\?' . $validChars . '*)?' . '(?:#' . $validChars . '*)?$/iu'; - return self::_check($check, $regex); + return static::_check($check, $regex); } /** @@ -863,7 +863,7 @@ public static function userDefined($check, $object, $method, $args = null) { */ public static function uuid($check) { $regex = '/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[0-5][a-fA-F0-9]{3}-[089aAbB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$/'; - return self::_check($check, $regex); + return static::_check($check, $regex); } /** @@ -912,7 +912,7 @@ protected static function _check($check, $regex) { * @return void */ protected static function _defaults($params) { - self::_reset(); + static::_reset(); $defaults = array( 'check' => null, 'regex' => null, @@ -937,7 +937,7 @@ protected static function _defaults($params) { */ public static function luhn($check, $deep = false) { if (is_array($check)) { - extract(self::_defaults($check)); + extract(static::_defaults($check)); } if ($deep !== true) { return true; @@ -981,7 +981,7 @@ public static function mimeType($check, $mimeTypes = array()) { } if (is_string($mimeTypes)) { - return self::_check($mime, $mimeTypes); + return static::_check($mime, $mimeTypes); } foreach ($mimeTypes as $key => $val) { @@ -1008,7 +1008,7 @@ public static function fileSize($check, $operator = null, $size = null) { } $filesize = filesize($check); - return self::comparison($filesize, $operator, $size); + return static::comparison($filesize, $operator, $size); } /** @@ -1032,7 +1032,7 @@ public static function uploadError($check) { * @return void */ protected static function _populateIp() { - if (!isset(self::$_pattern['IPv6'])) { + if (!isset(static::$_pattern['IPv6'])) { $pattern = '((([0-9A-Fa-f]{1,4}:){7}(([0-9A-Fa-f]{1,4})|:))|(([0-9A-Fa-f]{1,4}:){6}'; $pattern .= '(:|((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})'; $pattern .= '|(:[0-9A-Fa-f]{1,4})))|(([0-9A-Fa-f]{1,4}:){5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})'; @@ -1048,11 +1048,11 @@ protected static function _populateIp() { $pattern .= '\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4})'; $pattern .= '{1,2})))|(((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})))(%.+)?'; - self::$_pattern['IPv6'] = $pattern; + static::$_pattern['IPv6'] = $pattern; } - if (!isset(self::$_pattern['IPv4'])) { + if (!isset(static::$_pattern['IPv4'])) { $pattern = '(?:(?:25[0-5]|2[0-4][0-9]|(?:(?:1[0-9])?|[1-9]?)[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|(?:(?:1[0-9])?|[1-9]?)[0-9])'; - self::$_pattern['IPv4'] = $pattern; + static::$_pattern['IPv4'] = $pattern; } } @@ -1062,7 +1062,7 @@ protected static function _populateIp() { * @return void */ protected static function _reset() { - self::$errors = array(); + static::$errors = array(); } } diff --git a/lib/Cake/Utility/Xml.php b/lib/Cake/Utility/Xml.php index 74d88494d41..95bb4659e14 100644 --- a/lib/Cake/Utility/Xml.php +++ b/lib/Cake/Utility/Xml.php @@ -99,11 +99,11 @@ public static function build($input, $options = array()) { $options += $defaults; if (is_array($input) || is_object($input)) { - return self::fromArray((array)$input, $options); + return static::fromArray((array)$input, $options); } elseif (strpos($input, '<') !== false) { - return self::_loadXml($input, $options); + return static::_loadXml($input, $options); } elseif ($options['readFile'] && file_exists($input)) { - return self::_loadXml(file_get_contents($input), $options); + return static::_loadXml(file_get_contents($input), $options); } elseif ($options['readFile'] && strpos($input, 'http://') === 0 || strpos($input, 'https://') === 0) { try { $socket = new HttpSocket(array('request' => array('redirect' => 10))); @@ -111,7 +111,7 @@ public static function build($input, $options = array()) { if (!$response->isOk()) { throw new XmlException(__d('cake_dev', 'XML cannot be read.')); } - return self::_loadXml($response->body, $options); + return static::_loadXml($response->body, $options); } catch (SocketException $e) { throw new XmlException(__d('cake_dev', 'XML cannot be read.')); } @@ -218,7 +218,7 @@ public static function fromArray($input, $options = array()) { if ($options['pretty']) { $dom->formatOutput = true; } - self::_fromArray($dom, $dom, $input, $options['format']); + static::_fromArray($dom, $dom, $input, $options['format']); $options['return'] = strtolower($options['return']); if ($options['return'] === 'simplexml' || $options['return'] === 'simplexmlelement') { @@ -282,10 +282,10 @@ protected static function _fromArray($dom, $node, &$data, $format) { foreach ($value as $item) { $itemData = compact('dom', 'node', 'key', 'format'); $itemData['value'] = $item; - self::_createChild($itemData); + static::_createChild($itemData); } } else { // Struct - self::_createChild(compact('dom', 'node', 'key', 'value', 'format')); + static::_createChild(compact('dom', 'node', 'key', 'value', 'format')); } } } else { @@ -324,7 +324,7 @@ protected static function _createChild($data) { $child->setAttribute('xmlns', $childNS); } - self::_fromArray($dom, $child, $value, $format); + static::_fromArray($dom, $child, $value, $format); $node->appendChild($child); } @@ -344,7 +344,7 @@ public static function toArray($obj) { } $result = array(); $namespaces = array_merge(array('' => ''), $obj->getNamespaces(true)); - self::_toArray($obj, $result, '', array_keys($namespaces)); + static::_toArray($obj, $result, '', array_keys($namespaces)); return $result; } @@ -369,7 +369,7 @@ protected static function _toArray($xml, &$parentData, $ns, $namespaces) { } foreach ($xml->children($namespace, true) as $child) { - self::_toArray($child, $data, $namespace, $namespaces); + static::_toArray($child, $data, $namespace, $namespaces); } } diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 1edbe75513e..257124834de 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -428,7 +428,7 @@ public function create($model = null, $options = array()) { case 'delete': $append .= $this->hidden('_method', array( 'name' => '_method', 'value' => strtoupper($options['type']), 'id' => null, - 'secure' => self::SECURE_SKIP + 'secure' => static::SECURE_SKIP )); default: $htmlAttributes['method'] = 'post'; @@ -488,7 +488,7 @@ protected function _csrfField() { } return $this->hidden('_Token.key', array( 'value' => $this->request->params['_Token']['key'], 'id' => 'Token' . mt_rand(), - 'secure' => self::SECURE_SKIP + 'secure' => static::SECURE_SKIP )); } @@ -1696,7 +1696,7 @@ public function hidden($fieldName, $options = array()) { unset($options['secure']); $options = $this->_initInputField($fieldName, array_merge( - $options, array('secure' => self::SECURE_SKIP) + $options, array('secure' => static::SECURE_SKIP) )); if ($secure === true) { @@ -1717,7 +1717,7 @@ public function hidden($fieldName, $options = array()) { public function file($fieldName, $options = array()) { $options += array('secure' => true); $secure = $options['secure']; - $options['secure'] = self::SECURE_SKIP; + $options['secure'] = static::SECURE_SKIP; $options = $this->_initInputField($fieldName, $options); $field = $this->entity(); @@ -2067,7 +2067,7 @@ public function select($fieldName, $options = array(), $attributes = array()) { $id = $this->_extractOption('id', $attributes); $attributes = $this->_initInputField($fieldName, array_merge( - (array)$attributes, array('secure' => self::SECURE_SKIP) + (array)$attributes, array('secure' => static::SECURE_SKIP) )); if (is_string($options) && isset($this->_options[$options])) { @@ -3007,7 +3007,7 @@ protected function _initInputField($field, $options = array()) { $result['required'] = true; } - if ($secure === self::SECURE_SKIP) { + if ($secure === static::SECURE_SKIP) { return $result; } diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index 01bacfef58b..e1014fad38b 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -468,7 +468,7 @@ public function render($view = null, $layout = null) { } if ($view !== false && $viewFileName = $this->_getViewFileName($view)) { - $this->_currentType = self::TYPE_VIEW; + $this->_currentType = static::TYPE_VIEW; $this->getEventManager()->dispatch(new CakeEvent('View.beforeRender', $this, array($viewFileName))); $this->Blocks->set('content', $this->_render($viewFileName)); $this->getEventManager()->dispatch(new CakeEvent('View.afterRender', $this, array($viewFileName))); @@ -542,7 +542,7 @@ public function renderLayout($content, $layout = null) { $this->viewVars['title_for_layout'] = $title; $this->Blocks->set('title', $title); - $this->_currentType = self::TYPE_LAYOUT; + $this->_currentType = static::TYPE_LAYOUT; $this->Blocks->set('content', $this->_render($layoutFileName)); $this->getEventManager()->dispatch(new CakeEvent('View.afterLayout', $this, array($layoutFileName))); @@ -728,11 +728,11 @@ public function end() { * @throws LogicException when you extend an element which doesn't exist */ public function extend($name) { - if ($name[0] === '/' || $this->_currentType === self::TYPE_VIEW) { + if ($name[0] === '/' || $this->_currentType === static::TYPE_VIEW) { $parent = $this->_getViewFileName($name); } else { switch ($this->_currentType) { - case self::TYPE_ELEMENT: + case static::TYPE_ELEMENT: $parent = $this->_getElementFileName($name); if (!$parent) { list($plugin, $name) = $this->pluginSplit($name); @@ -745,7 +745,7 @@ public function extend($name) { )); } break; - case self::TYPE_LAYOUT: + case static::TYPE_LAYOUT: $parent = $this->_getLayoutFileName($name); break; default: @@ -1218,7 +1218,7 @@ protected function _elementCache($name, $data, $options) { protected function _renderElement($file, $data, $options) { $current = $this->_current; $restore = $this->_currentType; - $this->_currentType = self::TYPE_ELEMENT; + $this->_currentType = static::TYPE_ELEMENT; if ($options['callbacks']) { $this->getEventManager()->dispatch(new CakeEvent('View.beforeRender', $this, array($file))); From e4b24287353820f2ed85b72dcbc006b088b442bd Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 21 Jul 2015 16:28:17 -0400 Subject: [PATCH 263/336] Fix PHPCS errors. --- lib/Cake/Test/Case/Utility/HashTest.php | 2 +- lib/Cake/Utility/Hash.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index 7976929d3c2..e050ca98261 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -318,7 +318,7 @@ public function testMaxDimensions() { ) ) ), - '2' => array('2.1' => '2.1.1',) + '2' => array('2.1' => '2.1.1') ); $result = Hash::maxDimensions($data); $this->assertEquals($result, 5); diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index 6f5b32abc54..b5245f39435 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -756,7 +756,6 @@ public static function dimensions(array $data) { * number of dimensions in a mixed array. * * @param array $data Array to count dimensions on - * @param int $count counts current depth of this iteration * @return int The maximum number of dimensions in $data * @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::maxDimensions */ From c6e5026767e07585d43ff63de397535d652c18cc Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 22 Jul 2015 00:40:45 -0400 Subject: [PATCH 264/336] Fix issues saveMany & saveAssociated with boolean values. For non-atomic, save operations that include models with boolean fields. The first false value would cause the save to abort. This regression was introduced in #6947. Instead of checking the data from save() we should be boolean casting save() to capture the success/failure. Refs #7069 --- lib/Cake/Model/Model.php | 8 +- lib/Cake/Test/Case/Model/ModelWriteTest.php | 90 +++++++++++++++++++++ 2 files changed, 94 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 6cfe4713acc..bfce2dd41c2 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -1717,7 +1717,7 @@ public function saveField($name, $value, $validate = false) { * - validate: Set to true/false to enable or disable validation. * - fieldList: An array of fields you want to allow for saving. * - callbacks: Set to false to disable callbacks. Using 'before' or 'after' - * will enable only those callbacks. + * will enable only those callbacks. * - `counterCache`: Boolean to control updating of counter caches (if any) * * @param array $fieldList List of fields to allow to be saved @@ -2335,7 +2335,7 @@ public function saveMany($data = null, $options = array()) { if ($options['deep']) { $saved = $this->saveAssociated($record, array('atomic' => false) + $options); } else { - $saved = $this->save($record, array('atomic' => false) + $options); + $saved = (bool)$this->save($record, array('atomic' => false) + $options); } } @@ -2478,7 +2478,7 @@ public function saveAssociated($data = null, $options = array()) { if ($options['deep']) { $saved = $Model->saveAssociated($values, array('atomic' => false) + $options); } else { - $saved = $Model->save($values, array('atomic' => false) + $options); + $saved = (bool)$Model->save($values, array('atomic' => false) + $options); } $validates = ($saved === true || (is_array($saved) && !in_array(false, Hash::flatten($saved), true))); } @@ -2534,7 +2534,7 @@ public function saveAssociated($data = null, $options = array()) { if ($options['deep']) { $saved = $Model->saveAssociated($values, array('atomic' => false) + $options); } else { - $saved = $Model->save($values, $options); + $saved = (bool)$Model->save($values, $options); } } diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index 62818f6f5fc..9e3e7892736 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -7684,6 +7684,37 @@ public function testSaveAllDeepEmptyHasManyHasMany() { $this->assertEquals(2, count($result['Attachment'])); } +/** + * Test that boolean fields don't cause saveMany to fail + * + * @return void + */ + public function testSaveManyBooleanFields() { + $this->loadFixtures('Item', 'Syfile', 'Image'); + $data = array( + array( + 'Item' => array( + 'name' => 'testing', + 'syfile_id' => 1, + 'published' => false + ) + ), + array( + 'Item' => array( + 'name' => 'testing 2', + 'syfile_id' => 1, + 'published' => true + ) + ), + ); + $item = ClassRegistry::init('Item'); + $result = $item->saveMany($data, array('atomic' => false)); + + $this->assertCount(2, $result, '2 records should have been saved.'); + $this->assertTrue($result[0], 'Both should have succeded'); + $this->assertTrue($result[1], 'Both should have succeded'); + } + /** * testSaveManyDeepHasManyValidationFailure method * @@ -7806,6 +7837,65 @@ public function testSaveAssociatedDeepBelongsToHasManyValidateTrueValidationFail ), $TestModel->validationErrors); } +/** + * Test that boolean fields don't cause saveAssociated to fail + * + * @return void + */ + public function testSaveAssociatedHasOneBooleanFields() { + $this->loadFixtures('Item', 'Syfile', 'Image'); + $data = array( + 'Syfile' => array( + 'image_id' => 1, + 'name' => 'Some file', + ), + 'Item' => array( + 'name' => 'testing', + 'published' => false + ), + ); + $syfile = ClassRegistry::init('Syfile'); + $syfile->bindModel(array('hasOne' => array('Item')), false); + $result = $syfile->saveAssociated($data, array('atomic' => false)); + + $this->assertCount(2, $result, '2 records should have been saved.'); + $this->assertTrue($result['Syfile'], 'Both should have succeded'); + $this->assertTrue($result['Item'], 'Both should have succeded'); + } + +/** + * Test that boolean fields don't cause saveAssociated to fail + * + * @return void + */ + public function testSaveAssociatedBelongsToBooleanFields() { + $this->loadFixtures('Item', 'Syfile', 'Image'); + $data = array( + 'Syfile' => array( + 'image_id' => 1, + 'name' => 'Some file', + ), + 'Item' => array( + 'name' => 'testing', + 'syfile_id' => 2, + 'published' => false + ), + ); + $item = ClassRegistry::init('Item'); + $item->bindModel(array( + 'belongsTo' => array( + 'Item' => array( + 'foreignKey' => 'image_id' + ) + ) + ), false); + $result = $item->saveAssociated($data, array('atomic' => false)); + + $this->assertCount(2, $result, '2 records should have been saved.'); + $this->assertTrue($result['Syfile'], 'Both should have succeded'); + $this->assertTrue($result['Item'], 'Both should have succeded'); + } + /** * testUpdateAllBoolean * From e25be3a47e09da9ed48be0137d91cdd87c17d250 Mon Sep 17 00:00:00 2001 From: Yoshiyuki Kinjo Date: Tue, 21 Jul 2015 22:58:50 +0900 Subject: [PATCH 265/336] Add failing test for FormHelper::input FormHelper::input does not respect 'value' option when form is of date/time type. Signed-off-by: mark_story Backport fixes from #7082 to 2.7 --- .../Test/Case/View/Helper/FormHelperTest.php | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 55a917b93f6..0e7738ee3c0 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -2517,6 +2517,61 @@ public function testTimeSelectedWithInterval() { $this->assertContains('', $result); } +/** + * Test interval + value near the hour roll over. + * + * @return void + */ + public function testTimeValueWithInterval() { + $result = $this->Form->input('Model.start_time', array( + 'type' => 'time', + 'interval' => 15, + 'value' => array('hour' => '3', 'min' => '57', 'meridian' => 'pm') + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + + $result = $this->Form->input('Model.start_time', array( + 'type' => 'time', + 'interval' => 15, + 'value' => '2012-10-23 15:57:00' + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + + $result = $this->Form->input('Model.start_time', array( + 'timeFormat' => 24, + 'type' => 'time', + 'interval' => 15, + 'value' => '15:57' + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + + $result = $this->Form->input('Model.start_time', array( + 'timeFormat' => 24, + 'type' => 'time', + 'interval' => 15, + 'value' => '23:57' + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + + $result = $this->Form->input('Model.created', array( + 'timeFormat' => 24, + 'type' => 'datetime', + 'interval' => 15, + 'value' => '2012-09-30 23:56' + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + } + /** * Test time with selected values around 12:xx:xx * @@ -2554,6 +2609,43 @@ public function testTimeSelectedWithIntervalTwelve() { $this->assertContains('', $result); } +/** + * Test time with selected values around 12:xx:xx + * + * @return void + */ + public function testTimeValueWithIntervalTwelve() { + $result = $this->Form->input('Model.start_time', array( + 'type' => 'time', + 'timeFormat' => 12, + 'interval' => 15, + 'value' => '00:00:00' + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + + $result = $this->Form->input('Model.start_time', array( + 'type' => 'time', + 'timeFormat' => 12, + 'interval' => 15, + 'value' => '12:00:00' + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + + $result = $this->Form->input('Model.start_time', array( + 'type' => 'time', + 'timeFormat' => 12, + 'interval' => 15, + 'value' => '12:15:00' + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + } + /** * Test interval & timeFormat = 12 * From 00919c5f01cfcc4ef1338c33101080b834a140c2 Mon Sep 17 00:00:00 2001 From: Yoshiyuki Kinjo Date: Tue, 21 Jul 2015 23:04:20 +0900 Subject: [PATCH 266/336] Fix FormHelper::input ignoring value option. Signed-off-by: mark_story Backport fixes from #7082 to 2.7 --- lib/Cake/View/Helper/FormHelper.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 1edbe75513e..13247ae789b 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -1086,13 +1086,13 @@ protected function _getInput($args) { unset($options['options']); return $this->select($fieldName, $list, $options); case 'time': - $options['value'] = $selected; + $options += array('value' => $selected); return $this->dateTime($fieldName, null, $timeFormat, $options); case 'date': - $options['value'] = $selected; + $options += array('value' => $selected); return $this->dateTime($fieldName, $dateFormat, null, $options); case 'datetime': - $options['value'] = $selected; + $options += array('value' => $selected); return $this->dateTime($fieldName, $dateFormat, $timeFormat, $options); case 'textarea': return $this->textarea($fieldName, $options + array('cols' => '30', 'rows' => '6')); From 94b2ea29a6c289cbcf83fecb8617f2de704e568d Mon Sep 17 00:00:00 2001 From: antograssiot Date: Thu, 23 Jul 2015 05:48:34 +0200 Subject: [PATCH 267/336] enable colors for windows ConEmu user backport of #7090 --- lib/Cake/Console/ConsoleOutput.php | 6 +++--- lib/Cake/Log/Engine/ConsoleLog.php | 2 +- lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Console/ConsoleOutput.php b/lib/Cake/Console/ConsoleOutput.php index d1fb2b9bd7b..f80ae343ecd 100644 --- a/lib/Cake/Console/ConsoleOutput.php +++ b/lib/Cake/Console/ConsoleOutput.php @@ -153,15 +153,15 @@ class ConsoleOutput { /** * Construct the output object. * - * Checks for a pretty console environment. Ansicon allows pretty consoles - * on Windows, and is supported. + * Checks for a pretty console environment. Ansicon and ConEmu allows + * pretty consoles on Windows, and is supported. * * @param string $stream The identifier of the stream to write output to. */ public function __construct($stream = 'php://stdout') { $this->_output = fopen($stream, 'w'); - if ((DS === '\\' && !(bool)env('ANSICON')) || + if ((DS === '\\' && !(bool)env('ANSICON') && env('ConEmuANSI') !== 'ON') || $stream === 'php://output' || (function_exists('posix_isatty') && !posix_isatty($this->_output)) ) { diff --git a/lib/Cake/Log/Engine/ConsoleLog.php b/lib/Cake/Log/Engine/ConsoleLog.php index e7617295786..3c716946edd 100644 --- a/lib/Cake/Log/Engine/ConsoleLog.php +++ b/lib/Cake/Log/Engine/ConsoleLog.php @@ -48,7 +48,7 @@ class ConsoleLog extends BaseLog { */ public function __construct($config = array()) { parent::__construct($config); - if ((DS === '\\' && !(bool)env('ANSICON')) || + if ((DS === '\\' && !(bool)env('ANSICON') && env('ConEmuANSI') !== 'ON') || (function_exists('posix_isatty') && !posix_isatty($this->_output)) ) { $outputAs = ConsoleOutput::PLAIN; diff --git a/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php b/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php index c9a06b7fc1c..8bfd5a2ab0a 100644 --- a/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php +++ b/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php @@ -139,7 +139,7 @@ public function testDefaultOutputAs() { TestCakeLog::config('test_console_log', array( 'engine' => 'TestConsole', )); - if ((DS === '\\' && !(bool)env('ANSICON')) || + if ((DS === '\\' && !(bool)env('ANSICON') && env('ConEmuANSI') !== 'ON') || (function_exists('posix_isatty') && !posix_isatty(null)) ) { $expected = ConsoleOutput::PLAIN; From 71e4ed91aff8e3530cced33e39613b7831afce3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Thu, 23 Jul 2015 17:29:47 +0200 Subject: [PATCH 268/336] Slightly improve the bake templates --- lib/Cake/Console/Templates/default/classes/fixture.ctp | 3 +-- lib/Cake/Console/Templates/default/classes/test.ctp | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/Cake/Console/Templates/default/classes/fixture.ctp b/lib/Cake/Console/Templates/default/classes/fixture.ctp index 0fb23e24fca..7ac2c398772 100644 --- a/lib/Cake/Console/Templates/default/classes/fixture.ctp +++ b/lib/Cake/Console/Templates/default/classes/fixture.ctp @@ -21,8 +21,7 @@ echo " /** - * Fixture - * + * Fixture */ class Fixture extends CakeTestFixture { diff --git a/lib/Cake/Console/Templates/default/classes/test.ctp b/lib/Cake/Console/Templates/default/classes/test.ctp index 8e249f4f28a..2c8daa372cd 100644 --- a/lib/Cake/Console/Templates/default/classes/test.ctp +++ b/lib/Cake/Console/Templates/default/classes/test.ctp @@ -24,7 +24,6 @@ App::uses('', ''); /** * Test Case - * */ class Test extends ControllerTestCase { From b412b405f9ea5a3aff75879f9a165e21822d8a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Thu, 23 Jul 2015 18:03:42 +0200 Subject: [PATCH 269/336] Make fixture import from table aware of records found --- lib/Cake/Console/Command/Task/FixtureTask.php | 11 +++++++++-- .../Case/Console/Command/Task/FixtureTaskTest.php | 8 +++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Console/Command/Task/FixtureTask.php b/lib/Cake/Console/Command/Task/FixtureTask.php index b20c22b4b79..05caa4629f8 100644 --- a/lib/Cake/Console/Command/Task/FixtureTask.php +++ b/lib/Cake/Console/Command/Task/FixtureTask.php @@ -414,19 +414,26 @@ protected function _makeRecordString($records) { * @return array Array of records. */ protected function _getRecordsFromTable($modelName, $useTable = null) { + $modelObject = new Model(array('name' => $modelName, 'table' => $useTable, 'ds' => $this->connection)); if ($this->interactive) { $condition = null; $prompt = __d('cake_console', "Please provide a SQL fragment to use as conditions\nExample: WHERE 1=1"); while (!$condition) { $condition = $this->in($prompt, null, 'WHERE 1=1'); } + + $recordsFound = $modelObject->find('count', array( + 'conditions' => $condition, + 'recursive' => -1, + )); + $prompt = __d('cake_console', "How many records do you want to import?"); - $recordCount = $this->in($prompt, null, 10); + $recordCount = $this->in($prompt, null, ($recordsFound < 10 ) ? $recordsFound : 10); } else { $condition = 'WHERE 1=1'; $recordCount = (isset($this->params['count']) ? $this->params['count'] : 10); } - $modelObject = new Model(array('name' => $modelName, 'table' => $useTable, 'ds' => $this->connection)); + $records = $modelObject->find('all', array( 'conditions' => $condition, 'recursive' => -1, diff --git a/lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php index dd62bd5f6f5..a649b7b7583 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php @@ -186,6 +186,9 @@ public function testImportRecordsFromDatabaseWithConditionsPoo() { $this->Task->interactive = true; $this->Task->expects($this->at(0))->method('in') ->will($this->returnValue('WHERE 1=1')); + $this->Task->expects($this->at(1))->method('in') + ->with($this->anything(), $this->anything(), '3') + ->will($this->returnValue('2')); $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; @@ -197,9 +200,8 @@ public function testImportRecordsFromDatabaseWithConditionsPoo() { $this->assertContains('class ArticleFixture extends CakeTestFixture', $result); $this->assertContains('public $records', $result); $this->assertContains('public $import', $result); - $this->assertContains("'title' => 'First Article'", $result, 'Missing import data %s'); - $this->assertContains('Second Article', $result, 'Missing import data %s'); - $this->assertContains('Third Article', $result, 'Missing import data %s'); + $this->assertContains("'title' => 'First Article'", $result, 'Missing import data'); + $this->assertContains('Second Article', $result, 'Missing import data'); } /** From 45877df3eb2a0d1f41066262bf2efb6e46a7aaf0 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 23 Jul 2015 21:08:54 -0400 Subject: [PATCH 270/336] Update version number to 2.7.1 --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index 907ad6287e1..ea11fc97e39 100644 --- a/lib/Cake/VERSION.txt +++ b/lib/Cake/VERSION.txt @@ -17,4 +17,4 @@ // @license http://www.opensource.org/licenses/mit-license.php MIT License // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -2.7.0 +2.7.1 From 418dcfd7f8a7767bc85bb4c51bde8cc20b3742ff Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 23 Jul 2015 21:42:26 -0400 Subject: [PATCH 271/336] Consistently remove plugin names in object collections. We were sometimes removing plugin prefixes (set, and some subclass methods). But many other methods were missing the pluginSplit() feature. This change makes all of the methods in ObjectCollection strip plugin prefixes, which increases consistency across the framework. Refs #7098 --- .../Case/Utility/ObjectCollectionTest.php | 29 +++++++++++++++++++ lib/Cake/Utility/ObjectCollection.php | 5 ++++ 2 files changed, 34 insertions(+) diff --git a/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php b/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php index c92c4923b1b..4d768d0d866 100644 --- a/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php +++ b/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php @@ -583,4 +583,33 @@ public function testDispatchEventNoSubject() { $this->assertTrue($this->Objects->trigger($event)); } +/** + * test that the various methods ignore plugin prefixes + * + * plugin prefixes should be removed consistently as load() will + * remove them. Furthermore the __get() method does not support + * names with '.' in them. + * + * @return void + */ + public function testPluginPrefixes() { + $this->Objects->load('TestPlugin.First'); + $this->assertTrue($this->Objects->loaded('First')); + $this->assertTrue($this->Objects->loaded('TestPlugin.First')); + + $this->assertTrue($this->Objects->enabled('First')); + $this->assertTrue($this->Objects->enabled('TestPlugin.First')); + + $this->assertNull($this->Objects->disable('TestPlugin.First')); + $this->assertFalse($this->Objects->enabled('First')); + $this->assertFalse($this->Objects->enabled('TestPlugin.First')); + + $this->assertNull($this->Objects->enable('TestPlugin.First')); + $this->assertTrue($this->Objects->enabled('First')); + $this->assertTrue($this->Objects->enabled('TestPlugin.First')); + $this->Objects->setPriority('TestPlugin.First', 1000); + + $result = $this->Objects->prioritize(); + $this->assertEquals(1000, $result['First'][0]); + } } diff --git a/lib/Cake/Utility/ObjectCollection.php b/lib/Cake/Utility/ObjectCollection.php index 4bbb1a3ea41..49e4ae9f89c 100644 --- a/lib/Cake/Utility/ObjectCollection.php +++ b/lib/Cake/Utility/ObjectCollection.php @@ -176,6 +176,7 @@ public function __isset($name) { public function enable($name, $prioritize = true) { $enabled = false; foreach ((array)$name as $object) { + list(, $object) = pluginSplit($object); if (isset($this->_loaded[$object]) && !isset($this->_enabled[$object])) { $priority = $this->defaultPriority; if (isset($this->_loaded[$object]->settings['priority'])) { @@ -219,6 +220,7 @@ public function setPriority($name, $priority = null) { $name = array($name => $priority); } foreach ($name as $object => $objectPriority) { + list(, $object) = pluginSplit($object); if (isset($this->_loaded[$object])) { if ($objectPriority === null) { $objectPriority = $this->defaultPriority; @@ -241,6 +243,7 @@ public function setPriority($name, $priority = null) { */ public function disable($name) { foreach ((array)$name as $object) { + list(, $object) = pluginSplit($object); unset($this->_enabled[$object]); } } @@ -255,6 +258,7 @@ public function disable($name) { */ public function enabled($name = null) { if (!empty($name)) { + list(, $name) = pluginSplit($name); return isset($this->_enabled[$name]); } return array_keys($this->_enabled); @@ -283,6 +287,7 @@ public function attached($name = null) { */ public function loaded($name = null) { if (!empty($name)) { + list(, $name) = pluginSplit($name); return isset($this->_loaded[$name]); } return array_keys($this->_loaded); From b3a192add0e0c50c544b0670b43125efcbbaff05 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 23 Jul 2015 21:49:22 -0400 Subject: [PATCH 272/336] Add warning for irregular method. Refs #7096 --- lib/Cake/View/Helper/FormHelper.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 13247ae789b..f97b1f30c21 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -814,6 +814,10 @@ public function error($field, $text = null, $options = array()) { * * ``` * + * *Warning* Unlike most FormHelper methods, this method does not automatically + * escape the $text parameter. You must escape the $text parameter yourself if you + * are using user supplied data. + * * @param string $fieldName This should be "Modelname.fieldname" * @param string $text Text that will appear in the label field. If * $text is left undefined the text will be inflected from the From a239324a0d6370de86c998bcc1594d4c83474e0c Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Sun, 26 Jul 2015 15:35:03 +0200 Subject: [PATCH 273/336] use constant PHP_SAPI --- lib/Cake/Cache/Engine/XcacheEngine.php | 2 +- lib/Cake/Console/Templates/skel/webroot/index.php | 2 +- lib/Cake/Error/ErrorHandler.php | 2 +- lib/Cake/Test/Case/BasicsTest.php | 8 ++++---- lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php | 2 +- lib/Cake/Test/Case/Network/CakeResponseTest.php | 4 ++-- lib/Cake/Test/Case/Utility/DebuggerTest.php | 8 ++++---- lib/Cake/basics.php | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/Cake/Cache/Engine/XcacheEngine.php b/lib/Cake/Cache/Engine/XcacheEngine.php index 9c185560505..97c85181898 100644 --- a/lib/Cake/Cache/Engine/XcacheEngine.php +++ b/lib/Cake/Cache/Engine/XcacheEngine.php @@ -44,7 +44,7 @@ class XcacheEngine extends CacheEngine { * @return bool True if the engine has been successfully initialized, false if not */ public function init($settings = array()) { - if (php_sapi_name() !== 'cli') { + if (PHP_SAPI !== 'cli') { parent::init(array_merge(array( 'engine' => 'Xcache', 'prefix' => Inflector::slug(APP_DIR) . '_', diff --git a/lib/Cake/Console/Templates/skel/webroot/index.php b/lib/Cake/Console/Templates/skel/webroot/index.php index 4b67fafa4ea..e546e52ca63 100644 --- a/lib/Cake/Console/Templates/skel/webroot/index.php +++ b/lib/Cake/Console/Templates/skel/webroot/index.php @@ -77,7 +77,7 @@ } // for built-in server -if (php_sapi_name() === 'cli-server') { +if (PHP_SAPI === 'cli-server') { if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $_SERVER['PHP_SELF'])) { return false; } diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index bde45f51364..2cce5768991 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -156,7 +156,7 @@ protected static function _getMessage($exception) { $message .= "\nException Attributes: " . var_export($exception->getAttributes(), true); } } - if (php_sapi_name() !== 'cli') { + if (PHP_SAPI !== 'cli') { $request = Router::getRequest(); if ($request) { $message .= "\nRequest URL: " . $request->here(); diff --git a/lib/Cake/Test/Case/BasicsTest.php b/lib/Cake/Test/Case/BasicsTest.php index 25b9e339529..65821693ed3 100644 --- a/lib/Cake/Test/Case/BasicsTest.php +++ b/lib/Cake/Test/Case/BasicsTest.php @@ -952,7 +952,7 @@ public function testDebug() { ########################### EXPECTED; - if (php_sapi_name() === 'cli') { + if (PHP_SAPI === 'cli') { $expected = sprintf($expectedText, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 18); } else { $expected = sprintf($expectedHtml, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 20); @@ -977,7 +977,7 @@ public function testDebug() { ########################### EXPECTED; - if (php_sapi_name() === 'cli') { + if (PHP_SAPI === 'cli') { $expected = sprintf($expectedText, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 18); } else { $expected = sprintf($expectedHtml, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 19); @@ -1043,7 +1043,7 @@ public function testDebug() { * @return void */ public function testPr() { - $this->skipIf(php_sapi_name() === 'cli', 'Skipping web test in cli mode'); + $this->skipIf(PHP_SAPI === 'cli', 'Skipping web test in cli mode'); ob_start(); pr('this is a test'); $result = ob_get_clean(); @@ -1063,7 +1063,7 @@ public function testPr() { * @return void */ public function testPrCli() { - $this->skipIf(php_sapi_name() != 'cli', 'Skipping cli test in web mode'); + $this->skipIf(PHP_SAPI !== 'cli', 'Skipping cli test in web mode'); ob_start(); pr('this is a test'); $result = ob_get_clean(); diff --git a/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php index 91f019b6242..9c56241c2ad 100644 --- a/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php @@ -34,7 +34,7 @@ public function setUp() { parent::setUp(); $this->skipIf(!function_exists('apc_store'), 'Apc is not installed or configured properly.'); - if (php_sapi_name() === 'cli') { + if (PHP_SAPI === 'cli') { $this->skipIf(!ini_get('apc.enable_cli'), 'APC is not enabled for the CLI.'); } diff --git a/lib/Cake/Test/Case/Network/CakeResponseTest.php b/lib/Cake/Test/Case/Network/CakeResponseTest.php index 82a2f04196c..41e2eba074a 100644 --- a/lib/Cake/Test/Case/Network/CakeResponseTest.php +++ b/lib/Cake/Test/Case/Network/CakeResponseTest.php @@ -373,7 +373,7 @@ public function testCache() { * @return void */ public function testCompress() { - if (php_sapi_name() !== 'cli') { + if (PHP_SAPI !== 'cli') { $this->markTestSkipped('The response compression can only be tested in cli.'); } @@ -491,7 +491,7 @@ public function testOutputCompressed() { if (!extension_loaded("zlib")) { $this->markTestSkipped('Skipping further tests for outputCompressed as zlib extension is not loaded'); } - if (php_sapi_name() !== 'cli') { + if (PHP_SAPI !== 'cli') { $this->markTestSkipped('Testing outputCompressed method with compression enabled done only in cli'); } diff --git a/lib/Cake/Test/Case/Utility/DebuggerTest.php b/lib/Cake/Test/Case/Utility/DebuggerTest.php index e967e7776d3..4179a7636e2 100644 --- a/lib/Cake/Test/Case/Utility/DebuggerTest.php +++ b/lib/Cake/Test/Case/Utility/DebuggerTest.php @@ -516,8 +516,8 @@ public function testDump() { Debugger::dump($var); $result = ob_get_clean(); - $open = php_sapi_name() === 'cli' ? "\n" : '
';
-		$close = php_sapi_name() === 'cli' ? "\n" : '
'; + $open = PHP_SAPI === 'cli' ? "\n" : '
';
+		$close = PHP_SAPI === 'cli' ? "\n" : '
'; $expected = << array( @@ -540,8 +540,8 @@ public function testDump() { Debugger::dump($var, 1); $result = ob_get_clean(); - $open = php_sapi_name() === 'cli' ? "\n" : '
';
-		$close = php_sapi_name() === 'cli' ? "\n" : '
'; + $open = PHP_SAPI === 'cli' ? "\n" : '
';
+		$close = PHP_SAPI === 'cli' ? "\n" : '
'; $expected = << array( diff --git a/lib/Cake/basics.php b/lib/Cake/basics.php index 3b807094281..51afffa187f 100644 --- a/lib/Cake/basics.php +++ b/lib/Cake/basics.php @@ -100,7 +100,7 @@ function debug($var, $showHtml = null, $showFrom = true) { TEXT; $template = $html; - if (php_sapi_name() === 'cli' || $showHtml === false) { + if (PHP_SAPI === 'cli' || $showHtml === false) { $template = $text; if ($showFrom) { $lineInfo = sprintf('%s (line %s)', $file, $line); @@ -275,7 +275,7 @@ function pluginSplit($name, $dotAppend = false, $plugin = null) { */ function pr($var) { if (Configure::read('debug') > 0) { - $template = php_sapi_name() !== 'cli' ? '
%s
' : "\n%s\n"; + $template = PHP_SAPI !== 'cli' ? '
%s
' : "\n%s\n"; printf($template, print_r($var, true)); } } From b16d627b36203c04cc54f3414d438cbd0abb63aa Mon Sep 17 00:00:00 2001 From: "t.gommers" Date: Mon, 27 Jul 2015 13:03:21 +0200 Subject: [PATCH 274/336] Disable SNI in HttpSocket --- lib/Cake/Network/Http/HttpSocket.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Network/Http/HttpSocket.php b/lib/Cake/Network/Http/HttpSocket.php index 44b514d9f41..36c2985b509 100644 --- a/lib/Cake/Network/Http/HttpSocket.php +++ b/lib/Cake/Network/Http/HttpSocket.php @@ -719,7 +719,7 @@ protected function _configContext($host) { unset($this->config[$key]); } if (version_compare(PHP_VERSION, '5.3.2', '>=')) { - if (empty($this->config['context']['ssl']['SNI_enabled'])) { + if (!isset($this->config['context']['ssl']['SNI_enabled'])) { $this->config['context']['ssl']['SNI_enabled'] = true; } if (version_compare(PHP_VERSION, '5.6.0', '>=')) { From 58ea40e32c3ea71766b94c7890042efbf10797ac Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 27 Jul 2015 22:12:25 -0400 Subject: [PATCH 275/336] Don't stop reading when only a '0' has been read. Make tests simpler by using onConsecutiveCalls() instead of trying to maintain mock method indexes. Refs #7121 --- lib/Cake/Network/Http/HttpSocket.php | 2 +- .../Test/Case/Network/Http/HttpSocketTest.php | 75 +++++++++++++++---- 2 files changed, 60 insertions(+), 17 deletions(-) diff --git a/lib/Cake/Network/Http/HttpSocket.php b/lib/Cake/Network/Http/HttpSocket.php index 36c2985b509..0fdf4a12d90 100644 --- a/lib/Cake/Network/Http/HttpSocket.php +++ b/lib/Cake/Network/Http/HttpSocket.php @@ -378,7 +378,7 @@ public function request($request = array()) { $response = null; $inHeader = true; - while ($data = $this->read()) { + while (($data = $this->read()) !== false) { if ($this->_contentResource) { if ($inHeader) { $response .= $data; diff --git a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php index de04f18edc0..6ff788348bb 100644 --- a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php +++ b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php @@ -307,6 +307,10 @@ public function testConfigUri() { * @return void */ public function testRequest() { + $this->Socket->expects($this->any()) + ->method('read') + ->will($this->returnValue(false)); + $this->Socket->reset(); $response = $this->Socket->request(true); @@ -589,6 +593,10 @@ public function testRequest() { * @return void */ public function testGetWithSchemeAndPort() { + $this->Socket->expects($this->any()) + ->method('read') + ->will($this->returnValue(false)); + $this->Socket->reset(); $request = array( 'uri' => array( @@ -609,6 +617,10 @@ public function testGetWithSchemeAndPort() { * @return void */ public function testRequestWithStringQuery() { + $this->Socket->expects($this->any()) + ->method('read') + ->will($this->returnValue(false)); + $this->Socket->reset(); $request = array( 'uri' => array( @@ -642,14 +654,18 @@ public function testRequestNotAllowedUri() { */ public function testRequest2() { $this->Socket->reset(); + $request = array('uri' => 'htpp://www.cakephp.org/'); $number = mt_rand(0, 9999999); $this->Socket->expects($this->any())->method('connect')->will($this->returnValue(true)); $serverResponse = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

Hello, your lucky number is " . $number . "

"; $this->Socket->expects($this->at(0))->method('write') ->with("GET / HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n\r\n"); - $this->Socket->expects($this->at(0))->method('read')->will($this->returnValue(false)); - $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse)); + + $this->Socket->expects($this->any()) + ->method('read') + ->will($this->onConsecutiveCalls($serverResponse, false)); + $response = (string)$this->Socket->request($request); $this->assertEquals($response, "

Hello, your lucky number is " . $number . "

"); } @@ -662,7 +678,11 @@ public function testRequest2() { public function testRequest3() { $request = array('uri' => 'htpp://www.cakephp.org/'); $serverResponse = "HTTP/1.x 200 OK\r\nSet-Cookie: foo=bar\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

This is a cookie test!

"; - $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse)); + + $this->Socket->expects($this->any()) + ->method('read') + ->will($this->onConsecutiveCalls($serverResponse, false)); + $this->Socket->connected = true; $this->Socket->request($request); $result = $this->Socket->response['cookies']; @@ -711,9 +731,10 @@ public function testRequestWithConstructor() { */ public function testRequestWithResource() { $serverResponse = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

This is a test!

"; - $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse)); - $this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false)); - $this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse)); + + $this->Socket->expects($this->any()) + ->method('read') + ->will($this->onConsecutiveCalls($serverResponse, false, $serverResponse, false)); $this->Socket->connected = true; $f = fopen(TMP . 'download.txt', 'w'); @@ -744,8 +765,10 @@ public function testRequestWithCrossCookie() { $this->Socket->config['request']['cookies'] = array(); $serverResponse = "HTTP/1.x 200 OK\r\nSet-Cookie: foo=bar\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

This is a test!

"; + $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse)); $this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false)); + $expected = array('www.cakephp.org' => array('foo' => array('value' => 'bar'))); $this->Socket->request('http://www.cakephp.org/'); $this->assertEquals($expected, $this->Socket->config['request']['cookies']); @@ -781,8 +804,9 @@ public function testRequestWithCrossCookie() { public function testRequestCustomResponse() { $this->Socket->connected = true; $serverResponse = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

This is a test!

"; - $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse)); - $this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false)); + $this->Socket->expects($this->any()) + ->method('read') + ->will($this->onConsecutiveCalls($serverResponse, false)); $this->Socket->responseClass = 'CustomResponse'; $response = $this->Socket->request('http://www.cakephp.org/'); @@ -817,6 +841,8 @@ public function testRequestWithRedirectUrlEncoded() { $this->Socket->expects($this->at(4)) ->method('read') ->will($this->returnValue($serverResponse2)); + $this->Socket->expects($this->any()) + ->method('read')->will($this->returnValue(false)); $response = $this->Socket->request($request); $this->assertEquals('

You have been redirected

', $response->body()); @@ -834,8 +860,10 @@ public function testRequestWithRedirectAsTrue() { ); $serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n"; $serverResponse2 = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

You have been redirected

"; - $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1)); - $this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2)); + + $this->Socket->expects($this->any()) + ->method('read') + ->will($this->onConsecutiveCalls($serverResponse1, false, $serverResponse2, false)); $response = $this->Socket->request($request); $this->assertEquals('

You have been redirected

', $response->body()); @@ -853,8 +881,10 @@ public function testRequestWithRedirectAsInt() { ); $serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n"; $serverResponse2 = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

You have been redirected

"; - $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1)); - $this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2)); + + $this->Socket->expects($this->any()) + ->method('read') + ->will($this->onConsecutiveCalls($serverResponse1, false, $serverResponse2, false)); $this->Socket->request($request); $this->assertEquals(1, $this->Socket->request['redirect']); @@ -872,8 +902,10 @@ public function testRequestWithRedirectAsIntReachingZero() { ); $serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/oneruri\r\n\r\n"; $serverResponse2 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n"; - $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1)); - $this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2)); + + $this->Socket->expects($this->any()) + ->method('read') + ->will($this->onConsecutiveCalls($serverResponse1, false, $serverResponse2, false)); $response = $this->Socket->request($request); $this->assertEquals(0, $this->Socket->request['redirect']); @@ -1113,6 +1145,9 @@ public function testHead() { * @return void */ public function testAuth() { + $this->Socket->expects($this->any()) + ->method('read')->will($this->returnValue(false)); + $this->Socket->get('http://mark:secret@example.com/test'); $this->assertTrue(strpos($this->Socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=') !== false); @@ -1154,6 +1189,9 @@ public function testAuth() { * @return void */ public function testConsecutiveGetResetsAuthCredentials() { + $this->Socket->expects($this->any()) + ->method('read')->will($this->returnValue(false)); + $this->Socket->get('http://mark:secret@example.com/test'); $this->assertEquals('mark', $this->Socket->request['uri']['user']); $this->assertEquals('secret', $this->Socket->request['uri']['pass']); @@ -1813,6 +1851,9 @@ public function testPartialReset() { * @return void */ public function testConfigContext() { + $this->Socket->expects($this->any()) + ->method('read')->will($this->returnValue(false)); + $this->Socket->reset(); $this->Socket->request('http://example.com'); $this->assertTrue($this->Socket->config['context']['ssl']['verify_peer']); @@ -1869,8 +1910,10 @@ public function statusProvider() { public function testResponseStatusParsing($status, $code, $msg = '') { $this->Socket->connected = true; $serverResponse = $status . "\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\n\r\n

This is a test!

"; - $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse)); - $this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false)); + + $this->Socket->expects($this->any()) + ->method('read') + ->will($this->onConsecutiveCalls($serverResponse, false)); $response = $this->Socket->request('http://www.cakephp.org/'); $this->assertInstanceOf('HttpSocketResponse', $response); From 00d0a50dc27b54b0e59f7870f43d8352d25f909f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Tue, 28 Jul 2015 20:02:06 +0200 Subject: [PATCH 276/336] Add "Reporting a Security Issue" Backport of #7104 --- CONTRIBUTING.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5bb12117948..c991e246096 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -63,6 +63,10 @@ Check the [cakephp-codesniffer](https://github.com/cakephp/cakephp-codesniffer) repository to setup the CakePHP standard. The [README](https://github.com/cakephp/cakephp-codesniffer/blob/master/README.md) contains installation info for the sniff and phpcs. +## Reporting a Security Issue + +If you've found a security related issue in CakePHP, please don't open an issue in GitHub. Instead contact us at security@cakephp.org. For more information on how we handle security issues, [see the CakePHP Security Issue Process](http://book.cakephp.org/2.0/en/contributing/tickets.html#reporting-security-issues). + # Additional Resources * [CakePHP coding standards](http://book.cakephp.org/2.0/en/contributing/cakephp-coding-conventions.html) From a3bb420a7b67fd046f14e9d6d9fe69b9a2bddb74 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Tue, 28 Jul 2015 17:58:38 -0500 Subject: [PATCH 277/336] Set .htaccess indentation to 4 spaces --- .htaccess | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.htaccess b/.htaccess index f23dbaf6686..f23967b59a3 100644 --- a/.htaccess +++ b/.htaccess @@ -1,5 +1,5 @@ - RewriteEngine on - RewriteRule ^$ app/webroot/ [L] - RewriteRule (.*) app/webroot/$1 [L] + RewriteEngine on + RewriteRule ^$ app/webroot/ [L] + RewriteRule (.*) app/webroot/$1 [L] \ No newline at end of file From 26ab829d5ad62e19c8de172a8dbfb0f1ad93da19 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 29 Jul 2015 22:01:27 -0400 Subject: [PATCH 278/336] Bootstrap Configure after the mb_* shims have been defined. By bootstrapping after the shims have been defined allows the shims to be used by Inflector which is often involved with bootstrapping. Refs #7135 --- lib/Cake/bootstrap.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/Cake/bootstrap.php b/lib/Cake/bootstrap.php index 4ad77a21b5a..b17c9f68ffe 100644 --- a/lib/Cake/bootstrap.php +++ b/lib/Cake/bootstrap.php @@ -172,17 +172,6 @@ Configure::write('App.cssBaseUrl', CSS_URL); Configure::write('App.jsBaseUrl', JS_URL); -Configure::bootstrap(isset($boot) ? $boot : true); - -if (function_exists('mb_internal_encoding')) { - $encoding = Configure::read('App.encoding'); - if (!empty($encoding)) { - mb_internal_encoding($encoding); - } - if (!empty($encoding) && function_exists('mb_regex_encoding')) { - mb_regex_encoding($encoding); - } -} if (!function_exists('mb_stripos')) { @@ -438,3 +427,15 @@ function mb_encode_mimeheader($str, $charset = 'UTF-8', $transferEncoding = 'B', } } + +Configure::bootstrap(isset($boot) ? $boot : true); + +if (function_exists('mb_internal_encoding')) { + $encoding = Configure::read('App.encoding'); + if (!empty($encoding)) { + mb_internal_encoding($encoding); + } + if (!empty($encoding) && function_exists('mb_regex_encoding')) { + mb_regex_encoding($encoding); + } +} From a73fc25657d50de729a62946166f286d0f27565d Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 30 Jul 2015 22:28:55 -0400 Subject: [PATCH 279/336] Fix incorrectly parsed mo file context. The context from mo files should be parsed correctly. Refs #7118 --- lib/Cake/I18n/I18n.php | 8 ++++++-- lib/Cake/Test/Case/I18n/I18nTest.php | 16 ++++++++++++++++ .../Locale/nld_mo/LC_MESSAGES/default.mo | Bin 0 -> 335 bytes 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 lib/Cake/Test/test_app/Locale/nld_mo/LC_MESSAGES/default.mo diff --git a/lib/Cake/I18n/I18n.php b/lib/Cake/I18n/I18n.php index 9f0d06fea08..1ce5aae4890 100644 --- a/lib/Cake/I18n/I18n.php +++ b/lib/Cake/I18n/I18n.php @@ -497,6 +497,9 @@ public static function loadMo($filename) { $msgid = substr($data, $r["offs"], $r["len"]); unset($msgid_plural); + if (strpos($msgid, "\x04") !== false) { + list($context, $msgid) = explode("\x04", $msgid); + } if (strpos($msgid, "\000")) { list($msgid, $msgid_plural) = explode("\000", $msgid); } @@ -508,9 +511,10 @@ public static function loadMo($filename) { } if ($msgid != '') { - $msgstr = array($context => $msgstr); + $translations[$msgid][$context] = $msgstr; + } else { + $translations[$msgid] = $msgstr; } - $translations[$msgid] = $msgstr; if (isset($msgid_plural)) { $translations[$msgid_plural] =& $translations[$msgid]; diff --git a/lib/Cake/Test/Case/I18n/I18nTest.php b/lib/Cake/Test/Case/I18n/I18nTest.php index 79657c4614d..faac0e0694b 100644 --- a/lib/Cake/Test/Case/I18n/I18nTest.php +++ b/lib/Cake/Test/Case/I18n/I18nTest.php @@ -2040,6 +2040,22 @@ public function testContext() { $this->assertSame("saldo", __x('money', 'balance')); } +/** + * Test basic context support using mo files. + * + * @return void + */ + public function testContextMoFile() { + Configure::write('Config.language', 'nld_mo'); + + $this->assertSame("brief", __x('mail', 'letter')); + $this->assertSame("letter", __x('character', 'letter')); + $this->assertSame("bal", __x('spherical object', 'ball')); + $this->assertSame("danspartij", __x('social gathering', 'ball')); + $this->assertSame("balans", __('balance')); + $this->assertSame("saldo", __x('money', 'balance')); + } + /** * Singular method * diff --git a/lib/Cake/Test/test_app/Locale/nld_mo/LC_MESSAGES/default.mo b/lib/Cake/Test/test_app/Locale/nld_mo/LC_MESSAGES/default.mo new file mode 100644 index 0000000000000000000000000000000000000000..bb89fa6e9ae1b1f1848449c9ce986d282aa6232d GIT binary patch literal 335 zcmZY2O%4Gu7{>8ejE_i25D5v112}<|y(`$fQ$?jZ(l!zYv14iD8V+G+=M*-c*I=W` ze}2=i^xjGigi%F(G?NL&G3RXs|0k57GwPxXYNIQvqZ{g=$Hym>(JT;^VG9;v4>sTc z%DoXR!7;4C36yhFNGV%(N{g1%iao2SePVS4loM#f#{R8kPVbZN{g5fccDUrY(%!hG uY*-3gnJH{!=~}CpujY>i;q$`pq0}3_Ao=dJqri5a(VSh_vX5r{zVQOW)=BCB literal 0 HcmV?d00001 From 27c88a872bcd09ffce5e6f6745dcb03e2c2cfb83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Sat, 1 Aug 2015 00:39:10 +0200 Subject: [PATCH 280/336] Use tabs and single spaces in all .htaccess files --- .htaccess | 6 +++--- app/.htaccess | 6 +++--- app/webroot/.htaccess | 8 ++++---- lib/Cake/Console/Templates/skel/.htaccess | 6 +++--- lib/Cake/Console/Templates/skel/webroot/.htaccess | 8 ++++---- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.htaccess b/.htaccess index f23967b59a3..2ac5e0e7a89 100644 --- a/.htaccess +++ b/.htaccess @@ -1,5 +1,5 @@ - RewriteEngine on - RewriteRule ^$ app/webroot/ [L] - RewriteRule (.*) app/webroot/$1 [L] + RewriteEngine on + RewriteRule ^$ app/webroot/ [L] + RewriteRule (.*) app/webroot/$1 [L] \ No newline at end of file diff --git a/app/.htaccess b/app/.htaccess index fc3aac4b296..128e7871bc7 100644 --- a/app/.htaccess +++ b/app/.htaccess @@ -1,5 +1,5 @@ - RewriteEngine on - RewriteRule ^$ webroot/ [L] - RewriteRule (.*) webroot/$1 [L] + RewriteEngine on + RewriteRule ^$ webroot/ [L] + RewriteRule (.*) webroot/$1 [L] \ No newline at end of file diff --git a/app/webroot/.htaccess b/app/webroot/.htaccess index 1f19e4c0601..1d499ba73bb 100644 --- a/app/webroot/.htaccess +++ b/app/webroot/.htaccess @@ -1,6 +1,6 @@ - RewriteEngine On - RewriteCond %{REQUEST_FILENAME} !-d - RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^ index.php [L] + RewriteEngine On + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.php [L] diff --git a/lib/Cake/Console/Templates/skel/.htaccess b/lib/Cake/Console/Templates/skel/.htaccess index fc3aac4b296..128e7871bc7 100644 --- a/lib/Cake/Console/Templates/skel/.htaccess +++ b/lib/Cake/Console/Templates/skel/.htaccess @@ -1,5 +1,5 @@ - RewriteEngine on - RewriteRule ^$ webroot/ [L] - RewriteRule (.*) webroot/$1 [L] + RewriteEngine on + RewriteRule ^$ webroot/ [L] + RewriteRule (.*) webroot/$1 [L] \ No newline at end of file diff --git a/lib/Cake/Console/Templates/skel/webroot/.htaccess b/lib/Cake/Console/Templates/skel/webroot/.htaccess index 1f19e4c0601..1d499ba73bb 100644 --- a/lib/Cake/Console/Templates/skel/webroot/.htaccess +++ b/lib/Cake/Console/Templates/skel/webroot/.htaccess @@ -1,6 +1,6 @@ - RewriteEngine On - RewriteCond %{REQUEST_FILENAME} !-d - RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^ index.php [L] + RewriteEngine On + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.php [L] From 3f15c8a1993c09db5abac9ff8c93e95e55e03c01 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Wed, 5 Aug 2015 11:45:27 +0200 Subject: [PATCH 281/336] fix templates --- lib/Cake/Console/Templates/default/views/form.ctp | 2 +- lib/Cake/Console/Templates/default/views/view.ctp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Console/Templates/default/views/form.ctp b/lib/Cake/Console/Templates/default/views/form.ctp index b7dad3cee1d..4a21aabe376 100644 --- a/lib/Cake/Console/Templates/default/views/form.ctp +++ b/lib/Cake/Console/Templates/default/views/form.ctp @@ -44,7 +44,7 @@
    -
  • 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}'))); ?>"; ?>
  • +
  • Form->postLink(__('Delete'), array('action' => 'delete', \$this->Form->value('{$modelClass}.{$primaryKey}')), array('confirm' => __('Are you sure you want to delete # %s?', \$this->Form->value('{$modelClass}.{$primaryKey}')))); ?>"; ?>
  • Html->link(__('List " . $pluralHumanName . "'), array('action' => 'index')); ?>"; ?>
  • Html->link(__('Edit " . $singularHumanName ."'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> \n"; - echo "\t\t
  • Form->postLink(__('Delete " . $singularHumanName . "'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), array(), __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>
  • \n"; + echo "\t\t
  • Form->postLink(__('Delete " . $singularHumanName . "'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), array('confirm' => __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}']))); ?>
  • \n"; echo "\t\t
  • Html->link(__('List " . $pluralHumanName . "'), array('action' => 'index')); ?>
  • \n"; echo "\t\t
  • Html->link(__('New " . $singularHumanName . "'), array('action' => 'add')); ?>
  • \n"; @@ -117,7 +117,7 @@ echo "\t\n"; echo "\t\t\t\tHtml->link(__('View'), array('controller' => '{$details['controller']}', 'action' => 'view', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n"; echo "\t\t\t\tHtml->link(__('Edit'), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n"; - echo "\t\t\t\tForm->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\tForm->postLink(__('Delete'), array('controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']), array('confirm' => __('Are you sure you want to delete # %s?', \${$otherSingularVar}['{$details['primaryKey']}']))); ?>\n"; echo "\t\t\t\n"; echo "\t\t\n"; From 9f20330d179cf759692537edb3e75fdd3adcbf7b Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 5 Aug 2015 22:12:13 -0400 Subject: [PATCH 282/336] Fix fatal error on null subject. Refs #7176 --- .../Controller/Component/EmailComponent.php | 3 ++- .../Component/EmailComponentTest.php | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Controller/Component/EmailComponent.php b/lib/Cake/Controller/Component/EmailComponent.php index 799baaca8f1..d89099f7e84 100644 --- a/lib/Cake/Controller/Component/EmailComponent.php +++ b/lib/Cake/Controller/Component/EmailComponent.php @@ -309,7 +309,8 @@ public function send($content = null, $template = null, $layout = null) { $lib->readReceipt($this->_formatAddresses((array)$this->readReceipt)); } - $lib->subject($this->subject)->messageID($this->messageId); + $lib->subject($this->subject); + $lib->messageID($this->messageId); $lib->helpers($this->_controller->helpers); $headers = array('X-Mailer' => $this->xMailer); diff --git a/lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php b/lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php index 7be4282b30e..aee72160d89 100644 --- a/lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php @@ -339,6 +339,32 @@ public function testTemplateNestedElements() { $this->assertRegExp('/http\:\/\/example\.com/', $result); } +/** + * test send with null properties + * + * @return void + */ + public function testSendNullProperties() { + $this->Controller->EmailTest->to = 'test@example.com'; + $this->Controller->EmailTest->from = 'test@example.com'; + $this->Controller->EmailTest->subject = null; + $this->Controller->EmailTest->replyTo = null; + $this->Controller->EmailTest->messageId = null; + $this->Controller->EmailTest->template = null; + + $this->Controller->EmailTest->delivery = 'DebugComp'; + $this->assertTrue($this->Controller->EmailTest->send(null)); + $result = DebugCompTransport::$lastEmail; + + $this->assertRegExp('/To: test@example.com\n/', $result); + $this->assertRegExp('/Subject: \n/', $result); + $this->assertRegExp('/From: test@example.com\n/', $result); + $this->assertRegExp('/Date: ' . preg_quote(static::$sentDate) . '\n/', $result); + $this->assertRegExp('/X-Mailer: CakePHP Email Component\n/', $result); + $this->assertRegExp('/Content-Type: text\/plain; charset=UTF-8\n/', $result); + $this->assertRegExp('/Content-Transfer-Encoding: 8bitMessage:\n/', $result); + } + /** * testSendDebug method * From 056f24a77428ad35e23cab6840a72b7c25c4ccc0 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 5 Aug 2015 23:05:30 -0400 Subject: [PATCH 283/336] Forbid direct prefix access with mixed casing. Changing the casing up should not allow prefix method access. --- lib/Cake/Controller/Controller.php | 4 ++-- .../Test/Case/Controller/ControllerTest.php | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index 8cd10fdf134..78381e90acd 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -514,12 +514,12 @@ protected function _isPrivateAction(ReflectionMethod $method, CakeRequest $reque !$method->isPublic() || !in_array($method->name, $this->methods) ); - $prefixes = Router::prefixes(); + $prefixes = array_map('strtolower', Router::prefixes()); if (!$privateAction && !empty($prefixes)) { if (empty($request->params['prefix']) && strpos($request->params['action'], '_') > 0) { list($prefix) = explode('_', $request->params['action']); - $privateAction = in_array($prefix, $prefixes); + $privateAction = in_array(strtolower($prefix), $prefixes); } } return $privateAction; diff --git a/lib/Cake/Test/Case/Controller/ControllerTest.php b/lib/Cake/Test/Case/Controller/ControllerTest.php index 534825e3773..f319bd1672d 100644 --- a/lib/Cake/Test/Case/Controller/ControllerTest.php +++ b/lib/Cake/Test/Case/Controller/ControllerTest.php @@ -1447,6 +1447,25 @@ public function testInvokeActionPrefixProtection() { $Controller->invokeAction($url); } +/** + * test invoking controller methods. + * + * @expectedException PrivateActionException + * @expectedExceptionMessage Private Action TestController::Admin_add() is not directly accessible. + * @return void + */ + public function testInvokeActionPrefixProtectionCasing() { + Router::reload(); + Router::connect('/admin/:controller/:action/*', array('prefix' => 'admin')); + + $url = new CakeRequest('test/Admin_add/'); + $url->addParams(array('controller' => 'test_controller', 'action' => 'Admin_add')); + $response = $this->getMock('CakeResponse'); + + $Controller = new TestController($url, $response); + $Controller->invokeAction($url); + } + /** * test invoking controller methods. * From b7c9ac913d05f7530784af8fb34166d33cb10af4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 6 Aug 2015 21:32:17 -0400 Subject: [PATCH 284/336] Backport fixes for comparison() and range() to 2.x These fixes were released as a security update for 3.x, they also belong in 2.x --- lib/Cake/Test/Case/Utility/ValidationTest.php | 35 +++++++++++++++++++ lib/Cake/Utility/Validation.php | 7 ++++ 2 files changed, 42 insertions(+) diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index a8f0e957fa9..f501e4f6b81 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -930,6 +930,25 @@ public function testComparison() { $this->assertFalse(Validation::comparison(7, '==', 6)); $this->assertFalse(Validation::comparison(7, 'not equal', 7)); $this->assertFalse(Validation::comparison(7, '!=', 7)); + + $this->assertTrue(Validation::comparison('6.5', '!=', 6)); + $this->assertTrue(Validation::comparison('6.5', '<', 7)); + } + +/** + * Test comparison casting values before comparisons. + * + * @return void + */ + public function testComparisonTypeChecks() { + $this->assertFalse(Validation::comparison('\x028', '>=', 1), 'hexish encoding fails'); + $this->assertFalse(Validation::comparison('0b010', '>=', 1), 'binary string data fails'); + $this->assertFalse(Validation::comparison('0x01', '>=', 1), 'hex string data fails'); + $this->assertFalse(Validation::comparison('0x1', '>=', 1), 'hex string data fails'); + + $this->assertFalse(Validation::comparison('\x028', '>=', 1.5), 'hexish encoding fails'); + $this->assertFalse(Validation::comparison('0b010', '>=', 1.5), 'binary string data fails'); + $this->assertFalse(Validation::comparison('0x02', '>=', 1.5), 'hex string data fails'); } /** @@ -2004,6 +2023,22 @@ public function testRange() { $this->assertFalse(Validation::range('word')); } +/** + * Test range type checks + * + * @return void + */ + public function testRangeTypeChecks() { + $this->assertFalse(Validation::range('\x028', 1, 5), 'hexish encoding fails'); + $this->assertFalse(Validation::range('0b010', 1, 5), 'binary string data fails'); + $this->assertFalse(Validation::range('0x01', 1, 5), 'hex string data fails'); + $this->assertFalse(Validation::range('0x1', 1, 5), 'hex string data fails'); + + $this->assertFalse(Validation::range('\x028', 1, 5), 'hexish encoding fails'); + $this->assertFalse(Validation::range('0b010', 1, 5), 'binary string data fails'); + $this->assertFalse(Validation::range('0x02', 1, 5), 'hex string data fails'); + } + /** * testExtension method * diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index 6cdd745b0b2..40449ab0d4f 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -242,6 +242,10 @@ public static function comparison($check1, $operator = null, $check2 = null) { if (is_array($check1)) { extract($check1, EXTR_OVERWRITE); } + + if ((float)$check1 != $check1) { + return false; + } $operator = str_replace(array(' ', "\t", "\n", "\r", "\0", "\x0B"), '', strtolower($operator)); switch ($operator) { @@ -757,6 +761,9 @@ public static function range($check, $lower = null, $upper = null) { if (!is_numeric($check)) { return false; } + if ((float)$check != $check) { + return false; + } if (isset($lower) && isset($upper)) { return ($check > $lower && $check < $upper); } From f959b7601323065e74c6ec5dd0b63049ae939dac Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 6 Aug 2015 21:43:53 -0400 Subject: [PATCH 285/336] Update version number to 2.7.2 --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index ea11fc97e39..2f10769939e 100644 --- a/lib/Cake/VERSION.txt +++ b/lib/Cake/VERSION.txt @@ -17,4 +17,4 @@ // @license http://www.opensource.org/licenses/mit-license.php MIT License // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -2.7.1 +2.7.2 From a7b5f8c3af2398da3f6d0c35b4ac5bf77331468b Mon Sep 17 00:00:00 2001 From: paolo Date: Thu, 6 Aug 2015 16:05:16 +0200 Subject: [PATCH 286/336] DboSource now check the actual status of connection by executing a dumb query on DB This change makes it possible for developer to build reconnection logic on MySQL connections which frequently time out in long running CLI processes. Cherry picked onto 2.7 from #7190. --- lib/Cake/Model/Datasource/DboSource.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 927a6e369fb..a41e88cef12 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -857,6 +857,12 @@ public function name($data) { * @return bool True if the database is connected, else false */ public function isConnected() { + try { + $connected = $this->_connection->query('SELECT 1'); + } catch (Exception $e) { + $connected = false; + } + $this->connected = ! empty($connected); return $this->connected; } From f3e590acfbcd75dc505c10edfd7433efd895153f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Tue, 11 Aug 2015 16:29:48 +0200 Subject: [PATCH 287/336] Annotate test coverage --- lib/Cake/Test/Case/Utility/CakeTextTest.php | 45 ++++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/CakeTextTest.php b/lib/Cake/Test/Case/Utility/CakeTextTest.php index 7eface6e9e2..2e085c39afe 100644 --- a/lib/Cake/Test/Case/Utility/CakeTextTest.php +++ b/lib/Cake/Test/Case/Utility/CakeTextTest.php @@ -19,17 +19,28 @@ App::uses('CakeText', 'Utility'); /** - * CakeTextTest class + * CakeText Tests * - * @package Cake.Test.Case.Utility + * @package Cake.Test.Case.Utility + * @coversDefaultClass CakeText */ class CakeTextTest extends CakeTestCase { +/** + * Setup object under test + * + * @return void + */ public function setUp() { parent::setUp(); $this->Text = new CakeText(); } +/** + * Tear down object under test + * + * @return void + */ public function tearDown() { parent::tearDown(); unset($this->Text); @@ -39,6 +50,7 @@ public function tearDown() { * testUuidGeneration method * * @return void + * @covers ::uuid */ public function testUuidGeneration() { $result = CakeText::uuid(); @@ -51,6 +63,7 @@ public function testUuidGeneration() { * testMultipleUuidGeneration method * * @return void + * @covers ::uuid */ public function testMultipleUuidGeneration() { $check = array(); @@ -70,6 +83,7 @@ public function testMultipleUuidGeneration() { * testInsert method * * @return void + * @covers ::insert */ public function testInsert() { $string = 'some string'; @@ -231,6 +245,7 @@ public function testInsert() { * test Clean Insert * * @return void + * @covers ::cleanInsert */ public function testCleanInsert() { $result = CakeText::cleanInsert(':incomplete', array( @@ -271,6 +286,7 @@ public function testCleanInsert() { * CakeText::insert(). * * @return void + * @covers ::insert */ public function testAutoIgnoreBadInsertData() { $data = array('foo' => 'alpha', 'bar' => 'beta', 'fale' => array()); @@ -282,6 +298,7 @@ public function testAutoIgnoreBadInsertData() { * testTokenize method * * @return void + * @covers ::tokenize */ public function testTokenize() { $result = CakeText::tokenize('A,(short,boring test)'); @@ -318,6 +335,7 @@ public function testTokenize() { * testReplaceWithQuestionMarkInString method * * @return void + * @covers ::insert */ public function testReplaceWithQuestionMarkInString() { $string = ':a, :b and :c?'; @@ -331,6 +349,8 @@ public function testReplaceWithQuestionMarkInString() { * * @dataProvider wordWrapProvider * @return void + * @covers ::wordWrap + * @covers ::_wordWrap */ public function testWordWrap($text, $width, $break = "\n", $cut = false) { $result = CakeText::wordWrap($text, $width, $break, $cut); @@ -364,6 +384,8 @@ public function wordWrapProvider() { * test that wordWrap() properly handle unicode strings. * * @return void + * @covers ::wordWrap + * @covers ::_wordWrap */ public function testWordWrapUnicodeAware() { $text = 'Но вим омниюм факёльиси элыктрам, мюнырэ лэгыры векж ыт. Выльёт квюандо нюмквуам ты кюм. Зыд эю рыбюм.'; @@ -391,6 +413,8 @@ public function testWordWrapUnicodeAware() { * test that wordWrap() properly handle newline characters. * * @return void + * @covers ::wordWrap + * @covers ::_wordWrap */ public function testWordWrapNewlineAware() { $text = 'This is a line that is almost the 55 chars long. @@ -408,6 +432,9 @@ public function testWordWrapNewlineAware() { * test wrap method. * * @return void + * @covers ::wrap + * @covers ::wordWrap + * @covers ::_wordWrap */ public function testWrap() { $text = 'This is the song that never ends. This is the song that never ends. This is the song that never ends.'; @@ -443,6 +470,9 @@ public function testWrap() { * test wrap() indenting * * @return void + * @covers ::wrap + * @covers ::wordWrap + * @covers ::_wordWrap */ public function testWrapIndent() { $text = 'This is the song that never ends. This is the song that never ends. This is the song that never ends.'; @@ -459,6 +489,7 @@ public function testWrapIndent() { * testTruncate method * * @return void + * @covers ::truncate */ public function testTruncate() { $text1 = 'The quick brown fox jumps over the lazy dog'; @@ -564,6 +595,7 @@ public function testTruncate() { * testTruncate method with non utf8 sites * * @return void + * @covers ::truncate */ public function testTruncateLegacy() { Configure::write('App.encoding', 'ISO-8859-1'); @@ -587,6 +619,7 @@ public function testTruncateLegacy() { * testTail method * * @return void + * @covers ::tail */ public function testTail() { $text1 = 'The quick brown fox jumps over the lazy dog'; @@ -630,6 +663,7 @@ public function testTail() { * testHighlight method * * @return void + * @covers ::highlight */ public function testHighlight() { $text = 'This is a test text'; @@ -664,6 +698,7 @@ public function testHighlight() { * testHighlightHtml method * * @return void + * @covers ::highlight */ public function testHighlightHtml() { $text1 = '

    strongbow isn’t real cider

    '; @@ -690,6 +725,7 @@ public function testHighlightHtml() { * testHighlightMulti method * * @return void + * @covers ::highlight */ public function testHighlightMulti() { $text = 'This is a test text'; @@ -703,6 +739,7 @@ public function testHighlightMulti() { * testStripLinks method * * @return void + * @covers ::stripLinks */ public function testStripLinks() { $text = 'This is a test text'; @@ -730,6 +767,7 @@ public function testStripLinks() { * testHighlightCaseInsensitivity method * * @return void + * @covers ::highlight */ public function testHighlightCaseInsensitivity() { $text = 'This is a Test text'; @@ -746,6 +784,7 @@ public function testHighlightCaseInsensitivity() { * testExcerpt method * * @return void + * @covers ::excerpt */ public function testExcerpt() { $text = 'This is a phrase with test text to play with'; @@ -786,6 +825,7 @@ public function testExcerpt() { * testExcerptCaseInsensitivity method * * @return void + * @covers ::excerpt */ public function testExcerptCaseInsensitivity() { $text = 'This is a phrase with test text to play with'; @@ -803,6 +843,7 @@ public function testExcerptCaseInsensitivity() { * testListGeneration method * * @return void + * @covers ::toList */ public function testListGeneration() { $result = $this->Text->toList(array()); From 90a77f6ce5b6b6b39c9d643a79f43ec99143c383 Mon Sep 17 00:00:00 2001 From: James Tancock Date: Sun, 16 Aug 2015 19:06:12 +0100 Subject: [PATCH 288/336] Alter model exists to consider useTable --- lib/Cake/Model/Model.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index bfce2dd41c2..124bb394ab3 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -2895,6 +2895,10 @@ public function exists($id = null) { return false; } + if ($this->useTable === false) { + return true; + } + return (bool)$this->find('count', array( 'conditions' => array( $this->alias . '.' . $this->primaryKey => $id From 0df7bcd26dd26788e46c976861a2f86ba7ffea60 Mon Sep 17 00:00:00 2001 From: mattmemmesheimer Date: Sun, 16 Aug 2015 17:55:03 -0500 Subject: [PATCH 289/336] Adding Flash element template files. --- lib/Cake/View/Elements/Flash/default.ctp | 8 +++++++- lib/Cake/View/Elements/Flash/error.ctp | 1 + lib/Cake/View/Elements/Flash/success.ctp | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) mode change 100644 => 100755 lib/Cake/View/Elements/Flash/default.ctp create mode 100755 lib/Cake/View/Elements/Flash/error.ctp create mode 100755 lib/Cake/View/Elements/Flash/success.ctp diff --git a/lib/Cake/View/Elements/Flash/default.ctp b/lib/Cake/View/Elements/Flash/default.ctp old mode 100644 new mode 100755 index ce0f613558a..bc1e2c36912 --- a/lib/Cake/View/Elements/Flash/default.ctp +++ b/lib/Cake/View/Elements/Flash/default.ctp @@ -1 +1,7 @@ -
    \ No newline at end of file + +
    diff --git a/lib/Cake/View/Elements/Flash/error.ctp b/lib/Cake/View/Elements/Flash/error.ctp new file mode 100755 index 00000000000..6d6f27e6df7 --- /dev/null +++ b/lib/Cake/View/Elements/Flash/error.ctp @@ -0,0 +1 @@ +
    diff --git a/lib/Cake/View/Elements/Flash/success.ctp b/lib/Cake/View/Elements/Flash/success.ctp new file mode 100755 index 00000000000..4a375e60fc6 --- /dev/null +++ b/lib/Cake/View/Elements/Flash/success.ctp @@ -0,0 +1 @@ +
    From 604cb0e48bda36547ddad969fa391ded5fab3705 Mon Sep 17 00:00:00 2001 From: mattmemmesheimer Date: Sun, 16 Aug 2015 17:58:41 -0500 Subject: [PATCH 290/336] Including the FlashComponent by default in the controller when baking. --- lib/Cake/Console/Command/Task/ControllerTask.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index 728358d6655..fc2d9134348 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -384,9 +384,9 @@ public function doHelpers() { * @return array Components the user wants to use. */ public function doComponents() { - $components = array('Paginator'); + $components = array('Paginator', 'Flash'); return array_merge($components, $this->_doPropertyChoices( - __d('cake_console', "Would you like this controller to use other components\nbesides PaginatorComponent?"), + __d('cake_console', "Would you like this controller to use other components\nbesides PaginatorComponent and FlashComponent?"), __d('cake_console', "Please provide a comma separated list of the component names you'd like to use.\nExample: 'Acl, Security, RequestHandler'") )); } From d3cf879195a52b45b27d18674edde0d3c55c615c Mon Sep 17 00:00:00 2001 From: mattmemmesheimer Date: Sun, 16 Aug 2015 18:01:23 -0500 Subject: [PATCH 291/336] Updating deprecated SessionComponent::setFlash calls to FlashComponent magic calls. --- .../Templates/default/actions/controller_actions.ctp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Cake/Console/Templates/default/actions/controller_actions.ctp b/lib/Cake/Console/Templates/default/actions/controller_actions.ctp index b6b89a99342..dfc30921517 100644 --- a/lib/Cake/Console/Templates/default/actions/controller_actions.ctp +++ b/lib/Cake/Console/Templates/default/actions/controller_actions.ctp @@ -53,10 +53,10 @@ $this->->create(); if ($this->->save($this->request->data)) { - $this->Session->setFlash(__('The has been saved.')); + $this->Flash->success(__('The has been saved.')); return $this->redirect(array('action' => 'index')); } else { - $this->Session->setFlash(__('The could not be saved. Please, try again.')); + $this->Flash->error(__('The could not be saved. Please, try again.')); return $this->flash(__('The has been saved.'), array('action' => 'index')); @@ -94,10 +94,10 @@ if ($this->request->is(array('post', 'put'))) { if ($this->->save($this->request->data)) { - $this->Session->setFlash(__('The has been saved.')); + $this->Flash->success(__('The has been saved.')); return $this->redirect(array('action' => 'index')); } else { - $this->Session->setFlash(__('The could not be saved. Please, try again.')); + $this->Flash->error(__('The could not be saved. Please, try again.')); return $this->flash(__('The has been saved.'), array('action' => 'index')); @@ -138,9 +138,9 @@ $this->request->allowMethod('post', 'delete'); if ($this->->delete()) { - $this->Session->setFlash(__('The has been deleted.')); + $this->Flash->success(__('The has been deleted.')); } else { - $this->Session->setFlash(__('The could not be deleted. Please, try again.')); + $this->Flash->error(__('The could not be deleted. Please, try again.')); } return $this->redirect(array('action' => 'index')); From fd198ce0fa13b0dc72168f1ad33fcecdf341bd90 Mon Sep 17 00:00:00 2001 From: James Tancock Date: Mon, 17 Aug 2015 12:19:02 +0100 Subject: [PATCH 292/336] Edits to tests to cover the changes to Model::exists --- .../Test/Case/Model/ModelValidationTest.php | 38 +++++++++++++++++++ lib/Cake/Test/Case/Model/ModelWriteTest.php | 11 +----- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/lib/Cake/Test/Case/Model/ModelValidationTest.php b/lib/Cake/Test/Case/Model/ModelValidationTest.php index ba81c7199f5..0edd3fe5f58 100644 --- a/lib/Cake/Test/Case/Model/ModelValidationTest.php +++ b/lib/Cake/Test/Case/Model/ModelValidationTest.php @@ -554,6 +554,44 @@ public function testValidates() { $this->assertEquals($expected, $result); } +/** + * test that validates() still performs correctly when useTable = false on the mode. + * + * @return void + */ + public function testValidatesWithNoTable() { + $TestModel = new TheVoid(); + $TestModel->validate = array( + 'title' => array( + 'notEmpty' => array( + 'rule' => array('notBlank'), + 'required' => true, + ), + 'tooShort' => array( + 'rule' => array('minLength', 10), + ), + ), + ); + $data = array( + 'TheVoid' => array( + 'title' => 'too short', + ), + ); + $TestModel->create($data); + $result = $TestModel->validates(); + $this->assertFalse($result); + + $data = array( + 'TheVoid' => array( + 'id' => '1', + 'title' => 'A good title', + ), + ); + $TestModel->create($data); + $result = $TestModel->validates(); + $this->assertTrue($result); + } + /** * test that validates() checks all the 'with' associations as well for validation * as this can cause partial/wrong data insertion. diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index 9ad34df010b..63b22ab6c8f 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -2785,18 +2785,9 @@ public function testRecordExists() { $TestModel = new TheVoid(); $this->assertFalse($TestModel->exists()); - } -/** - * testRecordExistsMissingTable method - * - * @expectedException PDOException - * @return void - */ - public function testRecordExistsMissingTable() { - $TestModel = new TheVoid(); $TestModel->id = 5; - $TestModel->exists(); + $this->assertTrue($TestModel->exists()); } /** From 2f7cc052d25af0b84734a76970b1f3c5c51835d4 Mon Sep 17 00:00:00 2001 From: James Tancock Date: Mon, 17 Aug 2015 13:15:35 +0100 Subject: [PATCH 293/336] Typo in tests docblock --- lib/Cake/Test/Case/Model/ModelValidationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Model/ModelValidationTest.php b/lib/Cake/Test/Case/Model/ModelValidationTest.php index 0edd3fe5f58..bd65b16e96a 100644 --- a/lib/Cake/Test/Case/Model/ModelValidationTest.php +++ b/lib/Cake/Test/Case/Model/ModelValidationTest.php @@ -555,7 +555,7 @@ public function testValidates() { } /** - * test that validates() still performs correctly when useTable = false on the mode. + * test that validates() still performs correctly when useTable = false on the model. * * @return void */ From fdb41e01bbe9f8dbb96d4d506f7faba5d0b77c23 Mon Sep 17 00:00:00 2001 From: James Tancock Date: Tue, 18 Aug 2015 13:07:30 +0100 Subject: [PATCH 294/336] Alter Model::exists() to return false with no table --- lib/Cake/Model/Model.php | 2 +- lib/Cake/Test/Case/Model/ModelWriteTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 124bb394ab3..9ded1b59e23 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -2896,7 +2896,7 @@ public function exists($id = null) { } if ($this->useTable === false) { - return true; + return false; } return (bool)$this->find('count', array( diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index 63b22ab6c8f..7974fa7cc7c 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -2787,7 +2787,7 @@ public function testRecordExists() { $this->assertFalse($TestModel->exists()); $TestModel->id = 5; - $this->assertTrue($TestModel->exists()); + $this->assertFalse($TestModel->exists()); } /** From 5b92c900e6318e067e7f47df0ade8f92790642f2 Mon Sep 17 00:00:00 2001 From: James Tancock Date: Tue, 18 Aug 2015 13:32:16 +0100 Subject: [PATCH 295/336] Missing test fix ModelIntegration --- lib/Cake/Test/Case/Model/ModelIntegrationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php index 1aacd766285..65ab2ad3a4c 100644 --- a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php +++ b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php @@ -1334,7 +1334,7 @@ public function testUseTableFalseExistsCheck() { $Article->useTable = false; $Article->id = 1; $result = $Article->exists(); - $this->assertTrue($result); + $this->assertFalse($result); } /** From d4467f9acf42b0899a63bf4568c96ee442a481d1 Mon Sep 17 00:00:00 2001 From: mattmemmesheimer Date: Tue, 18 Aug 2015 22:14:10 -0500 Subject: [PATCH 296/336] Fixing unit tests. --- .../Case/Console/Command/Task/ControllerTaskTest.php | 6 +++--- .../bake_compare/Controller/ActionsUsingSessions.ctp | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php index ded7e9596e7..9d8c9e2b28d 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php @@ -222,7 +222,7 @@ public function testDoHelpersTrailingCommas() { public function testDoComponentsNo() { $this->Task->expects($this->any())->method('in')->will($this->returnValue('n')); $result = $this->Task->doComponents(); - $this->assertSame(array('Paginator'), $result); + $this->assertSame(array('Paginator', 'Flash'), $result); } /** @@ -235,7 +235,7 @@ public function testDoComponentsTrailingSpaces() { $this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' RequestHandler, Security ')); $result = $this->Task->doComponents(); - $expected = array('Paginator', 'RequestHandler', 'Security'); + $expected = array('Paginator', 'Flash', 'RequestHandler', 'Security'); $this->assertEquals($expected, $result); } @@ -249,7 +249,7 @@ public function testDoComponentsTrailingCommas() { $this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' RequestHandler, Security, , ')); $result = $this->Task->doComponents(); - $expected = array('Paginator', 'RequestHandler', 'Security'); + $expected = array('Paginator', 'Flash', 'RequestHandler', 'Security'); $this->assertEquals($expected, $result); } diff --git a/lib/Cake/Test/bake_compare/Controller/ActionsUsingSessions.ctp b/lib/Cake/Test/bake_compare/Controller/ActionsUsingSessions.ctp index 5cd6a4dee52..b4072d770e9 100644 --- a/lib/Cake/Test/bake_compare/Controller/ActionsUsingSessions.ctp +++ b/lib/Cake/Test/bake_compare/Controller/ActionsUsingSessions.ctp @@ -33,10 +33,10 @@ if ($this->request->is('post')) { $this->BakeArticle->create(); if ($this->BakeArticle->save($this->request->data)) { - $this->Session->setFlash(__('The bake article has been saved.')); + $this->Flash->success(__('The bake article has been saved.')); return $this->redirect(array('action' => 'index')); } else { - $this->Session->setFlash(__('The bake article could not be saved. Please, try again.')); + $this->Flash->error(__('The bake article could not be saved. Please, try again.')); } } $bakeTags = $this->BakeArticle->BakeTag->find('list'); @@ -56,10 +56,10 @@ } if ($this->request->is(array('post', 'put'))) { if ($this->BakeArticle->save($this->request->data)) { - $this->Session->setFlash(__('The bake article has been saved.')); + $this->Flash->success(__('The bake article has been saved.')); return $this->redirect(array('action' => 'index')); } else { - $this->Session->setFlash(__('The bake article could not be saved. Please, try again.')); + $this->Flash->error(__('The bake article could not be saved. Please, try again.')); } } else { $options = array('conditions' => array('BakeArticle.' . $this->BakeArticle->primaryKey => $id)); @@ -83,9 +83,9 @@ } $this->request->allowMethod('post', 'delete'); if ($this->BakeArticle->delete()) { - $this->Session->setFlash(__('The bake article has been deleted.')); + $this->Flash->success(__('The bake article has been deleted.')); } else { - $this->Session->setFlash(__('The bake article could not be deleted. Please, try again.')); + $this->Flash->error(__('The bake article could not be deleted. Please, try again.')); } return $this->redirect(array('action' => 'index')); } From 8fe953548c65b85cf1a919709047fe273d932339 Mon Sep 17 00:00:00 2001 From: ndm2 Date: Wed, 19 Aug 2015 16:47:53 +0200 Subject: [PATCH 297/336] Fix path traversal check for Windows based systems On Windows based systems, both, backward as well as forward slashes are supported as path separators, thus checking for `DS` only, would allow to slip in `../` fragments. refs #5905, cad57dcc28ed9996b52e681ae06d62bc7b5c79c0 --- lib/Cake/Network/CakeResponse.php | 2 +- lib/Cake/Test/Case/Network/CakeResponseTest.php | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index 3c5a3c46af0..a1929922826 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -1337,7 +1337,7 @@ public function file($path, $options = array()) { 'download' => null ); - if (strpos($path, '..' . DS) !== false) { + if (strpos($path, '../') !== false || strpos($path, '..\\') !== false) { throw new NotFoundException(__d( 'cake_dev', 'The requested file contains `..` and will not be read.' diff --git a/lib/Cake/Test/Case/Network/CakeResponseTest.php b/lib/Cake/Test/Case/Network/CakeResponseTest.php index 41e2eba074a..6abe8c97b22 100644 --- a/lib/Cake/Test/Case/Network/CakeResponseTest.php +++ b/lib/Cake/Test/Case/Network/CakeResponseTest.php @@ -1167,17 +1167,29 @@ public function testFileNotFound() { } /** - * test file with .. + * test file with ../ * * @expectedException NotFoundException * @expectedExceptionMessage The requested file contains `..` and will not be read. * @return void */ - public function testFileWithPathTraversal() { + public function testFileWithForwardSlashPathTraversal() { $response = new CakeResponse(); $response->file('my/../cat.gif'); } +/** + * test file with ..\ + * + * @expectedException NotFoundException + * @expectedExceptionMessage The requested file contains `..` and will not be read. + * @return void + */ + public function testFileWithBackwardSlashPathTraversal() { + $response = new CakeResponse(); + $response->file('my\..\cat.gif'); + } + /** * Although unlikely, a file may contain dots in its filename. * This should be allowed, as long as the dots doesn't specify a path (../ or ..\) From 7d5e6e3a3e3498c7ebfa004ba25f71f1283708b3 Mon Sep 17 00:00:00 2001 From: mattmemmesheimer Date: Wed, 19 Aug 2015 17:50:47 -0500 Subject: [PATCH 298/336] Reverting accidental chmod. --- lib/Cake/View/Elements/Flash/default.ctp | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 lib/Cake/View/Elements/Flash/default.ctp diff --git a/lib/Cake/View/Elements/Flash/default.ctp b/lib/Cake/View/Elements/Flash/default.ctp old mode 100755 new mode 100644 From 70feb52f73861ed3177b8eda0a957c375f811170 Mon Sep 17 00:00:00 2001 From: mattmemmesheimer Date: Thu, 20 Aug 2015 20:19:22 -0500 Subject: [PATCH 299/336] Changing the default layout to use FlashComponent::render instead of the deprecated SessionComponent::flash. Changing the flash elements to retain the id attribute that was previously present. Also fixing file permissions on the template files I added. --- app/View/Layouts/default.ctp | 2 +- lib/Cake/View/Elements/Flash/default.ctp | 2 +- lib/Cake/View/Elements/Flash/error.ctp | 2 +- lib/Cake/View/Elements/Flash/success.ctp | 2 +- lib/Cake/View/Helper/FlashHelper.php | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) mode change 100755 => 100644 lib/Cake/View/Elements/Flash/error.ctp mode change 100755 => 100644 lib/Cake/View/Elements/Flash/success.ctp diff --git a/app/View/Layouts/default.ctp b/app/View/Layouts/default.ctp index fb4e9f36e62..5815ead6e78 100644 --- a/app/View/Layouts/default.ctp +++ b/app/View/Layouts/default.ctp @@ -42,7 +42,7 @@ $cakeVersion = __d('cake_dev', 'CakePHP %s', Configure::version())
- Session->flash(); ?> + Flash->render(); ?> fetch('content'); ?>
diff --git a/lib/Cake/View/Elements/Flash/default.ctp b/lib/Cake/View/Elements/Flash/default.ctp index bc1e2c36912..3080c523a6c 100644 --- a/lib/Cake/View/Elements/Flash/default.ctp +++ b/lib/Cake/View/Elements/Flash/default.ctp @@ -4,4 +4,4 @@ if (!empty($params['class'])) { $class .= ' ' . $params['class']; } ?> -
+
diff --git a/lib/Cake/View/Elements/Flash/error.ctp b/lib/Cake/View/Elements/Flash/error.ctp old mode 100755 new mode 100644 index 6d6f27e6df7..3764569886a --- a/lib/Cake/View/Elements/Flash/error.ctp +++ b/lib/Cake/View/Elements/Flash/error.ctp @@ -1 +1 @@ -
+
diff --git a/lib/Cake/View/Elements/Flash/success.ctp b/lib/Cake/View/Elements/Flash/success.ctp old mode 100755 new mode 100644 index 4a375e60fc6..13932bd7045 --- a/lib/Cake/View/Elements/Flash/success.ctp +++ b/lib/Cake/View/Elements/Flash/success.ctp @@ -1 +1 @@ -
+
diff --git a/lib/Cake/View/Helper/FlashHelper.php b/lib/Cake/View/Helper/FlashHelper.php index 46dc67ac4bb..058d191253a 100644 --- a/lib/Cake/View/Helper/FlashHelper.php +++ b/lib/Cake/View/Helper/FlashHelper.php @@ -84,6 +84,7 @@ public function render($key = 'flash', $options = array()) { $flash = $options + $flash; CakeSession::delete("Message.$key"); + $flash['key'] = $key; return $this->_View->element($flash['element'], $flash); } From 0df0f1a5592df6ece965b6029abea1e91340ceb1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 20 Aug 2015 22:36:09 -0400 Subject: [PATCH 300/336] Don't use short tags. They are not broadly supported before PHP 5.4 and we should escape all the content the core templates output. --- lib/Cake/View/Elements/Flash/default.ctp | 2 +- lib/Cake/View/Elements/Flash/error.ctp | 2 +- lib/Cake/View/Elements/Flash/success.ctp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/View/Elements/Flash/default.ctp b/lib/Cake/View/Elements/Flash/default.ctp index 3080c523a6c..820340ed431 100644 --- a/lib/Cake/View/Elements/Flash/default.ctp +++ b/lib/Cake/View/Elements/Flash/default.ctp @@ -4,4 +4,4 @@ if (!empty($params['class'])) { $class .= ' ' . $params['class']; } ?> -
+
diff --git a/lib/Cake/View/Elements/Flash/error.ctp b/lib/Cake/View/Elements/Flash/error.ctp index 3764569886a..27832145866 100644 --- a/lib/Cake/View/Elements/Flash/error.ctp +++ b/lib/Cake/View/Elements/Flash/error.ctp @@ -1 +1 @@ -
+
diff --git a/lib/Cake/View/Elements/Flash/success.ctp b/lib/Cake/View/Elements/Flash/success.ctp index 13932bd7045..dd2f8e52868 100644 --- a/lib/Cake/View/Elements/Flash/success.ctp +++ b/lib/Cake/View/Elements/Flash/success.ctp @@ -1 +1 @@ -
+
From f154a8f4d768fb7b276cac48ccfb697bf9d7c7a5 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Fri, 21 Aug 2015 12:35:49 +0200 Subject: [PATCH 301/336] Fix MediaView extension handling as documented and expected. --- lib/Cake/View/MediaView.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Cake/View/MediaView.php b/lib/Cake/View/MediaView.php index 77ba3c363ee..4cc4c131f46 100644 --- a/lib/Cake/View/MediaView.php +++ b/lib/Cake/View/MediaView.php @@ -65,7 +65,7 @@ class MediaView extends View { * @return void */ public function render($view = null, $layout = null) { - $name = $download = $id = $modified = $path = $cache = $mimeType = $compress = null; + $name = $extension = $download = $id = $modified = $path = $cache = $mimeType = $compress = null; extract($this->viewVars, EXTR_OVERWRITE); $path = $path . $id; @@ -86,7 +86,12 @@ public function render($view = null, $layout = null) { } if ($name !== null) { - $name .= '.' . pathinfo($id, PATHINFO_EXTENSION); + if (empty($extension)) { + $extension = pathinfo($id, PATHINFO_EXTENSION); + } + if (!empty($extension)) { + $name .= '.' . $extension; + } } $this->response->file($path, compact('name', 'download')); From 143c34bdc10dea7aefa10f5588c45cf0e5352442 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 22 Aug 2015 23:10:44 -0400 Subject: [PATCH 302/336] Handle case where a visible input shares a name with an invisible one. If a visible input is created *after* a hidden input was created, the form would always blackhole unless the visible input had the same value as the hidden input. Refs #7274 --- .../Test/Case/View/Helper/FormHelperTest.php | 24 +++++++++++++++++++ lib/Cake/View/Helper/FormHelper.php | 2 ++ 2 files changed, 26 insertions(+) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 0e7738ee3c0..1058bc72f38 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -1290,6 +1290,30 @@ public function testFormSecuredInput() { $this->assertTags($result, $expected); } +/** + * Test that a hidden field followed by a visible field + * undoes the hidden field locking. + * + * @return void + */ + public function testSecuredInputDuplicate() { + $this->Form->request['_Token'] = array('key' => 'testKey'); + $this->assertEquals(array(), $this->Form->fields); + + $this->Form->input('text_val', array( + 'type' => 'hidden', + 'value' => 'some text', + )); + $expected = array('text_val' => 'some text'); + $this->assertEquals($expected, $this->Form->fields); + + $this->Form->input('text_val', array( + 'type' => 'text', + )); + $expected = array('text_val'); + $this->assertEquals($expected, $this->Form->fields); + } + /** * Test secured inputs with custom names. * diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index b09e8e1c05b..1ef91877a3f 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -661,6 +661,8 @@ protected function _secure($lock, $field = null, $value = null) { if (!in_array($field, $this->fields)) { if ($value !== null) { return $this->fields[$field] = $value; + } elseif (isset($this->fields[$field]) && $value === null) { + unset($this->fields[$field]); } $this->fields[] = $field; } From 0dbabce792cf3ff04f68a5ecadefb7659113f5e3 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 23 Aug 2015 22:22:27 -0400 Subject: [PATCH 303/336] Update version number to 2.7.3 --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index 2f10769939e..c7f798220d5 100644 --- a/lib/Cake/VERSION.txt +++ b/lib/Cake/VERSION.txt @@ -17,4 +17,4 @@ // @license http://www.opensource.org/licenses/mit-license.php MIT License // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -2.7.2 +2.7.3 From 60d7bbaa104f5c67d521efb26200c70be0dd8ff5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 5 Sep 2015 22:00:43 -0400 Subject: [PATCH 304/336] Always update updated/modified columns when a fieldList is used. When a fieldList is used, and updated is not in the fieldList, the column should continue to be updated even if the column has a value from the user. Because the field is not in the fieldList, we must assume that the intent is for the field to update automatically, as it would have if the updated column was not present in the save data. Refs #7076 --- lib/Cake/Model/Model.php | 7 +++++- lib/Cake/Test/Case/Model/ModelWriteTest.php | 28 +++++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 9ded1b59e23..7fbef1832a1 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -1835,7 +1835,12 @@ protected function _doSave($data = null, $options = array()) { $now = time(); foreach ($dateFields as $updateCol) { - if (in_array($updateCol, $fields) || !$this->hasField($updateCol)) { + $fieldHasValue = in_array($updateCol, $fields); + $fieldInWhitelist = ( + count($this->whitelist) === 0 || + in_array($updateCol, $this->whitelist) + ); + if (($fieldHasValue && $fieldInWhitelist) || !$this->hasField($updateCol)) { continue; } diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index 7974fa7cc7c..1b26c8a2500 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -387,6 +387,30 @@ public function testSaveFieldListResetsWhitelistOnFailedSave() { $this->assertEquals($whitelist, $model->whitelist); } +/** + * Test that save() with a fieldList continues to write + * updated in all cases. + * + * @return void + */ + public function testSaveUpdatedWithFieldList() { + $this->loadFixtures('Post', 'Author'); + $model = ClassRegistry::init('Post'); + $original = $model->find('first', ['conditions' => ['Post.id' => 1]]); + $data = array( + 'Post' => array( + 'id' => 1, + 'title' => 'New title', + 'updated' => '1999-01-01 00:00:00', + ) + ); + $model->save($data, array( + 'fieldList' => ['title'] + )); + $new = $model->find('first', ['conditions' => ['Post.id' => 1]]); + $this->assertGreaterThan($original['Post']['updated'], $new['Post']['updated']); + } + /** * Test save() resets the whitelist after afterSave * @@ -1960,8 +1984,8 @@ public function testSaveHabtm() { 'title' => 'New Article With Tags and fieldList', 'body' => '', 'published' => 'N', - 'created' => '', - 'updated' => '' + 'created' => static::date(), + 'updated' => static::date(), ), 'Tag' => array( 0 => array( From e4cce7a44171034145b7992dae418e7cdb552bc1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 6 Sep 2015 22:14:04 -0400 Subject: [PATCH 305/336] Fix errors in PHP <5.4 --- lib/Cake/Test/Case/Model/ModelWriteTest.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index 1b26c8a2500..70ca570e991 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -396,7 +396,9 @@ public function testSaveFieldListResetsWhitelistOnFailedSave() { public function testSaveUpdatedWithFieldList() { $this->loadFixtures('Post', 'Author'); $model = ClassRegistry::init('Post'); - $original = $model->find('first', ['conditions' => ['Post.id' => 1]]); + $original = $model->find('first', array( + 'conditions' => array('Post.id' => 1) + )); $data = array( 'Post' => array( 'id' => 1, @@ -405,9 +407,11 @@ public function testSaveUpdatedWithFieldList() { ) ); $model->save($data, array( - 'fieldList' => ['title'] + 'fieldList' => array('title') + )); + $new = $model->find('first', array( + 'conditions' => array('Post.id' => 1) )); - $new = $model->find('first', ['conditions' => ['Post.id' => 1]]); $this->assertGreaterThan($original['Post']['updated'], $new['Post']['updated']); } From 9eafde13d220209f4e783ddde2dd82f6bb8499db Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 9 Sep 2015 22:08:49 -0400 Subject: [PATCH 306/336] Set the `key` variable in the SessionHelper. This fixes cross template compatibility between the Flash and Session helpers. Refs #7365 --- lib/Cake/View/Helper/SessionHelper.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Cake/View/Helper/SessionHelper.php b/lib/Cake/View/Helper/SessionHelper.php index e1fd1a20115..1670c84e9ba 100644 --- a/lib/Cake/View/Helper/SessionHelper.php +++ b/lib/Cake/View/Helper/SessionHelper.php @@ -156,6 +156,7 @@ public function flash($key = 'flash', $attrs = array()) { } $tmpVars = $flash['params']; $tmpVars['message'] = $message; + $tmpVars['key'] = $key; $out = $this->_View->element($flash['element'], $tmpVars, $options); } } From 5a7507df4fd08bac5af84be921ffb4ae4b6d8c92 Mon Sep 17 00:00:00 2001 From: Sander Visser Date: Fri, 11 Sep 2015 15:23:21 +0200 Subject: [PATCH 307/336] Fix issue "Debugger class not found" App::uses('Debugger') not needed because it's allready defined in top of file --- lib/Cake/Error/ErrorHandler.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index 2cce5768991..3192ed5f87c 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -230,6 +230,16 @@ public static function handleError($code, $description, $file = null, $line = nu } $message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']'; if (!empty($errorConfig['trace'])) { + // https://bugs.php.net/bug.php?id=65322 + if (version_compare(PHP_VERSION, '5.4.21', '<')) { + if (!class_exists('Debugger')) { + App::load('Debugger'); + } + if (!class_exists('CakeText')) { + App::uses('CakeText', 'Utility'); + App::load('CakeText'); + } + } $trace = Debugger::trace(array('start' => 1, 'format' => 'log')); $message .= "\nTrace:\n" . $trace . "\n"; } From 450a544eb4bc929735938f9607a2fad4a4c5e731 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Sun, 13 Sep 2015 13:12:53 +0200 Subject: [PATCH 308/336] Backport 3.x limit of fixture data generation. --- lib/Cake/Console/Command/Task/FixtureTask.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Console/Command/Task/FixtureTask.php b/lib/Cake/Console/Command/Task/FixtureTask.php index 05caa4629f8..c6adaf93573 100644 --- a/lib/Cake/Console/Command/Task/FixtureTask.php +++ b/lib/Cake/Console/Command/Task/FixtureTask.php @@ -74,7 +74,7 @@ public function getOptionParser() { ))->addOption('count', array( 'help' => __d('cake_console', 'When using generated data, the number of records to include in the fixture(s).'), 'short' => 'n', - 'default' => 10 + 'default' => 1 ))->addOption('connection', array( 'help' => __d('cake_console', 'Which database configuration to use for baking.'), 'short' => 'c', From d8a55ad065009463b371517aa861e2d22401451b Mon Sep 17 00:00:00 2001 From: mark Date: Wed, 16 Sep 2015 14:16:58 +0200 Subject: [PATCH 309/336] Allow CURRENT_TIMESTAMP for datetime columns - MySQL5.6+. --- lib/Cake/Model/Datasource/Database/Mysql.php | 2 +- .../Model/Datasource/Database/MysqlTest.php | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index 6a6828e2f99..24358c10787 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -352,7 +352,7 @@ public function describe($model) { if (in_array($fields[$column->Field]['type'], $this->fieldParameters['unsigned']['types'], true)) { $fields[$column->Field]['unsigned'] = $this->_unsigned($column->Type); } - if ($fields[$column->Field]['type'] === 'timestamp' && strtoupper($column->Default) === 'CURRENT_TIMESTAMP') { + if (in_array($fields[$column->Field]['type'], array('timestamp', 'datetime')) && strtoupper($column->Default) === 'CURRENT_TIMESTAMP') { $fields[$column->Field]['default'] = null; } if (!empty($column->Key) && isset($this->index[$column->Key])) { diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index 6c52c06d34c..7cf7d4565a9 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -927,6 +927,41 @@ public function testDescribeHandleCurrentTimestamp() { } /** + * Test that describe() ignores `default current_timestamp` in datetime columns. + * This is for MySQL >= 5.6. + * + * @return void + */ + public function testDescribeHandleCurrentTimestampDatetime() { + $name = $this->Dbo->fullTableName('timestamp_default_values'); + $sql = <<Dbo->execute($sql); + $model = new Model(array( + 'table' => 'timestamp_default_values', + 'ds' => 'test', + 'alias' => 'TimestampDefaultValue' + )); + $result = $this->Dbo->describe($model); + $this->Dbo->execute('DROP TABLE ' . $name); + + $this->assertNull($result['limit_date']['default']); + + $schema = new CakeSchema(array( + 'connection' => 'test', + 'testdescribes' => $result + )); + $result = $this->Dbo->createSchema($schema); + $this->assertContains('`limit_date` datetime NOT NULL,', $result); + } + + /** * test that a describe() gets additional fieldParameters * * @return void From e7d6319d598b6bef305d0ed2a4a706903e95e8fc Mon Sep 17 00:00:00 2001 From: mark Date: Thu, 17 Sep 2015 10:43:43 +0200 Subject: [PATCH 310/336] Skip test for versions of < MySQL5.6. --- lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index 7cf7d4565a9..39979d64099 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -933,6 +933,9 @@ public function testDescribeHandleCurrentTimestamp() { * @return void */ public function testDescribeHandleCurrentTimestampDatetime() { + $mysqlVersion = $this->Dbo->query('SELECT VERSION() as version', array('log' => false)); + $this->skipIf(version_compare($mysqlVersion[0][0]['version'], '5.6.0', '<')); + $name = $this->Dbo->fullTableName('timestamp_default_values'); $sql = << Date: Thu, 17 Sep 2015 11:33:59 +0200 Subject: [PATCH 311/336] Fix CS --- lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index 39979d64099..20f4d70c881 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -964,7 +964,7 @@ public function testDescribeHandleCurrentTimestampDatetime() { $this->assertContains('`limit_date` datetime NOT NULL,', $result); } - /** +/** * test that a describe() gets additional fieldParameters * * @return void From 97b6f8674c4a357f99194a7211792de885b56ed3 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Mon, 21 Sep 2015 13:45:18 +0200 Subject: [PATCH 312/336] Fix CS --- lib/Cake/Model/Datasource/DboSource.php | 2 +- lib/Cake/Network/CakeResponse.php | 2 +- lib/Cake/Test/Case/Network/Email/CakeEmailTest.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index a41e88cef12..235ff83d8cd 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -862,7 +862,7 @@ public function isConnected() { } catch (Exception $e) { $connected = false; } - $this->connected = ! empty($connected); + $this->connected = !empty($connected); return $this->connected; } diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index a1929922826..de02e9c52af 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -832,7 +832,7 @@ public function sharable($public = null, $time = null) { if (!$public && !$private && !$noCache) { return null; } - $sharable = $public || ! ($private || $noCache); + $sharable = $public || !($private || $noCache); return $sharable; } if ($public) { diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index 7945f7481fd..3be1a7f95ae 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -2288,10 +2288,10 @@ public function testCharsetsCompatible() { protected function _getEmailByOldStyleCharset($charset, $headerCharset) { $email = new CakeEmail(array('transport' => 'Debug')); - if (! empty($charset)) { + if (!empty($charset)) { $email->charset = $charset; } - if (! empty($headerCharset)) { + if (!empty($headerCharset)) { $email->headerCharset = $headerCharset; } @@ -2312,10 +2312,10 @@ protected function _getEmailByOldStyleCharset($charset, $headerCharset) { protected function _getEmailByNewStyleCharset($charset, $headerCharset) { $email = new CakeEmail(array('transport' => 'Debug')); - if (! empty($charset)) { + if (!empty($charset)) { $email->charset($charset); } - if (! empty($headerCharset)) { + if (!empty($headerCharset)) { $email->headerCharset($headerCharset); } From 8fae10a971e982771e59dc60811b7cc5add57d1e Mon Sep 17 00:00:00 2001 From: Graeme Tait Date: Mon, 21 Sep 2015 14:05:56 +0100 Subject: [PATCH 313/336] Set DboSource::$_connection to null on disconnect --- lib/Cake/Model/Datasource/DboSource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index a41e88cef12..e66ff49c16e 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -284,7 +284,7 @@ public function disconnect() { if ($this->_result instanceof PDOStatement) { $this->_result->closeCursor(); } - unset($this->_connection); + $this->_connection = null; $this->connected = false; return true; } From 1b33efaad3b3e9af87074552127839375d3cedee Mon Sep 17 00:00:00 2001 From: Graeme Tait Date: Mon, 21 Sep 2015 14:08:07 +0100 Subject: [PATCH 314/336] Check $_connection is not null before trying to use it Stops a fatal error if calling isConnected() after disconnect(). --- lib/Cake/Model/Datasource/DboSource.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index e66ff49c16e..135dfe0553a 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -857,10 +857,14 @@ public function name($data) { * @return bool True if the database is connected, else false */ public function isConnected() { - try { - $connected = $this->_connection->query('SELECT 1'); - } catch (Exception $e) { + if (is_null($this->_connection)) { $connected = false; + } else { + try { + $connected = $this->_connection->query('SELECT 1'); + } catch (Exception $e) { + $connected = false; + } } $this->connected = ! empty($connected); return $this->connected; From dc856b850865589f9810cf93bc12187902174bc9 Mon Sep 17 00:00:00 2001 From: Graeme Tait Date: Mon, 21 Sep 2015 17:00:20 +0100 Subject: [PATCH 315/336] Switch out is_null() --- lib/Cake/Model/Datasource/DboSource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 135dfe0553a..b3ae8d81422 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -857,7 +857,7 @@ public function name($data) { * @return bool True if the database is connected, else false */ public function isConnected() { - if (is_null($this->_connection)) { + if ($this->_connection === null) { $connected = false; } else { try { From c14d1ffe9390cb8f2f67146fe1045fff254a2340 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 21 Sep 2015 21:39:51 -0400 Subject: [PATCH 316/336] Add tests for #7428 --- .../Case/Model/Datasource/Database/MysqlTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index 20f4d70c881..6ad52f5390f 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -4130,4 +4130,17 @@ public function testSetValue() { $this->assertEquals("'a'", $result); } +/** + * Test isConnected + * + * @return void + */ + public function testIsConnected() { + $this->Dbo->disconnect(); + $this->assertFalse($this->Dbo->isConnected(), 'Not connected now.'); + + $this->Dbo->connect(); + $this->assertTrue($this->Dbo->isConnected(), 'Should be connected.'); + } + } From fd2dd41330a32b7900bd4c49fee10a027720363f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Fri, 25 Sep 2015 16:51:47 +0200 Subject: [PATCH 317/336] Add cakephp/cakephp-codesniffer as dev dependency --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e92b8f69d24..d5eae1773bd 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ }, "require-dev": { "phpunit/phpunit": "3.7.*", - "cakephp/debug_kit" : "2.2.*" + "cakephp/debug_kit" : "2.2.*", + "cakephp/cakephp-codesniffer": "^1.0.0" }, "bin": [ "lib/Cake/Console/cake" From e690662f0e26df0f46cb846504f2ebcf23447643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Fri, 25 Sep 2015 17:11:20 +0200 Subject: [PATCH 318/336] Various improvments to the CakePH Plib files Mostly CS, doc blocks and explicit returning nulls. --- lib/Cake/Console/Command/AclShell.php | 4 +- lib/Cake/Console/Command/Task/FixtureTask.php | 4 +- lib/Cake/Console/Command/Task/ViewTask.php | 2 +- lib/Cake/Console/Command/TestShell.php | 4 +- .../Templates/default/classes/model.ctp | 2 +- .../Console/Templates/default/views/view.ctp | 3 +- lib/Cake/Controller/Component/Acl/DbAcl.php | 1 - lib/Cake/Controller/Component/Acl/PhpAcl.php | 2 - .../Controller/Component/AclComponent.php | 4 +- .../Controller/Component/AuthComponent.php | 6 +-- .../Controller/Component/CookieComponent.php | 1 - .../Component/RequestHandlerComponent.php | 3 +- .../Controller/Component/SessionComponent.php | 2 +- lib/Cake/Core/Object.php | 1 - lib/Cake/Event/CakeEvent.php | 1 - lib/Cake/Event/CakeEventManager.php | 4 +- lib/Cake/Log/Engine/FileLog.php | 2 +- lib/Cake/Model/AclNode.php | 1 - lib/Cake/Model/Datasource/CakeSession.php | 2 +- lib/Cake/Model/Datasource/DboSource.php | 6 +-- .../Datasource/Session/DatabaseSession.php | 1 - lib/Cake/Model/Model.php | 4 +- lib/Cake/Network/CakeResponse.php | 2 +- lib/Cake/Network/CakeSocket.php | 2 +- lib/Cake/Routing/Dispatcher.php | 2 +- lib/Cake/Routing/Filter/AssetDispatcher.php | 2 +- lib/Cake/Routing/Filter/CacheDispatcher.php | 2 +- lib/Cake/Utility/Debugger.php | 7 ++- lib/Cake/Utility/Hash.php | 2 +- lib/Cake/Utility/Set.php | 4 +- lib/Cake/View/Errors/fatal_error.ctp | 1 - lib/Cake/View/Errors/missing_action.ctp | 3 +- lib/Cake/View/Errors/missing_behavior.ctp | 3 +- lib/Cake/View/Errors/missing_component.ctp | 3 +- lib/Cake/View/Errors/missing_controller.ctp | 3 +- lib/Cake/View/Errors/missing_database.ctp | 3 +- lib/Cake/View/Errors/missing_datasource.ctp | 5 +- .../View/Errors/missing_datasource_config.ctp | 3 +- lib/Cake/View/Errors/missing_helper.ctp | 3 +- lib/Cake/View/Errors/missing_layout.ctp | 3 +- lib/Cake/View/Errors/missing_plugin.ctp | 3 +- lib/Cake/View/Errors/missing_table.ctp | 5 +- lib/Cake/View/Errors/missing_view.ctp | 3 +- lib/Cake/View/Errors/pdo_error.ctp | 3 +- lib/Cake/View/Errors/private_action.ctp | 3 +- lib/Cake/View/Errors/scaffold_error.ctp | 3 +- lib/Cake/View/Helper/CacheHelper.php | 6 +-- lib/Cake/View/Helper/FlashHelper.php | 2 +- lib/Cake/View/Helper/FormHelper.php | 6 +-- lib/Cake/View/Helper/HtmlHelper.php | 2 +- lib/Cake/View/Scaffolds/form.ctp | 12 ++--- lib/Cake/View/Scaffolds/index.ctp | 22 ++++---- lib/Cake/View/Scaffolds/view.ctp | 4 +- lib/Cake/View/View.php | 2 +- lib/Cake/basics.php | 54 +++++++++---------- 55 files changed, 123 insertions(+), 120 deletions(-) diff --git a/lib/Cake/Console/Command/AclShell.php b/lib/Cake/Console/Command/AclShell.php index f5e493f7a9d..15536ebb618 100644 --- a/lib/Cake/Console/Command/AclShell.php +++ b/lib/Cake/Console/Command/AclShell.php @@ -558,7 +558,7 @@ public function parseIdentifier($identifier) { * or an array of properties to use in AcoNode::node() * * @param string $class Class type you want (Aro/Aco) - * @param string|array $identifier A mixed identifier for finding the node. + * @param string|array|null $identifier A mixed identifier for finding the node, otherwise null. * @return int Integer of NodeId. Will trigger an error if nothing is found. */ protected function _getNodeId($class, $identifier) { @@ -568,7 +568,7 @@ protected function _getNodeId($class, $identifier) { $identifier = var_export($identifier, true); } $this->error(__d('cake_console', 'Could not find node using reference "%s"', $identifier)); - return; + return null; } return Hash::get($node, "0.{$class}.id"); } diff --git a/lib/Cake/Console/Command/Task/FixtureTask.php b/lib/Cake/Console/Command/Task/FixtureTask.php index b20c22b4b79..4cd95d34aa3 100644 --- a/lib/Cake/Console/Command/Task/FixtureTask.php +++ b/lib/Cake/Console/Command/Task/FixtureTask.php @@ -210,7 +210,7 @@ public function importOptions($modelName) { * @param string $model Name of model to bake. * @param string $useTable Name of table to use. * @param array $importOptions Options for public $import - * @return string Baked fixture content + * @return string|null Baked fixture content, otherwise null. */ public function bake($model, $useTable = false, $importOptions = array()) { App::uses('CakeSchema', 'Model'); @@ -243,7 +243,7 @@ public function bake($model, $useTable = false, $importOptions = array()) { $data = $this->_Schema->read(array('models' => false, 'connection' => $this->connection)); if (!isset($data['tables'][$useTable])) { $this->err("Warning: Could not find the '${useTable}' table for ${model}."); - return; + return null; } $tableInfo = $data['tables'][$useTable]; diff --git a/lib/Cake/Console/Command/Task/ViewTask.php b/lib/Cake/Console/Command/Task/ViewTask.php index 2c49775dce6..06ecf0013cb 100644 --- a/lib/Cake/Console/Command/Task/ViewTask.php +++ b/lib/Cake/Console/Command/Task/ViewTask.php @@ -89,7 +89,7 @@ public function execute() { $this->_interactive(); } if (empty($this->args[0])) { - return; + return null; } if (!isset($this->connection)) { $this->connection = 'default'; diff --git a/lib/Cake/Console/Command/TestShell.php b/lib/Cake/Console/Command/TestShell.php index 15012bfebac..fe6cfd8730c 100644 --- a/lib/Cake/Console/Command/TestShell.php +++ b/lib/Cake/Console/Command/TestShell.php @@ -179,11 +179,11 @@ public function initialize() { /** * Parse the CLI options into an array CakeTestDispatcher can use. * - * @return array Array of params for CakeTestDispatcher + * @return array|null Array of params for CakeTestDispatcher or null. */ protected function _parseArgs() { if (empty($this->args)) { - return; + return null; } $params = array( 'core' => false, diff --git a/lib/Cake/Console/Templates/default/classes/model.ctp b/lib/Cake/Console/Templates/default/classes/model.ctp index 0014e004e32..6c3e64763fb 100644 --- a/lib/Cake/Console/Templates/default/classes/model.ctp +++ b/lib/Cake/Console/Templates/default/classes/model.ctp @@ -106,7 +106,7 @@ foreach ($associations as $assoc): if (!empty($assoc)): ?> - //The Associations below have been created with all possible keys, those that are not needed can be removed + // The Associations below have been created with all possible keys, those that are not needed can be removed \n";
- +_Instance = $adapter; $this->_Instance->initialize($this); - return; + return null; } return $this->_Instance; } diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index e36114419ce..56b6a06dd09 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -481,7 +481,7 @@ public function isAuthorized($user = null, CakeRequest $request = null) { */ public function constructAuthorize() { if (empty($this->authorize)) { - return; + return null; } $this->_authorizeObjects = array(); $config = Hash::normalize((array)$this->authorize); @@ -772,12 +772,12 @@ public function identify(CakeRequest $request, CakeResponse $response) { /** * Loads the configured authentication objects. * - * @return mixed either null on empty authenticate value, or an array of loaded objects. + * @return mixed Either null on empty authenticate value, or an array of loaded objects. * @throws CakeException */ public function constructAuthenticate() { if (empty($this->authenticate)) { - return; + return null; } $this->_authenticateObjects = array(); $config = Hash::normalize((array)$this->authenticate); diff --git a/lib/Cake/Controller/Component/CookieComponent.php b/lib/Cake/Controller/Component/CookieComponent.php index 6ed908d555b..2bb75194d60 100644 --- a/lib/Cake/Controller/Component/CookieComponent.php +++ b/lib/Cake/Controller/Component/CookieComponent.php @@ -27,7 +27,6 @@ * * @package Cake.Controller.Component * @link http://book.cakephp.org/2.0/en/core-libraries/components/cookie.html - * */ class CookieComponent extends Component { diff --git a/lib/Cake/Controller/Component/RequestHandlerComponent.php b/lib/Cake/Controller/Component/RequestHandlerComponent.php index 271b5677393..ea1d727045b 100644 --- a/lib/Cake/Controller/Component/RequestHandlerComponent.php +++ b/lib/Cake/Controller/Component/RequestHandlerComponent.php @@ -32,7 +32,6 @@ * * @package Cake.Controller.Component * @link http://book.cakephp.org/2.0/en/core-libraries/components/request-handling.html - * */ class RequestHandlerComponent extends Component { @@ -280,7 +279,7 @@ public function beforeRedirect(Controller $controller, $url, $status = null, $ex * "304 Not Modified" header. * * @param Controller $controller Controller instance. - * @return bool false if the render process should be aborted + * @return bool False if the render process should be aborted. */ public function beforeRender(Controller $controller) { if ($this->settings['checkHttpCache'] && $this->response->checkNotModified($this->request)) { diff --git a/lib/Cake/Controller/Component/SessionComponent.php b/lib/Cake/Controller/Component/SessionComponent.php index cb196775ae1..0a7dd062eaf 100644 --- a/lib/Cake/Controller/Component/SessionComponent.php +++ b/lib/Cake/Controller/Component/SessionComponent.php @@ -34,7 +34,7 @@ class SessionComponent extends Component { * Get / Set the userAgent * * @param string $userAgent Set the userAgent - * @return void + * @return string Current user agent. */ public function userAgent($userAgent = null) { return CakeSession::userAgent($userAgent); diff --git a/lib/Cake/Core/Object.php b/lib/Cake/Core/Object.php index 59ec9e3efb5..ffc7f19dc5c 100644 --- a/lib/Cake/Core/Object.php +++ b/lib/Cake/Core/Object.php @@ -31,7 +31,6 @@ class Object { /** * Constructor, no-op - * */ public function __construct() { } diff --git a/lib/Cake/Event/CakeEvent.php b/lib/Cake/Event/CakeEvent.php index 8696092838e..d8ed262347d 100644 --- a/lib/Cake/Event/CakeEvent.php +++ b/lib/Cake/Event/CakeEvent.php @@ -71,7 +71,6 @@ class CakeEvent { * $event = new CakeEvent('Order.afterBuy', $this, array('buyer' => $userData)); * $event = new CakeEvent('User.afterRegister', $UserModel); * ``` - * */ public function __construct($name, $subject = null, $data = null) { $this->_name = $name; diff --git a/lib/Cake/Event/CakeEventManager.php b/lib/Cake/Event/CakeEventManager.php index f647fd941d0..9043fbf94e1 100644 --- a/lib/Cake/Event/CakeEventManager.php +++ b/lib/Cake/Event/CakeEventManager.php @@ -172,10 +172,10 @@ public function detach($callable, $eventKey = null) { foreach (array_keys($this->_listeners) as $eventKey) { $this->detach($callable, $eventKey); } - return; + return null; } if (empty($this->_listeners[$eventKey])) { - return; + return null; } foreach ($this->_listeners[$eventKey] as $priority => $callables) { foreach ($callables as $k => $callback) { diff --git a/lib/Cake/Log/Engine/FileLog.php b/lib/Cake/Log/Engine/FileLog.php index 840889466f9..66d2ca5d2e1 100644 --- a/lib/Cake/Log/Engine/FileLog.php +++ b/lib/Cake/Log/Engine/FileLog.php @@ -196,7 +196,7 @@ protected function _rotateFile($filename) { if (!file_exists($filepath) || filesize($filepath) < $this->_size ) { - return; + return null; } if ($this->_config['rotate'] === 0) { diff --git a/lib/Cake/Model/AclNode.php b/lib/Cake/Model/AclNode.php index ab73f7b1d49..1080b9a228b 100644 --- a/lib/Cake/Model/AclNode.php +++ b/lib/Cake/Model/AclNode.php @@ -39,7 +39,6 @@ class AclNode extends Model { /** * Constructor - * */ public function __construct() { $config = Configure::read('Acl.database'); diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index b6c20b209a5..b3b471686fe 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -357,7 +357,7 @@ protected static function _validAgentAndTime() { * Get / Set the user agent * * @param string|null $userAgent Set the user agent - * @return string Current user agent + * @return string Current user agent. */ public static function userAgent($userAgent = null) { if ($userAgent) { diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 927a6e369fb..9bd3b0ca057 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -1258,7 +1258,7 @@ public function queryAssociation(Model $Model, Model $LinkModel, $type, $associa $queryTemplate = $this->generateAssociationQuery($Model, $LinkModel, $type, $association, $assocData, $queryData, $external); if (empty($queryTemplate)) { - return; + return null; } if (!is_array($resultSet)) { @@ -1952,7 +1952,7 @@ public function renderJoinStatement($data) { * * @param string $type type of query being run. e.g select, create, update, delete, schema, alter. * @param array $data Array of data to insert into the query. - * @return string Rendered SQL expression to be run. + * @return string|null Rendered SQL expression to be run, otherwise null. */ public function renderStatement($type, $data) { extract($data); @@ -1986,7 +1986,7 @@ public function renderStatement($type, $data) { } return "CREATE TABLE {$table} (\n{$columns}{$indexes}) {$tableParameters};"; case 'alter': - return; + return null; } } diff --git a/lib/Cake/Model/Datasource/Session/DatabaseSession.php b/lib/Cake/Model/Datasource/Session/DatabaseSession.php index 08c398a7a37..a9c6e862772 100644 --- a/lib/Cake/Model/Datasource/Session/DatabaseSession.php +++ b/lib/Cake/Model/Datasource/Session/DatabaseSession.php @@ -43,7 +43,6 @@ class DatabaseSession implements CakeSessionHandlerInterface { /** * Constructor. Looks at Session configuration information and * sets up the session model. - * */ public function __construct() { $modelName = Configure::read('Session.handler.model'); diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index bfce2dd41c2..1b094cdf5c4 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -1190,12 +1190,12 @@ public function setSource($tableName) { * * @param string|array|SimpleXmlElement|DomNode $one Array or string of data * @param string $two Value string for the alternative indata method - * @return array Data with all of $one's keys and values + * @return array|null Data with all of $one's keys and values, otherwise null. * @link http://book.cakephp.org/2.0/en/models/saving-your-data.html */ public function set($one, $two = null) { if (!$one) { - return; + return null; } if (is_object($one)) { diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index 3c5a3c46af0..fdefe1478d6 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -452,7 +452,7 @@ protected function _setCookies() { /** * Formats the Content-Type header based on the configured contentType and charset - * the charset will only be set in the header if the response is of type text/* + * the charset will only be set in the header if the response is of type text * * @return void */ diff --git a/lib/Cake/Network/CakeSocket.php b/lib/Cake/Network/CakeSocket.php index b4c378900a1..aebdee1913a 100644 --- a/lib/Cake/Network/CakeSocket.php +++ b/lib/Cake/Network/CakeSocket.php @@ -216,7 +216,7 @@ protected function _connectionErrorHandler($code, $message) { */ public function context() { if (!$this->connection) { - return; + return null; } return stream_context_get_options($this->connection); } diff --git a/lib/Cake/Routing/Dispatcher.php b/lib/Cake/Routing/Dispatcher.php index 13e2a2248a9..87c0a81161d 100644 --- a/lib/Cake/Routing/Dispatcher.php +++ b/lib/Cake/Routing/Dispatcher.php @@ -152,7 +152,7 @@ public function dispatch(CakeRequest $request, CakeResponse $response, $addition return $beforeEvent->result->body(); } $beforeEvent->result->send(); - return; + return null; } $controller = $this->_getController($request, $response); diff --git a/lib/Cake/Routing/Filter/AssetDispatcher.php b/lib/Cake/Routing/Filter/AssetDispatcher.php index 3a4908bcf68..c90a8235c0d 100644 --- a/lib/Cake/Routing/Filter/AssetDispatcher.php +++ b/lib/Cake/Routing/Filter/AssetDispatcher.php @@ -42,7 +42,7 @@ class AssetDispatcher extends DispatcherFilter { public function beforeDispatch(CakeEvent $event) { $url = urldecode($event->data['request']->url); if (strpos($url, '..') !== false || strpos($url, '.') === false) { - return; + return null; } if ($result = $this->_filterAsset($event)) { diff --git a/lib/Cake/Routing/Filter/CacheDispatcher.php b/lib/Cake/Routing/Filter/CacheDispatcher.php index 9219005bbd4..24361bf3bbe 100644 --- a/lib/Cake/Routing/Filter/CacheDispatcher.php +++ b/lib/Cake/Routing/Filter/CacheDispatcher.php @@ -39,7 +39,7 @@ class CacheDispatcher extends DispatcherFilter { */ public function beforeDispatch(CakeEvent $event) { if (Configure::read('Cache.check') !== true) { - return; + return null; } $path = $event->data['request']->here(); diff --git a/lib/Cake/Utility/Debugger.php b/lib/Cake/Utility/Debugger.php index b6fccf2aa95..ec29a4d6eb9 100644 --- a/lib/Cake/Utility/Debugger.php +++ b/lib/Cake/Utility/Debugger.php @@ -91,7 +91,6 @@ class Debugger { /** * Constructor. - * */ public function __construct() { $docRef = ini_get('docref_root'); @@ -200,7 +199,7 @@ public static function log($var, $level = LOG_DEBUG, $depth = 3) { * @param string $file File on which error occurred * @param int $line Line that triggered the error * @param array $context Context - * @return bool true if error was handled + * @return bool|null True if error was handled, otherwise null. * @deprecated 3.0.0 Will be removed in 3.0. This function is superseded by Debugger::outputError(). */ public static function showError($code, $description, $file = null, $line = null, $context = null) { @@ -217,7 +216,7 @@ public static function showError($code, $description, $file = null, $line = null if (!in_array($info, $self->errors)) { $self->errors[] = $info; } else { - return; + return null; } switch ($code) { @@ -247,7 +246,7 @@ public static function showError($code, $description, $file = null, $line = null $level = LOG_NOTICE; break; default: - return; + return null; } $data = compact( diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index ad06cf95b69..451e8f13e95 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -465,7 +465,7 @@ public static function format(array $data, array $paths, $format) { $count = count($paths); if (!$count) { - return; + return null; } for ($i = 0; $i < $count; $i++) { diff --git a/lib/Cake/Utility/Set.php b/lib/Cake/Utility/Set.php index d52c8d7ad0b..10750c1c62e 100644 --- a/lib/Cake/Utility/Set.php +++ b/lib/Cake/Utility/Set.php @@ -228,7 +228,7 @@ public static function enum($select, $list = null) { * @param array $data Source array from which to extract the data * @param string $format Format string into which values will be inserted, see sprintf() * @param array $keys An array containing one or more Set::extract()-style key paths - * @return array An array of strings extracted from $keys and formatted with $format + * @return array|null An array of strings extracted from $keys and formatted with $format, otherwise null. * @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::format */ public static function format($data, $format, $keys) { @@ -236,7 +236,7 @@ public static function format($data, $format, $keys) { $count = count($keys); if (!$count) { - return; + return null; } for ($i = 0; $i < $count; $i++) { diff --git a/lib/Cake/View/Errors/fatal_error.ctp b/lib/Cake/View/Errors/fatal_error.ctp index 0871555b872..52b2a8a72c1 100644 --- a/lib/Cake/View/Errors/fatal_error.ctp +++ b/lib/Cake/View/Errors/fatal_error.ctp @@ -36,4 +36,3 @@ if (extension_loaded('xdebug')) { xdebug_print_function_stack(); } -?> diff --git a/lib/Cake/View/Errors/missing_action.ctp b/lib/Cake/View/Errors/missing_action.ctp index 5876e9304c3..f507cd11039 100644 --- a/lib/Cake/View/Errors/missing_action.ctp +++ b/lib/Cake/View/Errors/missing_action.ctp @@ -38,4 +38,5 @@ class extends AppController { :

-element('exception_stack_trace'); ?> +element('exception_stack_trace'); diff --git a/lib/Cake/View/Errors/missing_behavior.ctp b/lib/Cake/View/Errors/missing_behavior.ctp index e8024ebf347..dee50802ef0 100644 --- a/lib/Cake/View/Errors/missing_behavior.ctp +++ b/lib/Cake/View/Errors/missing_behavior.ctp @@ -36,4 +36,5 @@ class extends ModelBehavior {

-element('exception_stack_trace'); ?> +element('exception_stack_trace'); diff --git a/lib/Cake/View/Errors/missing_component.ctp b/lib/Cake/View/Errors/missing_component.ctp index ab5d77cf956..2bb1455e3ab 100644 --- a/lib/Cake/View/Errors/missing_component.ctp +++ b/lib/Cake/View/Errors/missing_component.ctp @@ -36,4 +36,5 @@ class extends Component {

-element('exception_stack_trace'); ?> +element('exception_stack_trace'); diff --git a/lib/Cake/View/Errors/missing_controller.ctp b/lib/Cake/View/Errors/missing_controller.ctp index 7f31ff8f4d4..c20c9c87ab0 100644 --- a/lib/Cake/View/Errors/missing_controller.ctp +++ b/lib/Cake/View/Errors/missing_controller.ctp @@ -36,4 +36,5 @@ class AppController {

-element('exception_stack_trace'); ?> +element('exception_stack_trace'); diff --git a/lib/Cake/View/Errors/missing_database.ctp b/lib/Cake/View/Errors/missing_database.ctp index 0432b742407..73c9ccd5067 100644 --- a/lib/Cake/View/Errors/missing_database.ctp +++ b/lib/Cake/View/Errors/missing_database.ctp @@ -28,4 +28,5 @@

-element('exception_stack_trace'); ?> +element('exception_stack_trace'); diff --git a/lib/Cake/View/Errors/missing_datasource.ctp b/lib/Cake/View/Errors/missing_datasource.ctp index 9a16d508c13..7b4868374a7 100644 --- a/lib/Cake/View/Errors/missing_datasource.ctp +++ b/lib/Cake/View/Errors/missing_datasource.ctp @@ -20,7 +20,7 @@ $pluginDot = empty($plugin) ? null : $plugin . '.';

: ' . h($pluginDot . $class) . ''); ?> - +

@@ -29,4 +29,5 @@ $pluginDot = empty($plugin) ? null : $plugin . '.';

-element('exception_stack_trace'); ?> +element('exception_stack_trace'); diff --git a/lib/Cake/View/Errors/missing_datasource_config.ctp b/lib/Cake/View/Errors/missing_datasource_config.ctp index 0fe5929a67f..b08f2d56baa 100644 --- a/lib/Cake/View/Errors/missing_datasource_config.ctp +++ b/lib/Cake/View/Errors/missing_datasource_config.ctp @@ -24,4 +24,5 @@

-element('exception_stack_trace'); ?> +element('exception_stack_trace'); diff --git a/lib/Cake/View/Errors/missing_helper.ctp b/lib/Cake/View/Errors/missing_helper.ctp index 93fa54ed239..0da9aa00e97 100644 --- a/lib/Cake/View/Errors/missing_helper.ctp +++ b/lib/Cake/View/Errors/missing_helper.ctp @@ -36,4 +36,5 @@ class extends AppHelper {

-element('exception_stack_trace'); ?> +element('exception_stack_trace'); diff --git a/lib/Cake/View/Errors/missing_layout.ctp b/lib/Cake/View/Errors/missing_layout.ctp index b8c5d81cf50..e1cf0dfcbc6 100644 --- a/lib/Cake/View/Errors/missing_layout.ctp +++ b/lib/Cake/View/Errors/missing_layout.ctp @@ -41,4 +41,5 @@

-element('exception_stack_trace'); ?> +element('exception_stack_trace'); diff --git a/lib/Cake/View/Errors/missing_plugin.ctp b/lib/Cake/View/Errors/missing_plugin.ctp index 0d5592e71aa..b2f02bc70b9 100644 --- a/lib/Cake/View/Errors/missing_plugin.ctp +++ b/lib/Cake/View/Errors/missing_plugin.ctp @@ -40,4 +40,5 @@ CakePlugin::loadAll();

-element('exception_stack_trace'); ?> +element('exception_stack_trace'); diff --git a/lib/Cake/View/Errors/missing_table.ctp b/lib/Cake/View/Errors/missing_table.ctp index 7c308a864bb..34e943e04f5 100644 --- a/lib/Cake/View/Errors/missing_table.ctp +++ b/lib/Cake/View/Errors/missing_table.ctp @@ -17,11 +17,12 @@

: - ' . h($table) . '', '' . h($class) . '', '' . h($ds) . ''); ?> + ' . h($table) . '', '' . h($class) . '', '' . h($ds) . ''); ?>

:

-element('exception_stack_trace'); ?> +element('exception_stack_trace'); diff --git a/lib/Cake/View/Errors/missing_view.ctp b/lib/Cake/View/Errors/missing_view.ctp index b2579d57857..37c3dcca81b 100644 --- a/lib/Cake/View/Errors/missing_view.ctp +++ b/lib/Cake/View/Errors/missing_view.ctp @@ -41,4 +41,5 @@

-element('exception_stack_trace'); ?> +element('exception_stack_trace'); diff --git a/lib/Cake/View/Errors/pdo_error.ctp b/lib/Cake/View/Errors/pdo_error.ctp index b9c7a0ca350..71afc6f0a23 100644 --- a/lib/Cake/View/Errors/pdo_error.ctp +++ b/lib/Cake/View/Errors/pdo_error.ctp @@ -33,4 +33,5 @@ :

-element('exception_stack_trace'); ?> +element('exception_stack_trace'); diff --git a/lib/Cake/View/Errors/private_action.ctp b/lib/Cake/View/Errors/private_action.ctp index 11a18a3b809..00810609eee 100644 --- a/lib/Cake/View/Errors/private_action.ctp +++ b/lib/Cake/View/Errors/private_action.ctp @@ -24,4 +24,5 @@

-element('exception_stack_trace'); ?> +element('exception_stack_trace'); diff --git a/lib/Cake/View/Errors/scaffold_error.ctp b/lib/Cake/View/Errors/scaffold_error.ctp index ce1eea8e677..998d75e76a8 100644 --- a/lib/Cake/View/Errors/scaffold_error.ctp +++ b/lib/Cake/View/Errors/scaffold_error.ctp @@ -33,6 +33,5 @@ function _scaffoldError() {
element('exception_stack_trace'); + echo $this->element('exception_stack_trace'); } -?> diff --git a/lib/Cake/View/Helper/CacheHelper.php b/lib/Cake/View/Helper/CacheHelper.php index a6c7f47e36d..ed5560a5251 100644 --- a/lib/Cake/View/Helper/CacheHelper.php +++ b/lib/Cake/View/Helper/CacheHelper.php @@ -271,8 +271,8 @@ protected function _parseOutput($cache) { * * @param string $content view content to write to a cache file. * @param string $timestamp Duration to set for cache file. - * @param bool $useCallbacks Whether to include statements in cached file which - * run callbacks. + * @param bool|null $useCallbacks Whether to include statements in cached file which + * run callbacks, otherwise null. * @return bool success of caching view. */ protected function _writeFile($content, $timestamp, $useCallbacks = false) { @@ -294,7 +294,7 @@ protected function _writeFile($content, $timestamp, $useCallbacks = false) { $cache = strtolower(Inflector::slug($path)); if (empty($cache)) { - return; + return null; } $cache = $cache . '.php'; $file = '_getModel($model); if (!$object) { - return; + return null; } if ($key === 'key') { @@ -561,12 +561,12 @@ public function end($options = null, $secureAttributes = array()) { * generating the hash, else $this->fields is being used. * @param array $secureAttributes will be passed as html attributes into the hidden * input elements generated for the Security Component. - * @return string A hidden input field with a security hash + * @return string|null A hidden input field with a security hash, otherwise null. * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::secure */ public function secure($fields = array(), $secureAttributes = array()) { if (!isset($this->request['_Token']) || empty($this->request['_Token'])) { - return; + return null; } $locked = array(); $unlockedFields = $this->_unlockedFields; diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index a9c99e0cc4c..5098cec8670 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -446,7 +446,7 @@ public function css($path, $options = array()) { if (empty($options['block'])) { return $out . "\n"; } - return; + return ''; } if ($options['once'] && isset($this->_includedAssets[__METHOD__][$path])) { diff --git a/lib/Cake/View/Scaffolds/form.ctp b/lib/Cake/View/Scaffolds/form.ctp index 2f2face1d8b..0a6b5ddea70 100644 --- a/lib/Cake/View/Scaffolds/form.ctp +++ b/lib/Cake/View/Scaffolds/form.ctp @@ -35,9 +35,9 @@
  • Html->link(__d('cake', 'List') . ' ' . $pluralHumanName, array('action' => 'index')); ?>
  • $_data) { - foreach ($_data as $_alias => $_details) { - if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { + foreach ($associations as $_type => $_data): + foreach ($_data as $_alias => $_details): + if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)): echo "\t\t
  • " . $this->Html->link( __d('cake', 'List %s', Inflector::humanize($_details['controller'])), array('plugin' => $_details['plugin'], 'controller' => $_details['controller'], 'action' => 'index') @@ -47,9 +47,9 @@ array('plugin' => $_details['plugin'], 'controller' => $_details['controller'], 'action' => 'add') ) . "
  • \n"; $done[] = $_details['controller']; - } - } - } + endif; + endforeach; + endforeach; ?> diff --git a/lib/Cake/View/Scaffolds/index.ctp b/lib/Cake/View/Scaffolds/index.ctp index dbae1916789..e0219f4f0b3 100644 --- a/lib/Cake/View/Scaffolds/index.ctp +++ b/lib/Cake/View/Scaffolds/index.ctp @@ -26,21 +26,21 @@ '; - foreach ($scaffoldFields as $_field) { + foreach ($scaffoldFields as $_field): $isKey = false; - if (!empty($associations['belongsTo'])) { - foreach ($associations['belongsTo'] as $_alias => $_details) { - if ($_field === $_details['foreignKey']) { + if (!empty($associations['belongsTo'])): + foreach ($associations['belongsTo'] as $_alias => $_details): + if ($_field === $_details['foreignKey']): $isKey = true; echo '' . $this->Html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller' => $_details['controller'], 'action' => 'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . ''; break; - } - } - } - if ($isKey !== true) { + endif; + endforeach; + endif; + if ($isKey !== true): echo '' . h(${$singularVar}[$modelClass][$_field]) . ''; - } - } + endif; + endforeach; echo ''; echo $this->Html->link(__d('cake', 'View'), array('action' => 'view', ${$singularVar}[$modelClass][$primaryKey])); @@ -67,7 +67,7 @@ endforeach; Paginator->prev('< ' . __d('cake', 'previous'), array(), null, array('class' => 'prev disabled')); echo $this->Paginator->numbers(array('separator' => '')); - echo $this->Paginator->next(__d('cake', 'next') .' >', array(), null, array('class' => 'next disabled')); + echo $this->Paginator->next(__d('cake', 'next') . ' >', array(), null, array('class' => 'next disabled')); ?> diff --git a/lib/Cake/View/Scaffolds/view.ctp b/lib/Cake/View/Scaffolds/view.ctp index 8ec83432f80..64a3e31f156 100644 --- a/lib/Cake/View/Scaffolds/view.ctp +++ b/lib/Cake/View/Scaffolds/view.ctp @@ -95,10 +95,10 @@ foreach ($associations['hasOne'] as $_alias => $_details): ?>
    " . Inflector::humanize($_field) . "\n"; echo "\t\t
    \n\t" . ${$singularVar}[$_alias][$_field] . "\n 
    \n"; - } + endforeach; ?>
    diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index e1014fad38b..12434f7d29c 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -464,7 +464,7 @@ public function elementExists($name) { */ public function render($view = null, $layout = null) { if ($this->hasRendered) { - return; + return null; } if ($view !== false && $viewFileName = $this->_getViewFileName($view)) { diff --git a/lib/Cake/basics.php b/lib/Cake/basics.php index 51afffa187f..e1edb6ea167 100644 --- a/lib/Cake/basics.php +++ b/lib/Cake/basics.php @@ -580,7 +580,7 @@ function stripslashes_deep($values) { */ function __($singular, $args = null) { if (!$singular) { - return; + return null; } App::uses('I18n', 'I18n'); @@ -600,13 +600,13 @@ function __($singular, $args = null) { * @param string $singular Singular text to translate * @param string $plural Plural text * @param int $count Count - * @param mixed $args Array with arguments or multiple arguments in function + * @param mixed $args Array with arguments or multiple arguments in function, otherwise null. * @return mixed plural form of translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__n */ function __n($singular, $plural, $count, $args = null) { if (!$singular) { - return; + return null; } App::uses('I18n', 'I18n'); @@ -624,13 +624,13 @@ function __n($singular, $plural, $count, $args = null) { * * @param string $domain Domain * @param string $msg String to translate - * @param mixed $args Array with arguments or multiple arguments in function + * @param mixed $args Array with arguments or multiple arguments in function, otherwise null. * @return string translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__d */ function __d($domain, $msg, $args = null) { if (!$msg) { - return; + return null; } App::uses('I18n', 'I18n'); $translated = I18n::translate($msg, null, $domain); @@ -651,13 +651,13 @@ function __d($domain, $msg, $args = null) { * @param string $singular Singular string to translate * @param string $plural Plural * @param int $count Count - * @param mixed $args Array with arguments or multiple arguments in function + * @param mixed $args Array with arguments or multiple arguments in function, otherwise null. * @return string plural form of translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dn */ function __dn($domain, $singular, $plural, $count, $args = null) { if (!$singular) { - return; + return null; } App::uses('I18n', 'I18n'); $translated = I18n::translate($singular, $plural, $domain, I18n::LC_MESSAGES, $count); @@ -689,13 +689,13 @@ function __dn($domain, $singular, $plural, $count, $args = null) { * @param string $domain Domain * @param string $msg Message to translate * @param int $category Category - * @param mixed $args Array with arguments or multiple arguments in function + * @param mixed $args Array with arguments or multiple arguments in function, otherwise null. * @return string translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dc */ function __dc($domain, $msg, $category, $args = null) { if (!$msg) { - return; + return null; } App::uses('I18n', 'I18n'); $translated = I18n::translate($msg, null, $domain, $category); @@ -731,13 +731,13 @@ function __dc($domain, $msg, $category, $args = null) { * @param string $plural Plural * @param int $count Count * @param int $category Category - * @param mixed $args Array with arguments or multiple arguments in function + * @param mixed $args Array with arguments or multiple arguments in function, otherwise null. * @return string plural form of translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dcn */ function __dcn($domain, $singular, $plural, $count, $category, $args = null) { if (!$singular) { - return; + return null; } App::uses('I18n', 'I18n'); $translated = I18n::translate($singular, $plural, $domain, $category, $count); @@ -765,13 +765,13 @@ function __dcn($domain, $singular, $plural, $count, $category, $args = null) { * * @param string $msg String to translate * @param int $category Category - * @param mixed $args Array with arguments or multiple arguments in function + * @param mixed $args Array with arguments or multiple arguments in function, otherwise null. * @return string translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__c */ function __c($msg, $category, $args = null) { if (!$msg) { - return; + return null; } App::uses('I18n', 'I18n'); $translated = I18n::translate($msg, null, null, $category); @@ -788,13 +788,13 @@ function __c($msg, $category, $args = null) { * * @param string $context Context of the text * @param string $singular Text to translate - * @param mixed $args Array with arguments or multiple arguments in function + * @param mixed $args Array with arguments or multiple arguments in function, otherwise null. * @return mixed translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__ */ function __x($context, $singular, $args = null) { if (!$singular) { - return; + return null; } App::uses('I18n', 'I18n'); @@ -815,13 +815,13 @@ function __x($context, $singular, $args = null) { * @param string $singular Singular text to translate * @param string $plural Plural text * @param int $count Count - * @param mixed $args Array with arguments or multiple arguments in function + * @param mixed $args Array with arguments or multiple arguments in function, otherwise null. * @return mixed plural form of translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__n */ function __xn($context, $singular, $plural, $count, $args = null) { if (!$singular) { - return; + return null; } App::uses('I18n', 'I18n'); @@ -840,13 +840,13 @@ function __xn($context, $singular, $plural, $count, $args = null) { * @param string $domain Domain * @param string $context Context of the text * @param string $msg String to translate - * @param mixed $args Array with arguments or multiple arguments in function + * @param mixed $args Array with arguments or multiple arguments in function, otherwise null. * @return string translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__d */ function __dx($domain, $context, $msg, $args = null) { if (!$msg) { - return; + return null; } App::uses('I18n', 'I18n'); $translated = I18n::translate($msg, null, $domain, null, null, null, $context); @@ -868,13 +868,13 @@ function __dx($domain, $context, $msg, $args = null) { * @param string $singular Singular string to translate * @param string $plural Plural * @param int $count Count - * @param mixed $args Array with arguments or multiple arguments in function + * @param mixed $args Array with arguments or multiple arguments in function, otherwise null. * @return string plural form of translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dn */ function __dxn($domain, $context, $singular, $plural, $count, $args = null) { if (!$singular) { - return; + return null; } App::uses('I18n', 'I18n'); $translated = I18n::translate($singular, $plural, $domain, I18n::LC_MESSAGES, $count, null, $context); @@ -907,13 +907,13 @@ function __dxn($domain, $context, $singular, $plural, $count, $args = null) { * @param string $context Context of the text * @param string $msg Message to translate * @param int $category Category - * @param mixed $args Array with arguments or multiple arguments in function + * @param mixed $args Array with arguments or multiple arguments in function, otherwise null. * @return string translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dc */ function __dxc($domain, $context, $msg, $category, $args = null) { if (!$msg) { - return; + return null; } App::uses('I18n', 'I18n'); $translated = I18n::translate($msg, null, $domain, $category, null, null, $context); @@ -950,13 +950,13 @@ function __dxc($domain, $context, $msg, $category, $args = null) { * @param string $plural Plural * @param int $count Count * @param int $category Category - * @param mixed $args Array with arguments or multiple arguments in function + * @param mixed $args Array with arguments or multiple arguments in function, otherwise null. * @return string plural form of translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dcn */ function __dxcn($domain, $context, $singular, $plural, $count, $category, $args = null) { if (!$singular) { - return; + return null; } App::uses('I18n', 'I18n'); $translated = I18n::translate($singular, $plural, $domain, $category, $count, null, $context); @@ -985,13 +985,13 @@ function __dxcn($domain, $context, $singular, $plural, $count, $category, $args * @param string $context Context of the text * @param string $msg String to translate * @param int $category Category - * @param mixed $args Array with arguments or multiple arguments in function + * @param mixed $args Array with arguments or multiple arguments in function, otherwise null. * @return string translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__c */ function __xc($context, $msg, $category, $args = null) { if (!$msg) { - return; + return null; } App::uses('I18n', 'I18n'); $translated = I18n::translate($msg, null, null, $category, null, null, $context); From 1ede742d926e3b8a060fcfb1a6dda2eb3e5c10c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Fri, 25 Sep 2015 17:22:00 +0200 Subject: [PATCH 319/336] Various improvements to the CakePHP test files Mostly CS, doc blocks and unused variables. --- .../Case/Console/ConsoleOptionParserTest.php | 10 +++++----- .../Controller/Component/Acl/DbAclTest.php | 1 - .../Auth/ControllerAuthorizeTest.php | 4 ++++ .../Component/AuthComponentTest.php | 3 +-- .../Component/PaginatorComponentTest.php | 4 ++-- .../Test/Case/Controller/ControllerTest.php | 2 +- lib/Cake/Test/Case/Core/CakePluginTest.php | 1 - lib/Cake/Test/Case/Core/ConfigureTest.php | 3 +++ lib/Cake/Test/Case/Core/ObjectTest.php | 9 +++++---- .../Test/Case/Event/CakeEventManagerTest.php | 1 - lib/Cake/Test/Case/Event/CakeEventTest.php | 1 - lib/Cake/Test/Case/Model/AclNodeTest.php | 3 +-- lib/Cake/Test/Case/Model/models.php | 1 - .../Test/Case/Network/CakeRequestTest.php | 8 +------- .../Test/Case/Network/CakeResponseTest.php | 8 ++++---- .../Test/Case/Network/Email/CakeEmailTest.php | 13 ++++-------- .../Case/Network/Email/DebugTransportTest.php | 1 - .../Case/Network/Email/MailTransportTest.php | 1 - .../Case/Network/Email/SmtpTransportTest.php | 10 ++++------ .../Test/Case/Network/Http/HttpSocketTest.php | 14 ++++++------- .../Routing/Filter/AssetDispatcherTest.php | 1 - .../Case/Routing/Route/RedirectRouteTest.php | 20 +++++++++---------- lib/Cake/Test/Case/Routing/RouterTest.php | 6 +++--- .../Test/Case/TestSuite/CakeTestCaseTest.php | 14 ++++++------- .../Case/TestSuite/CakeTestFixtureTest.php | 2 +- .../Case/TestSuite/ControllerTestCaseTest.php | 8 ++++---- lib/Cake/Test/Case/Utility/FolderTest.php | 2 +- .../Case/Utility/ObjectCollectionTest.php | 4 ++-- lib/Cake/Test/Case/Utility/SanitizeTest.php | 2 +- lib/Cake/Test/Case/Utility/SecurityTest.php | 2 +- lib/Cake/Test/Case/Utility/SetTest.php | 1 - lib/Cake/Test/Case/Utility/ValidationTest.php | 2 +- lib/Cake/Test/Case/Utility/XmlTest.php | 6 +++--- .../Test/bake_compare/Controller/Scaffold.ctp | 1 - .../Datasource/Session/TestAppLibSession.php | 1 - .../TestPlugin/View/Errors/error500.ctp | 1 - .../Test/test_app/View/Elements/html_call.ctp | 3 +-- .../test_app/View/Emails/html/default.ctp | 3 +-- lib/Cake/Test/test_app/View/Layouts/ajax2.ctp | 3 ++- .../test_app/View/Layouts/rss/default.ctp | 4 +--- .../test_app/View/Posts/helper_overwrite.ctp | 3 +-- .../Test/test_app/View/Posts/parent_view.ctp | 2 +- .../test_app/View/Posts/test_nocache_tags.ctp | 2 +- .../Themed/TestTheme/Emails/text/themed.ctp | 2 +- .../View/Themed/TestTheme/Layouts/default.ctp | 2 +- lib/Cake/TestSuite/CakeTestCase.php | 4 ++-- lib/Cake/TestSuite/CakeTestLoader.php | 6 +++--- lib/Cake/TestSuite/ControllerTestCase.php | 2 +- .../TestSuite/Reporter/CakeHtmlReporter.php | 4 ++-- lib/Cake/TestSuite/templates/header.php | 2 +- 50 files changed, 94 insertions(+), 119 deletions(-) diff --git a/lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php b/lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php index 0b68f999a70..5a194db086f 100644 --- a/lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php +++ b/lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php @@ -37,7 +37,7 @@ public function testDescription() { $this->assertEquals($parser, $result, 'Setting description is not chainable'); $this->assertEquals('A test', $parser->description(), 'getting value is wrong.'); - $result = $parser->description(array('A test', 'something')); + $parser->description(array('A test', 'something')); $this->assertEquals("A test\nsomething", $parser->description(), 'getting value is wrong.'); } @@ -53,7 +53,7 @@ public function testEpilog() { $this->assertEquals($parser, $result, 'Setting epilog is not chainable'); $this->assertEquals('A test', $parser->epilog(), 'getting value is wrong.'); - $result = $parser->epilog(array('A test', 'something')); + $parser->epilog(array('A test', 'something')); $this->assertEquals("A test\nsomething", $parser->epilog(), 'getting value is wrong.'); } @@ -294,7 +294,7 @@ public function testOptionWithChoices() { $expected = array('name' => 'mark', 'help' => false); $this->assertEquals($expected, $result[0], 'Got the correct value.'); - $result = $parser->parse(array('--name', 'jimmy')); + $parser->parse(array('--name', 'jimmy')); } /** @@ -384,7 +384,7 @@ public function testParseArgumentTooMany() { $result = $parser->parse($expected); $this->assertEquals($expected, $result[1], 'Arguments are not as expected'); - $result = $parser->parse(array('one', 'two', 'three')); + $parser->parse(array('one', 'two', 'three')); } /** @@ -430,7 +430,7 @@ public function testPositionalArgWithChoices() { $expected = array('mark', 'samurai', 'sword'); $this->assertEquals($expected, $result[1], 'Got the correct value.'); - $result = $parser->parse(array('jose', 'coder')); + $parser->parse(array('jose', 'coder')); } /** diff --git a/lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php b/lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php index d4f2b6347d6..b1f927a5832 100644 --- a/lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php @@ -155,7 +155,6 @@ class DbAclTwoTest extends DbAcl { /** * construct method - * */ public function __construct() { $this->Aro = new AroTwoTest(); diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php index 8c57c6e766b..80bb5c25860 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php @@ -45,6 +45,8 @@ public function setUp() { } /** + * testControllerTypeError + * * @expectedException PHPUnit_Framework_Error * @return void */ @@ -53,6 +55,8 @@ public function testControllerTypeError() { } /** + * testControllerErrorOnMissingMethod + * * @expectedException CakeException * @return void */ diff --git a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php index b66252f2410..8faae470ade 100644 --- a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php @@ -176,7 +176,6 @@ class AuthTestController extends Controller { /** * construct method - * */ public function __construct($request, $response) { $request->addParams(Router::parse('/auth_test')); @@ -1319,7 +1318,7 @@ public function testAjaxLoginResponseCodeNoElement() { ->with('HTTP/1.1 403 Forbidden', null); $this->Auth->initialize($this->Controller); - $result = $this->Auth->startup($this->Controller); + $this->Auth->startup($this->Controller); $this->assertArrayNotHasKey('Location', $this->Controller->response->header()); $this->assertNull($this->Controller->testUrl, 'redirect() not called'); diff --git a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php index 234d2dac3b8..fbcccc26659 100644 --- a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php @@ -486,7 +486,7 @@ public function testPaginateExtraParams() { $Controller->request->params['named'] = array('limit' => 12); $Controller->Paginator->settings = array('limit' => 30, 'maxLimit' => 100, 'paramType' => 'named'); - $result = $Controller->Paginator->paginate('PaginatorControllerPost'); + $Controller->Paginator->paginate('PaginatorControllerPost'); $paging = $Controller->params['paging']['PaginatorControllerPost']; $this->assertEquals(12, $Controller->PaginatorControllerPost->lastQueries[0]['limit']); @@ -504,7 +504,7 @@ public function testPaginateExtraParams() { 'paramType' => 'named' ) ); - $result = $Controller->Paginator->paginate('ControllerPaginateModel'); + $Controller->Paginator->paginate('ControllerPaginateModel'); $expected = array( 'contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id', diff --git a/lib/Cake/Test/Case/Controller/ControllerTest.php b/lib/Cake/Test/Case/Controller/ControllerTest.php index f319bd1672d..a8abc2bdd11 100644 --- a/lib/Cake/Test/Case/Controller/ControllerTest.php +++ b/lib/Cake/Test/Case/Controller/ControllerTest.php @@ -653,7 +653,7 @@ public function testRender() { $expected = $Controller->ControllerComment->validationErrors; $Controller->viewPath = 'Posts'; - $result = $Controller->render('index'); + $Controller->render('index'); $View = $Controller->View; $this->assertTrue(isset($View->validationErrors['ControllerComment'])); $this->assertEquals($expected, $View->validationErrors['ControllerComment']); diff --git a/lib/Cake/Test/Case/Core/CakePluginTest.php b/lib/Cake/Test/Case/Core/CakePluginTest.php index 94bc3c5acf7..3398d166132 100644 --- a/lib/Cake/Test/Case/Core/CakePluginTest.php +++ b/lib/Cake/Test/Case/Core/CakePluginTest.php @@ -20,7 +20,6 @@ /** * CakePluginTest class - * */ class CakePluginTest extends CakeTestCase { diff --git a/lib/Cake/Test/Case/Core/ConfigureTest.php b/lib/Cake/Test/Case/Core/ConfigureTest.php index a0c321e1ace..744932dac87 100644 --- a/lib/Cake/Test/Case/Core/ConfigureTest.php +++ b/lib/Cake/Test/Case/Core/ConfigureTest.php @@ -69,6 +69,7 @@ public function tearDown() { /** * Test to ensure bootrapping doesn't overwrite prior configs set under 'App' key + * * @return void */ public function testBootstrap() { @@ -469,6 +470,8 @@ public function testClear() { } /** + * testDumpNoAdapter + * * @expectedException ConfigureException * @return void */ diff --git a/lib/Cake/Test/Case/Core/ObjectTest.php b/lib/Cake/Test/Case/Core/ObjectTest.php index c44291a3f7d..1556baa8949 100644 --- a/lib/Cake/Test/Case/Core/ObjectTest.php +++ b/lib/Cake/Test/Case/Core/ObjectTest.php @@ -73,7 +73,7 @@ public function another_ra_test($id, $other) { /** * normal_request_action method * - * @return void + * @return string Hello World! */ public function normal_request_action() { return 'Hello World'; @@ -82,7 +82,7 @@ public function normal_request_action() { /** * returns $this->here * - * @return void + * @return string $this->here. */ public function return_here() { return $this->here; @@ -91,7 +91,7 @@ public function return_here() { /** * paginate_request_action method * - * @return void + * @return true */ public function paginate_request_action() { $this->paginate(); @@ -251,8 +251,9 @@ public function methodWithOptionalParam($param = null) { } /** - * undocumented function + * Set properties. * + * @param array $properties The $properties. * @return void */ public function set($properties = array()) { diff --git a/lib/Cake/Test/Case/Event/CakeEventManagerTest.php b/lib/Cake/Test/Case/Event/CakeEventManagerTest.php index 5eb8d3a2cae..db16e6b7fb5 100644 --- a/lib/Cake/Test/Case/Event/CakeEventManagerTest.php +++ b/lib/Cake/Test/Case/Event/CakeEventManagerTest.php @@ -88,7 +88,6 @@ public function thirdListenerFunction() { /** * Tests the CakeEventManager class functionality - * */ class CakeEventManagerTest extends CakeTestCase { diff --git a/lib/Cake/Test/Case/Event/CakeEventTest.php b/lib/Cake/Test/Case/Event/CakeEventTest.php index 9ba28d3a909..3bb4771f917 100644 --- a/lib/Cake/Test/Case/Event/CakeEventTest.php +++ b/lib/Cake/Test/Case/Event/CakeEventTest.php @@ -22,7 +22,6 @@ /** * Tests the CakeEvent class functionality - * */ class CakeEventTest extends CakeTestCase { diff --git a/lib/Cake/Test/Case/Model/AclNodeTest.php b/lib/Cake/Test/Case/Model/AclNodeTest.php index 391ccd79b7a..ca40243e6e8 100644 --- a/lib/Cake/Test/Case/Model/AclNodeTest.php +++ b/lib/Cake/Test/Case/Model/AclNodeTest.php @@ -181,8 +181,7 @@ public function bindNode($ref = null) { class TestDbAcl extends DbAcl { /** - * construct method - * + * Constructor */ public function __construct() { $this->Aro = new DbAroTest(); diff --git a/lib/Cake/Test/Case/Model/models.php b/lib/Cake/Test/Case/Model/models.php index 33a0cda2118..ea8d36426db 100644 --- a/lib/Cake/Test/Case/Model/models.php +++ b/lib/Cake/Test/Case/Model/models.php @@ -4781,7 +4781,6 @@ public function schema($field = false) { /** * Test model for datasource prefixes - * */ class PrefixTestModel extends CakeTestModel { } diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index 2dfdfea4eb8..b588565a5ef 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -318,12 +318,6 @@ public function testPutParsing() { $request->reConstruct(); $this->assertEquals($data, $request->data); - $data = array( - 'data' => array( - 'Article' => array('title' => 'Testing'), - ), - 'action' => 'update' - ); $request = $this->getMock('TestCakeRequest', array('_readInput')); $request->expects($this->at(0))->method('_readInput') ->will($this->returnValue('data[Article][title]=Testing&action=update')); @@ -2261,7 +2255,7 @@ public function testAcceptLanguage() { // Checking if requested $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'es_mx,en_ca'; - $result = CakeRequest::acceptLanguage(); + CakeRequest::acceptLanguage(); $result = CakeRequest::acceptLanguage('en-ca'); $this->assertTrue($result); diff --git a/lib/Cake/Test/Case/Network/CakeResponseTest.php b/lib/Cake/Test/Case/Network/CakeResponseTest.php index 6abe8c97b22..cbbe1c7c691 100644 --- a/lib/Cake/Test/Case/Network/CakeResponseTest.php +++ b/lib/Cake/Test/Case/Network/CakeResponseTest.php @@ -566,7 +566,7 @@ public function testSendContentLength() { $response->send(); ob_start(); - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); $goofyOutput = 'I am goofily sending output in the controller'; echo $goofyOutput; $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); @@ -1746,7 +1746,7 @@ public function testFileRangeInvalid() { ); $this->assertEquals(416, $response->statusCode()); - $result = $response->send(); + $response->send(); } /** @@ -1787,7 +1787,7 @@ public function testFileRangeOffsetsNoDownload($range, $length, $offsetResponse) ); ob_start(); - $result = $response->send(); + $response->send(); ob_get_clean(); } @@ -1876,7 +1876,7 @@ public function testFileRangeInvalidNoDownload() { ); $this->assertEquals(416, $response->statusCode()); - $result = $response->send(); + $response->send(); } /** diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index 3be1a7f95ae..a86412ce66f 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -21,7 +21,6 @@ /** * Help to test CakeEmail - * */ class TestCakeEmail extends CakeEmail { @@ -36,7 +35,6 @@ class TestCakeEmail extends CakeEmail { /** * Config - * */ protected $_config = array(); @@ -89,7 +87,6 @@ public function render($content) { /** * EmailConfig class - * */ class TestEmailConfig { @@ -135,7 +132,6 @@ class TestEmailConfig { /** * ExtendTransport class * test class to ensure the class has send() method - * */ class ExtendTransport { @@ -217,7 +213,7 @@ public function testFrom() { $this->assertSame($this->CakeEmail, $result); $this->setExpectedException('SocketException'); - $result = $this->CakeEmail->from(array('cake@cakephp.org' => 'CakePHP', 'fail@cakephp.org' => 'From can only be one address')); + $this->CakeEmail->from(array('cake@cakephp.org' => 'CakePHP', 'fail@cakephp.org' => 'From can only be one address')); } /** @@ -866,7 +862,7 @@ public function testTransport() { $this->setExpectedException('SocketException'); $this->CakeEmail->transport('Invalid'); - $result = $this->CakeEmail->transportClass(); + $this->CakeEmail->transportClass(); } /** @@ -955,7 +951,7 @@ public function testConfigMerge() { $this->assertEquals($expected, $this->CakeEmail->transportClass()->config()); $this->CakeEmail->config(array('log' => true)); - $result = $this->CakeEmail->transportClass()->config(); + $this->CakeEmail->transportClass()->config(); $expected += array('log' => true); $this->assertEquals($expected, $this->CakeEmail->transportClass()->config()); @@ -2028,7 +2024,7 @@ public function testEmailFormat() { $this->assertEquals('html', $result); $this->setExpectedException('SocketException'); - $result = $this->CakeEmail->emailFormat('invalid'); + $this->CakeEmail->emailFormat('invalid'); } /** @@ -2385,7 +2381,6 @@ public function testWrapWithTagsAcrossLines() { style="font-weight: bold">The tag is across multiple lines HTML; - $length = strlen($str); $message = $str . str_repeat('x', CakeEmail::LINE_LENGTH_MUST + 1); $this->CakeEmail->reset(); diff --git a/lib/Cake/Test/Case/Network/Email/DebugTransportTest.php b/lib/Cake/Test/Case/Network/Email/DebugTransportTest.php index ca5653b49c1..9c6061c3645 100644 --- a/lib/Cake/Test/Case/Network/Email/DebugTransportTest.php +++ b/lib/Cake/Test/Case/Network/Email/DebugTransportTest.php @@ -22,7 +22,6 @@ /** * Test case - * */ class DebugTransportTest extends CakeTestCase { diff --git a/lib/Cake/Test/Case/Network/Email/MailTransportTest.php b/lib/Cake/Test/Case/Network/Email/MailTransportTest.php index bccc95439db..dde5eaa9010 100644 --- a/lib/Cake/Test/Case/Network/Email/MailTransportTest.php +++ b/lib/Cake/Test/Case/Network/Email/MailTransportTest.php @@ -22,7 +22,6 @@ /** * Test case - * */ class MailTransportTest extends CakeTestCase { diff --git a/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php b/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php index 7c4076439e6..478de6b98ac 100644 --- a/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php +++ b/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php @@ -22,14 +22,13 @@ /** * Help to test SmtpTransport - * */ class SmtpTestTransport extends SmtpTransport { /** * Helper to change the socket * - * @param object $socket + * @param CakeSocket $socket A socket. * @return void */ public function setSocket(CakeSocket $socket) { @@ -39,7 +38,7 @@ public function setSocket(CakeSocket $socket) { /** * Helper to change the CakeEmail * - * @param object $cakeEmail + * @param object $cakeEmail An email object. * @return void */ public function setCakeEmail($cakeEmail) { @@ -57,8 +56,8 @@ protected function _generateSocket() { /** * Magic function to call protected methods * - * @param string $method - * @param string $args + * @param string $method The method to call. + * @param string $args The arguments. * @return mixed */ public function __call($method, $args) { @@ -70,7 +69,6 @@ public function __call($method, $args) { /** * Test case - * */ class SmtpTransportTest extends CakeTestCase { diff --git a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php index 6ff788348bb..318e43401fa 100644 --- a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php +++ b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php @@ -29,8 +29,8 @@ class TestAuthentication { /** * authentication method * - * @param HttpSocket $http - * @param array $authInfo + * @param HttpSocket $http A HTTP socket. + * @param array &$authInfo Some auth info. * @return void */ public static function authentication(HttpSocket $http, &$authInfo) { @@ -40,8 +40,8 @@ public static function authentication(HttpSocket $http, &$authInfo) { /** * proxyAuthentication method * - * @param HttpSocket $http - * @param array $proxyInfo + * @param HttpSocket $http A HTTP socket. + * @param array &$proxyInfo Some proxy info. * @return void */ public static function proxyAuthentication(HttpSocket $http, &$proxyInfo) { @@ -52,7 +52,6 @@ public static function proxyAuthentication(HttpSocket $http, &$proxyInfo) { /** * CustomResponse - * */ class CustomResponse { @@ -66,6 +65,7 @@ class CustomResponse { /** * Constructor * + * @param string $message A message. */ public function __construct($message) { $this->first10 = substr($message, 0, 10); @@ -75,7 +75,6 @@ public function __construct($message) { /** * TestHttpSocket - * */ class TestHttpSocket extends HttpSocket { @@ -135,7 +134,6 @@ public function parseQuery($query) { * Convenience method for testing protected method * * @param array $request Needs to contain a 'uri' key. Should also contain a 'method' key, otherwise defaults to GET. - * @param string $versionToken The version token to use, defaults to HTTP/1.1 * @return string Request line */ public function buildRequestLine($request = array()) { @@ -583,7 +581,7 @@ public function testRequest() { $this->Socket->reset(); $request = array('method' => 'POST', 'uri' => 'http://www.cakephp.org/posts/add', 'body' => array('name' => 'HttpSocket-is-released', 'date' => 'today')); - $response = $this->Socket->request($request); + $this->Socket->request($request); $this->assertEquals("name=HttpSocket-is-released&date=today", $this->Socket->request['body']); } diff --git a/lib/Cake/Test/Case/Routing/Filter/AssetDispatcherTest.php b/lib/Cake/Test/Case/Routing/Filter/AssetDispatcherTest.php index e9e5b5ddd87..c67cba3846e 100644 --- a/lib/Cake/Test/Case/Routing/Filter/AssetDispatcherTest.php +++ b/lib/Cake/Test/Case/Routing/Filter/AssetDispatcherTest.php @@ -258,7 +258,6 @@ public function testAssetContentLength() { $file = file_get_contents($path); $this->assertEquals($file, $result); - $expected = filesize($path); $headers = $response->header(); $this->assertFalse($headers['Content-Length']); } diff --git a/lib/Cake/Test/Case/Routing/Route/RedirectRouteTest.php b/lib/Cake/Test/Case/Routing/Route/RedirectRouteTest.php index fe3b41ab888..4eb65404750 100644 --- a/lib/Cake/Test/Case/Routing/Route/RedirectRouteTest.php +++ b/lib/Cake/Test/Case/Routing/Route/RedirectRouteTest.php @@ -47,14 +47,14 @@ public function testParsing() { $route = new RedirectRoute('/home', array('controller' => 'posts')); $route->stop = false; $route->response = $this->getMock('CakeResponse', array('_sendHeader')); - $result = $route->parse('/home'); + $route->parse('/home'); $header = $route->response->header(); $this->assertEquals(Router::url('/posts', true), $header['Location']); $route = new RedirectRoute('/home', array('controller' => 'posts', 'action' => 'index')); $route->stop = false; $route->response = $this->getMock('CakeResponse', array('_sendHeader')); - $result = $route->parse('/home'); + $route->parse('/home'); $header = $route->response->header(); $this->assertEquals(Router::url('/posts', true), $header['Location']); $this->assertEquals(301, $route->response->statusCode()); @@ -62,14 +62,14 @@ public function testParsing() { $route = new RedirectRoute('/google', 'http://google.com'); $route->stop = false; $route->response = $this->getMock('CakeResponse', array('_sendHeader')); - $result = $route->parse('/google'); + $route->parse('/google'); $header = $route->response->header(); $this->assertEquals('http://google.com', $header['Location']); $route = new RedirectRoute('/posts/*', array('controller' => 'posts', 'action' => 'view'), array('status' => 302)); $route->stop = false; $route->response = $this->getMock('CakeResponse', array('_sendHeader')); - $result = $route->parse('/posts/2'); + $route->parse('/posts/2'); $header = $route->response->header(); $this->assertEquals(Router::url('/posts/view', true), $header['Location']); $this->assertEquals(302, $route->response->statusCode()); @@ -77,35 +77,35 @@ public function testParsing() { $route = new RedirectRoute('/posts/*', array('controller' => 'posts', 'action' => 'view'), array('persist' => true)); $route->stop = false; $route->response = $this->getMock('CakeResponse', array('_sendHeader')); - $result = $route->parse('/posts/2'); + $route->parse('/posts/2'); $header = $route->response->header(); $this->assertEquals(Router::url('/posts/view/2', true), $header['Location']); $route = new RedirectRoute('/posts/*', '/test', array('persist' => true)); $route->stop = false; $route->response = $this->getMock('CakeResponse', array('_sendHeader')); - $result = $route->parse('/posts/2'); + $route->parse('/posts/2'); $header = $route->response->header(); $this->assertEquals(Router::url('/test', true), $header['Location']); $route = new RedirectRoute('/my_controllers/:action/*', array('controller' => 'tags', 'action' => 'add'), array('persist' => true)); $route->stop = false; $route->response = $this->getMock('CakeResponse', array('_sendHeader')); - $result = $route->parse('/my_controllers/do_something/passme/named:param'); + $route->parse('/my_controllers/do_something/passme/named:param'); $header = $route->response->header(); $this->assertEquals(Router::url('/tags/add/passme/named:param', true), $header['Location']); $route = new RedirectRoute('/my_controllers/:action/*', array('controller' => 'tags', 'action' => 'add')); $route->stop = false; $route->response = $this->getMock('CakeResponse', array('_sendHeader')); - $result = $route->parse('/my_controllers/do_something/passme/named:param'); + $route->parse('/my_controllers/do_something/passme/named:param'); $header = $route->response->header(); $this->assertEquals(Router::url('/tags/add', true), $header['Location']); $route = new RedirectRoute('/:lang/my_controllers', array('controller' => 'tags', 'action' => 'add'), array('lang' => '(nl|en)', 'persist' => array('lang'))); $route->stop = false; $route->response = $this->getMock('CakeResponse', array('_sendHeader')); - $result = $route->parse('/nl/my_controllers/'); + $route->parse('/nl/my_controllers/'); $header = $route->response->header(); $this->assertEquals(Router::url('/tags/add/lang:nl', true), $header['Location']); @@ -114,7 +114,7 @@ public function testParsing() { $route = new RedirectRoute('/:lang/my_controllers', array('controller' => 'tags', 'action' => 'add'), array('lang' => '(nl|en)', 'persist' => array('lang'))); $route->stop = false; $route->response = $this->getMock('CakeResponse', array('_sendHeader')); - $result = $route->parse('/nl/my_controllers/'); + $route->parse('/nl/my_controllers/'); $header = $route->response->header(); $this->assertEquals(Router::url('/nl/preferred_controllers', true), $header['Location']); } diff --git a/lib/Cake/Test/Case/Routing/RouterTest.php b/lib/Cake/Test/Case/Routing/RouterTest.php index 0a78cdedc3d..20d493bfe38 100644 --- a/lib/Cake/Test/Case/Routing/RouterTest.php +++ b/lib/Cake/Test/Case/Routing/RouterTest.php @@ -201,7 +201,7 @@ public function testMapResourcesConnectOptions() { )); CakePlugin::load('TestPlugin'); App::uses('TestRoute', 'TestPlugin.Routing/Route'); - $resources = Router::mapResources('Posts', array( + Router::mapResources('Posts', array( 'connectOptions' => array( 'routeClass' => 'TestPlugin.TestRoute', 'foo' => '^(bar)$', @@ -238,7 +238,7 @@ public function testPluginMapResourcesWithPrefix() { $this->assertEquals($expected, $result); $this->assertEquals(array('test_plugin'), $resources); - $resources = Router::mapResources('Posts', array('prefix' => 'api')); + Router::mapResources('Posts', array('prefix' => 'api')); $_SERVER['REQUEST_METHOD'] = 'GET'; $result = Router::parse('/api/posts'); @@ -1579,7 +1579,7 @@ public function testNamedArgsUrlGeneration() { $request->base = '/'; Router::setRequestInfo($request); - $result = Router::parse('/admin/controller/index/type:whatever'); + Router::parse('/admin/controller/index/type:whatever'); $result = Router::url(array('type' => 'new')); $expected = "/admin/controller/index/type:new"; $this->assertEquals($expected, $result); diff --git a/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php b/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php index d5cee102e06..f9a677a9c01 100644 --- a/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php +++ b/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php @@ -327,7 +327,7 @@ public function testAssertTextEquals() { */ public function testAssertTextStartsWith() { $stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!"; - $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; + // $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; $this->assertStringStartsWith("some\nstring", $stringDirty); $this->assertStringStartsNotWith("some\r\nstring\r\nwith", $stringDirty); @@ -344,7 +344,7 @@ public function testAssertTextStartsWith() { */ public function testAssertTextStartsNotWith() { $stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!"; - $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; + // $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; $this->assertTextStartsNotWith("some\nstring\nwithout", $stringDirty); } @@ -356,7 +356,7 @@ public function testAssertTextStartsNotWith() { */ public function testAssertTextEndsWith() { $stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!"; - $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; + // $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; $this->assertTextEndsWith("string\nwith\r\ndifferent\rline endings!", $stringDirty); $this->assertTextEndsWith("string\r\nwith\ndifferent\nline endings!", $stringDirty); @@ -369,7 +369,7 @@ public function testAssertTextEndsWith() { */ public function testAssertTextEndsNotWith() { $stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!"; - $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; + // $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; $this->assertStringEndsNotWith("different\nline endings", $stringDirty); $this->assertTextEndsNotWith("different\rline endings", $stringDirty); @@ -382,7 +382,7 @@ public function testAssertTextEndsNotWith() { */ public function testAssertTextContains() { $stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!"; - $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; + // $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; $this->assertContains("different", $stringDirty); $this->assertNotContains("different\rline", $stringDirty); @@ -397,7 +397,7 @@ public function testAssertTextContains() { */ public function testAssertTextNotContains() { $stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!"; - $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; + // $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; $this->assertTextNotContains("different\rlines", $stringDirty); } @@ -460,7 +460,7 @@ public function testGetMockForModelWithPlugin() { ), App::RESET); CakePlugin::load('TestPlugin'); $this->getMockForModel('TestPlugin.TestPluginAppModel'); - $TestPluginComment = $this->getMockForModel('TestPlugin.TestPluginComment'); + $this->getMockForModel('TestPlugin.TestPluginComment'); $result = ClassRegistry::init('TestPlugin.TestPluginComment'); $this->assertInstanceOf('TestPluginComment', $result); diff --git a/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php b/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php index 1a04dae0f5f..b50e219262b 100644 --- a/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php +++ b/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php @@ -534,7 +534,7 @@ public function testInsertStrings() { */ public function testInsertInvalid() { $Fixture = new InvalidTestFixture(); - $return = $Fixture->insert($this->criticDb); + $Fixture->insert($this->criticDb); } /** diff --git a/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php b/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php index bade7e034ef..efd8878d842 100644 --- a/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php +++ b/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php @@ -276,7 +276,7 @@ public function testGenerateWithPlugin() { * @return void */ public function testTestAction() { - $Controller = $this->Case->generate('TestsApps'); + $this->Case->generate('TestsApps'); $this->Case->testAction('/tests_apps/index'); $this->assertInternalType('array', $this->Case->controller->viewVars); @@ -306,7 +306,7 @@ public function testTestAction() { * @return void */ public function testTestActionArrayUrls() { - $Controller = $this->Case->generate('TestsApps'); + $this->Case->generate('TestsApps'); $this->Case->testAction(array('controller' => 'tests_apps', 'action' => 'index')); $this->assertInternalType('array', $this->Case->controller->viewVars); } @@ -452,7 +452,7 @@ public function testTestActionPostData() { public function testTestActionGetData() { $this->Case->autoMock = true; - $result = $this->Case->testAction('/tests_apps_posts/url_var', array( + $this->Case->testAction('/tests_apps_posts/url_var', array( 'method' => 'get', 'data' => array( 'some' => 'var', @@ -474,7 +474,7 @@ public function testTestActionGetData() { )); $this->assertEquals(array('gogo', 'val2'), $result['params']['pass']); - $result = $this->Case->testAction('/tests_apps_posts/url_var', array( + $this->Case->testAction('/tests_apps_posts/url_var', array( 'return' => 'vars', 'method' => 'get', 'data' => array( diff --git a/lib/Cake/Test/Case/Utility/FolderTest.php b/lib/Cake/Test/Case/Utility/FolderTest.php index 67ab0cce990..55292281803 100644 --- a/lib/Cake/Test/Case/Utility/FolderTest.php +++ b/lib/Cake/Test/Case/Utility/FolderTest.php @@ -1026,7 +1026,7 @@ public function testCopyWithOverwrite() { extract($this->_setupFilesystem()); $Folder = new Folder($folderOne); - $result = $Folder->copy(array('to' => $folderThree, 'scheme' => Folder::OVERWRITE)); + $Folder->copy(array('to' => $folderThree, 'scheme' => Folder::OVERWRITE)); $this->assertTrue(file_exists($folderThree . DS . 'file1.php')); $this->assertTrue(file_exists($folderThree . DS . 'folderA' . DS . 'fileA.php')); diff --git a/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php b/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php index 4d768d0d866..7d2eade79d4 100644 --- a/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php +++ b/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php @@ -27,8 +27,8 @@ class GenericObject { /** * Constructor * - * @param GenericObjectCollection $collection - * @param array $settings + * @param GenericObjectCollection $collection A collection. + * @param array $settings Settings. */ public function __construct(GenericObjectCollection $collection, $settings = array()) { $this->_Collection = $collection; diff --git a/lib/Cake/Test/Case/Utility/SanitizeTest.php b/lib/Cake/Test/Case/Utility/SanitizeTest.php index 524e8ab4905..b6112c124a7 100644 --- a/lib/Cake/Test/Case/Utility/SanitizeTest.php +++ b/lib/Cake/Test/Case/Utility/SanitizeTest.php @@ -154,7 +154,7 @@ public function testClean() { $string = ''; $expected = ''; $result = Sanitize::clean($string, array('connection' => 'test')); - $this->assertEquals($expected, $string); + $this->assertEquals($expected, $result); $data = array( 'Grant' => array( diff --git a/lib/Cake/Test/Case/Utility/SecurityTest.php b/lib/Cake/Test/Case/Utility/SecurityTest.php index bc81aecfe67..90ea96c86dd 100644 --- a/lib/Cake/Test/Case/Utility/SecurityTest.php +++ b/lib/Cake/Test/Case/Utility/SecurityTest.php @@ -324,7 +324,7 @@ public function testEncryptDecrypt() { public function testDecryptKeyFailure() { $txt = 'The quick brown fox'; $key = 'This key is longer than 32 bytes long.'; - $result = Security::encrypt($txt, $key); + Security::encrypt($txt, $key); $key = 'Not the same key. This one will fail'; $this->assertFalse(Security::decrypt($txt, $key), 'Modified key will fail.'); diff --git a/lib/Cake/Test/Case/Utility/SetTest.php b/lib/Cake/Test/Case/Utility/SetTest.php index f55afd1069d..6097191db6b 100644 --- a/lib/Cake/Test/Case/Utility/SetTest.php +++ b/lib/Cake/Test/Case/Utility/SetTest.php @@ -2763,7 +2763,6 @@ public function testPushDiff() { /** * testSetApply method * @return void - * */ public function testApply() { $data = array( diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index f501e4f6b81..7c5dca57601 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -28,7 +28,7 @@ class CustomValidator { /** * Makes sure that a given $email address is valid and unique * - * @param string $email + * @param string $check Email to check. * @return bool */ public static function customValidate($check) { diff --git a/lib/Cake/Test/Case/Utility/XmlTest.php b/lib/Cake/Test/Case/Utility/XmlTest.php index 614a22a0544..5cb62d0f879 100644 --- a/lib/Cake/Test/Case/Utility/XmlTest.php +++ b/lib/Cake/Test/Case/Utility/XmlTest.php @@ -175,7 +175,7 @@ public function testBuild() { */ public function testBuildFromFileWhenDisabled() { $xml = CAKE . 'Test' . DS . 'Fixture' . DS . 'sample.xml'; - $obj = Xml::build($xml, array('readFile' => false)); + Xml::build($xml, array('readFile' => false)); } /** @@ -186,7 +186,7 @@ public function testBuildFromFileWhenDisabled() { */ public function testBuildFromUrlWhenDisabled() { $xml = 'http://www.google.com'; - $obj = Xml::build($xml, array('readFile' => false)); + Xml::build($xml, array('readFile' => false)); } /** @@ -222,7 +222,7 @@ public function testBuildInvalidData($value) { */ public function testBuildInvalidDataSimpleXml() { $input = ' 'simplexml')); + Xml::build($input, array('return' => 'simplexml')); } /** diff --git a/lib/Cake/Test/bake_compare/Controller/Scaffold.ctp b/lib/Cake/Test/bake_compare/Controller/Scaffold.ctp index 325fdb9912e..757e0eabd94 100644 --- a/lib/Cake/Test/bake_compare/Controller/Scaffold.ctp +++ b/lib/Cake/Test/bake_compare/Controller/Scaffold.ctp @@ -2,7 +2,6 @@ App::uses('AppController', 'Controller'); /** * Articles Controller - * */ class ArticlesController extends AppController { diff --git a/lib/Cake/Test/test_app/Model/Datasource/Session/TestAppLibSession.php b/lib/Cake/Test/test_app/Model/Datasource/Session/TestAppLibSession.php index e7b5f9f308d..2ba874dba62 100644 --- a/lib/Cake/Test/test_app/Model/Datasource/Session/TestAppLibSession.php +++ b/lib/Cake/Test/test_app/Model/Datasource/Session/TestAppLibSession.php @@ -1,7 +1,6 @@ 0): echo $this->element('exception_stack_trace'); endif; -?> diff --git a/lib/Cake/Test/test_app/View/Elements/html_call.ctp b/lib/Cake/Test/test_app/View/Elements/html_call.ctp index 8c2c089786a..fb5122dd270 100644 --- a/lib/Cake/Test/test_app/View/Elements/html_call.ctp +++ b/lib/Cake/Test/test_app/View/Elements/html_call.ctp @@ -1,3 +1,2 @@ Html->link('Test', 'http://example.com'); -?> \ No newline at end of file +echo $this->Html->link('Test', 'http://example.com'); \ No newline at end of file diff --git a/lib/Cake/Test/test_app/View/Emails/html/default.ctp b/lib/Cake/Test/test_app/View/Emails/html/default.ctp index 5d6eabd09c5..538e907f50d 100644 --- a/lib/Cake/Test/test_app/View/Emails/html/default.ctp +++ b/lib/Cake/Test/test_app/View/Emails/html/default.ctp @@ -3,5 +3,4 @@ $content = explode("\n", $content); foreach ($content as $line): echo '

    ' . $line . '

    '; -endforeach; -?> \ No newline at end of file +endforeach; \ No newline at end of file diff --git a/lib/Cake/Test/test_app/View/Layouts/ajax2.ctp b/lib/Cake/Test/test_app/View/Layouts/ajax2.ctp index 43331599001..25c20f425ca 100644 --- a/lib/Cake/Test/test_app/View/Layouts/ajax2.ctp +++ b/lib/Cake/Test/test_app/View/Layouts/ajax2.ctp @@ -1,2 +1,3 @@ Ajax! -fetch('content'); ?> \ No newline at end of file +fetch('content'); \ No newline at end of file diff --git a/lib/Cake/Test/test_app/View/Layouts/rss/default.ctp b/lib/Cake/Test/test_app/View/Layouts/rss/default.ctp index df2f0ab19b8..f0af9c0d842 100644 --- a/lib/Cake/Test/test_app/View/Layouts/rss/default.ctp +++ b/lib/Cake/Test/test_app/View/Layouts/rss/default.ctp @@ -12,6 +12,4 @@ echo $this->Rss->document( $this->Rss->channel( array(), $channel, $this->fetch('content') ) -); - -?> \ No newline at end of file +); \ No newline at end of file diff --git a/lib/Cake/Test/test_app/View/Posts/helper_overwrite.ctp b/lib/Cake/Test/test_app/View/Posts/helper_overwrite.ctp index 100c5f51bb1..610d33ad907 100644 --- a/lib/Cake/Test/test_app/View/Posts/helper_overwrite.ctp +++ b/lib/Cake/Test/test_app/View/Posts/helper_overwrite.ctp @@ -1,4 +1,3 @@ Html->link('Test link', '#'); -?> \ No newline at end of file +echo $this->Html->link('Test link', '#'); \ No newline at end of file diff --git a/lib/Cake/Test/test_app/View/Posts/parent_view.ctp b/lib/Cake/Test/test_app/View/Posts/parent_view.ctp index e338b784f28..ee468954414 100644 --- a/lib/Cake/Test/test_app/View/Posts/parent_view.ctp +++ b/lib/Cake/Test/test_app/View/Posts/parent_view.ctp @@ -1,2 +1,2 @@ Parent View. -fetch('content') ?> +fetch('content'); ?> diff --git a/lib/Cake/Test/test_app/View/Posts/test_nocache_tags.ctp b/lib/Cake/Test/test_app/View/Posts/test_nocache_tags.ctp index c0b2ac283ab..19a88e33919 100644 --- a/lib/Cake/Test/test_app/View/Posts/test_nocache_tags.ctp +++ b/lib/Cake/Test/test_app/View/Posts/test_nocache_tags.ctp @@ -47,7 +47,7 @@ Html->image('test.jpg') ?> \ No newline at end of file +Html->image('test.jpg'); ?> \ No newline at end of file diff --git a/lib/Cake/Test/test_app/View/Themed/TestTheme/Layouts/default.ctp b/lib/Cake/Test/test_app/View/Themed/TestTheme/Layouts/default.ctp index 9f2aa062d63..d4e3dd5868f 100644 --- a/lib/Cake/Test/test_app/View/Themed/TestTheme/Layouts/default.ctp +++ b/lib/Cake/Test/test_app/View/Themed/TestTheme/Layouts/default.ctp @@ -1,2 +1,2 @@ default test_theme layout -fetch('content') ?> +fetch('content'); ?> diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index bcecc45a373..c375717fe9a 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -643,9 +643,9 @@ protected function expectError($expected = false, $message = '') { /** * Compatibility wrapper function for setExpectedException * - * @param mixed $expected the name of the Exception + * @param mixed $name The name of the expected Exception. * @param string $message the text to display if the assertion is not correct - * @deprecated 3.0.0 This is a compatiblity wrapper for 1.x. It will be removed in 3.0 + * @deprecated 3.0.0 This is a compatibility wrapper for 1.x. It will be removed in 3.0. * @return void */ protected function expectException($name = 'Exception', $message = '') { diff --git a/lib/Cake/TestSuite/CakeTestLoader.php b/lib/Cake/TestSuite/CakeTestLoader.php index c1fa85f106e..3fe681bde87 100644 --- a/lib/Cake/TestSuite/CakeTestLoader.php +++ b/lib/Cake/TestSuite/CakeTestLoader.php @@ -42,9 +42,9 @@ public function load($filePath, $params = '') { /** * Convert path fragments used by CakePHP's test runner to absolute paths that can be fed to PHPUnit. * - * @param string $filePath The file path to load - * @param string $params Additional parameters - * @return void + * @param string $filePath The file path to load. + * @param string $params Additional parameters. + * @return string Converted path fragments. */ protected function _resolveTestFile($filePath, $params) { $basePath = $this->_basePath($params) . DS . $filePath; diff --git a/lib/Cake/TestSuite/ControllerTestCase.php b/lib/Cake/TestSuite/ControllerTestCase.php index 17620ae0882..03d78011a3b 100644 --- a/lib/Cake/TestSuite/ControllerTestCase.php +++ b/lib/Cake/TestSuite/ControllerTestCase.php @@ -258,7 +258,7 @@ protected function _testAction($url, $options = array()) { $Dispatch->parseParams(new CakeEvent('ControllerTestCase', $Dispatch, array('request' => $request))); if (!isset($request->params['controller']) && Router::currentRoute()) { $this->headers = Router::currentRoute()->response->header(); - return; + return null; } if ($this->_dirtyController) { $this->controller = null; diff --git a/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php b/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php index 3e68005f3a8..d877d556f8d 100644 --- a/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php +++ b/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php @@ -58,7 +58,7 @@ public function sendContentType() { */ public function paintDocumentStart() { ob_start(); - $baseDir = $this->params['baseDir']; + $this->params['baseDir']; include CAKE . 'TestSuite' . DS . 'templates' . DS . 'header.php'; } @@ -69,7 +69,7 @@ public function paintDocumentStart() { * @return void */ public function paintTestMenu() { - $cases = $this->baseUrl() . '?show=cases'; + $this->baseUrl() . '?show=cases'; $plugins = App::objects('plugin', null, false); sort($plugins); include CAKE . 'TestSuite' . DS . 'templates' . DS . 'menu.php'; diff --git a/lib/Cake/TestSuite/templates/header.php b/lib/Cake/TestSuite/templates/header.php index 616bc179f73..60afa75595b 100644 --- a/lib/Cake/TestSuite/templates/header.php +++ b/lib/Cake/TestSuite/templates/header.php @@ -106,7 +106,7 @@ div.code-coverage-results span.line-num strong { color:#666; } div.code-coverage-results div.start { border:1px solid #aaa; - border-width:1px 1px 0px 1px; + border-width:1px 1px 0 1px; margin-top:30px; padding-top:5px; } From dbfd2c44e9b2f0bd5c5c2f9b08f9d0422eb82be6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Fri, 25 Sep 2015 17:25:35 +0200 Subject: [PATCH 320/336] App & skel folder sync + some improvements Mostly CS, doc blocks and some CSS --- app/Config/Schema/db_acl.php | 1 - app/Config/Schema/i18n.php | 10 ++++++ app/Config/Schema/sessions.php | 14 ++++++-- app/Config/acl.ini.php | 2 +- app/Config/bootstrap.php | 3 -- app/Config/core.php | 7 ++-- app/Config/database.php.default | 2 -- app/Config/email.php.default | 3 -- app/Config/routes.php | 1 + app/View/Elements/empty | 0 app/View/Layouts/rss/default.ctp | 1 - app/webroot/css/cake.generic.css | 33 +++++++++---------- app/webroot/index.php | 5 +-- app/webroot/test.php | 5 +-- .../Templates/skel/Config/Schema/db_acl.php | 4 +-- .../Templates/skel/Config/Schema/i18n.php | 21 ++++++++---- .../Templates/skel/Config/Schema/sessions.php | 22 +++++++++---- .../Templates/skel/Config/bootstrap.php | 3 -- .../Console/Templates/skel/Config/core.php | 4 --- .../skel/Config/database.php.default | 2 -- .../Templates/skel/Config/email.php.default | 1 - .../skel/View/Emails/html/default.ctp | 3 +- .../Templates/skel/View/Errors/error400.ctp | 1 - .../Templates/skel/View/Errors/error500.ctp | 1 - .../Templates/skel/View/Pages/home.ctp | 2 +- .../skel/webroot/css/cake.generic.css | 33 +++++++++---------- .../Console/Templates/skel/webroot/index.php | 3 -- .../Console/Templates/skel/webroot/test.php | 3 -- 28 files changed, 93 insertions(+), 97 deletions(-) delete mode 100644 app/View/Elements/empty diff --git a/app/Config/Schema/db_acl.php b/app/Config/Schema/db_acl.php index 967abbe139f..cb63df7c7c0 100644 --- a/app/Config/Schema/db_acl.php +++ b/app/Config/Schema/db_acl.php @@ -21,7 +21,6 @@ /** * Using the Schema command line utility * cake schema run create DbAcl - * */ class DbAclSchema extends CakeSchema { diff --git a/app/Config/Schema/i18n.php b/app/Config/Schema/i18n.php index 15a446b48d8..cd598b35e3d 100644 --- a/app/Config/Schema/i18n.php +++ b/app/Config/Schema/i18n.php @@ -27,6 +27,11 @@ */ class I18nSchema extends CakeSchema { +/** + * The name property + * + * @var string + */ public $name = 'i18n'; /** @@ -48,6 +53,11 @@ public function before($event = array()) { public function after($event = array()) { } +/** + * The i18n table definition + * + * @var array + */ public $i18n = array( 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'), 'locale' => array('type' => 'string', 'null' => false, 'length' => 6, 'key' => 'index'), diff --git a/app/Config/Schema/sessions.php b/app/Config/Schema/sessions.php index 27f76d0a04a..bd7b1efc343 100644 --- a/app/Config/Schema/sessions.php +++ b/app/Config/Schema/sessions.php @@ -18,14 +18,17 @@ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ -/* - * +/** * Using the Schema command line utility * cake schema run create Sessions - * */ class SessionsSchema extends CakeSchema { +/** + * Name property + * + * @var string + */ public $name = 'Sessions'; /** @@ -47,6 +50,11 @@ public function before($event = array()) { public function after($event = array()) { } +/** + * The cake_sessions table definition + * + * @var array + */ public $cake_sessions = array( 'id' => array('type' => 'string', 'null' => false, 'key' => 'primary'), 'data' => array('type' => 'text', 'null' => true, 'default' => null), diff --git a/app/Config/acl.ini.php b/app/Config/acl.ini.php index 9a4672132d2..5e6bfb6e0fc 100644 --- a/app/Config/acl.ini.php +++ b/app/Config/acl.ini.php @@ -15,7 +15,7 @@ ; * @license http://www.opensource.org/licenses/mit-license.php MIT License ; */ -; acl.ini.php - Cake ACL Configuration +; acl.ini.php - CakePHP ACL Configuration ; --------------------------------------------------------------------- ; Use this file to specify user permissions. ; aco = access control object (something in your application) diff --git a/app/Config/bootstrap.php b/app/Config/bootstrap.php index 8633326f0b2..03cda9cae71 100644 --- a/app/Config/bootstrap.php +++ b/app/Config/bootstrap.php @@ -48,7 +48,6 @@ * 'Vendor' => array('/path/to/vendors/', '/next/path/to/vendors/'), * 'Plugin' => array('/path/to/plugins/', '/next/path/to/plugins/'), * )); - * */ /** @@ -57,7 +56,6 @@ * * Inflector::rules('singular', array('rules' => array(), 'irregular' => array(), 'uninflected' => array())); * Inflector::rules('plural', array('rules' => array(), 'irregular' => array(), 'uninflected' => array())); - * */ /** @@ -67,7 +65,6 @@ * * CakePlugin::loadAll(); // Loads all plugins at once * CakePlugin::load('DebugKit'); //Loads a single plugin named DebugKit - * */ /** diff --git a/app/Config/core.php b/app/Config/core.php index d2e163418f2..a55347ce3ac 100644 --- a/app/Config/core.php +++ b/app/Config/core.php @@ -18,6 +18,9 @@ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ +//setLocale(LC_ALL, 'deu'); +//Configure::write('Config.language', 'deu'); + /** * CakePHP Debug Level: * @@ -147,13 +150,11 @@ * Enables: * `admin_index()` and `/admin/controller/index` * `manager_index()` and `/manager/controller/index` - * */ //Configure::write('Routing.prefixes', array('admin')); /** * Turn off all caching application-wide. - * */ //Configure::write('Cache.disable', true); @@ -164,7 +165,6 @@ * public $cacheAction inside your controllers to define caching settings. * You can either set it controller-wide by setting public $cacheAction = true, * or in each action using $this->cacheAction = true. - * */ //Configure::write('Cache.check', true); @@ -213,7 +213,6 @@ * * To use database sessions, run the app/Config/Schema/sessions.php schema using * the cake shell command: cake schema create Sessions - * */ Configure::write('Session', array( 'defaults' => 'php' diff --git a/app/Config/database.php.default b/app/Config/database.php.default index c8ee3088c72..ebd21d475d6 100644 --- a/app/Config/database.php.default +++ b/app/Config/database.php.default @@ -1,7 +1,5 @@ * The origin email. See CakeEmail::from() about the valid values - * */ class EmailConfig { diff --git a/app/Config/routes.php b/app/Config/routes.php index a2b963f44ed..07b57003286 100644 --- a/app/Config/routes.php +++ b/app/Config/routes.php @@ -19,6 +19,7 @@ * @since CakePHP(tm) v 0.2.9 * @license http://www.opensource.org/licenses/mit-license.php MIT License */ + /** * Here, we are connecting '/' (base path) to controller called 'Pages', * its action called 'display', and we pass a param to select the view file diff --git a/app/View/Elements/empty b/app/View/Elements/empty deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/app/View/Layouts/rss/default.ctp b/app/View/Layouts/rss/default.ctp index 0ada29463d6..60a53659f44 100644 --- a/app/View/Layouts/rss/default.ctp +++ b/app/View/Layouts/rss/default.ctp @@ -11,4 +11,3 @@ echo $this->Rss->document( array(), $channel, $this->fetch('content') ) ); -?> diff --git a/app/webroot/css/cake.generic.css b/app/webroot/css/cake.generic.css index 39e0e7a541b..be3e40ae303 100644 --- a/app/webroot/css/cake.generic.css +++ b/app/webroot/css/cake.generic.css @@ -1,6 +1,5 @@ @charset "utf-8"; /** - * * Generic CSS for CakePHP * * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) @@ -84,7 +83,7 @@ p { line-height:20px; background: #003d4c url('../img/cake.icon.png') no-repeat left; color: #fff; - padding: 0px 30px; + padding: 0 30px; } #header h1 a { color: #fff; @@ -174,7 +173,7 @@ td.actions { white-space: nowrap; } table td.actions a { - margin: 0px 6px; + margin: 0 6px; padding:2px 5px; } @@ -336,7 +335,7 @@ option { input[type=checkbox] { clear: left; float: left; - margin: 0px 6px 7px 2px; + margin: 0 6px 7px 2px; width: auto; } div.checkbox label { @@ -365,7 +364,7 @@ form .submit input[type=submit] { background-image: -moz-linear-gradient(top, #76BF6B, #3B8230); border-color: #2d6324; color: #fff; - text-shadow: rgba(0, 0, 0, 0.5) 0px -1px 0px; + text-shadow: rgba(0, 0, 0, 0.5) 0 -1px 0; padding: 8px 10px; } form .submit input[type=submit]:hover { @@ -527,11 +526,11 @@ input[type=submit], -moz-border-radius: 4px; border-radius: 4px; text-decoration: none; - text-shadow: #fff 0px 1px 0px; + text-shadow: #fff 0 1px 0; min-width: 0; - -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0px 1px 1px rgba(0, 0, 0, 0.2); - -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0px 1px 1px rgba(0, 0, 0, 0.2); - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0px 1px 1px rgba(0, 0, 0, 0.2); + -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 1px rgba(0, 0, 0, 0.2); + -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 1px rgba(0, 0, 0, 0.2); + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 1px rgba(0, 0, 0, 0.2); -webkit-user-select: none; user-select: none; } @@ -551,7 +550,7 @@ input[type=submit]:active, background-image: -ms-linear-gradient(top, #dfdfdf, #eee); background-image: -o-linear-gradient(top, #dfdfdf, #eee); background-image: linear-gradient(top, #dfdfdf, #eee); - text-shadow: #eee 0px 1px 0px; + text-shadow: #eee 0 1px 0; -moz-box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.3); -webkit-box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.3); box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.3); @@ -627,15 +626,15 @@ pre { -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; - margin: 0px 4px 10px 2px; + margin: 0 4px 10px 2px; font-family: sans-serif; font-size: 14px; line-height: 14px; display: inline-block; text-decoration: none; - -moz-box-shadow: inset 0px 1px 0 rgba(0, 0, 0, 0.3); - -webkit-box-shadow: inset 0px 1px 0 rgba(0, 0, 0, 0.3); - box-shadow: inset 0px 1px 0 rgba(0, 0, 0, 0.3); + -moz-box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.3); + -webkit-box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.3); + box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.3); } .cake-code-dump pre { position: relative; @@ -647,13 +646,13 @@ pre { .cake-stack-trace pre { color: #000; background-color: #F0F0F0; - margin: 0px 0 10px 0; + margin: 0 0 10px 0; padding: 1em; overflow: auto; text-shadow: none; } .cake-stack-trace li { - padding: 10px 5px 0px; + padding: 10px 5px 0; margin: 0 0 4px 0; font-family: monospace; border: 1px solid #bbb; @@ -709,7 +708,7 @@ pre { } .code-coverage-results div.start { border:1px solid #aaa; - border-width:1px 1px 0px 1px; + border-width:1px 1px 0 1px; margin-top:30px; padding-top:5px; } diff --git a/app/webroot/index.php b/app/webroot/index.php index 6d4fa486b55..a6481b24a05 100644 --- a/app/webroot/index.php +++ b/app/webroot/index.php @@ -33,7 +33,6 @@ /** * The full path to the directory which holds "app", WITHOUT a trailing DS. - * */ if (!defined('ROOT')) { define('ROOT', dirname(dirname(dirname(__FILE__)))); @@ -41,7 +40,6 @@ /** * The actual directory name for the "app". - * */ if (!defined('APP_DIR')) { define('APP_DIR', basename(dirname(dirname(__FILE__)))); @@ -76,7 +74,6 @@ /** * Editing below this line should NOT be necessary. * Change at your own risk. - * */ if (!defined('WEBROOT_DIR')) { define('WEBROOT_DIR', basename(dirname(__FILE__))); @@ -86,7 +83,7 @@ } // for built-in server -if (php_sapi_name() === 'cli-server') { +if (PHP_SAPI === 'cli-server') { if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $_SERVER['PHP_SELF'])) { return false; } diff --git a/app/webroot/test.php b/app/webroot/test.php index 22f1cc1e3a5..a41f0af7447 100644 --- a/app/webroot/test.php +++ b/app/webroot/test.php @@ -34,7 +34,6 @@ /** * The full path to the directory which holds "app", WITHOUT a trailing DS. - * */ if (!defined('ROOT')) { define('ROOT', dirname(dirname(dirname(__FILE__)))); @@ -42,7 +41,6 @@ /** * The actual directory name for the "app". - * */ if (!defined('APP_DIR')) { define('APP_DIR', basename(dirname(dirname(__FILE__)))); @@ -74,7 +72,6 @@ /** * Editing below this line should not be necessary. * Change at your own risk. - * */ if (!defined('WEBROOT_DIR')) { define('WEBROOT_DIR', basename(dirname(__FILE__))); @@ -100,7 +97,7 @@ } if (Configure::read('debug') < 1) { - throw new NotFoundException(__d('cake_dev', 'Debug setting does not allow access to this url.')); + throw new NotFoundException(__d('cake_dev', 'Debug setting does not allow access to this URL.')); } require_once CAKE . 'TestSuite' . DS . 'CakeTestSuiteDispatcher.php'; diff --git a/lib/Cake/Console/Templates/skel/Config/Schema/db_acl.php b/lib/Cake/Console/Templates/skel/Config/Schema/db_acl.php index 6ab31d63376..9a4f54337ae 100644 --- a/lib/Cake/Console/Templates/skel/Config/Schema/db_acl.php +++ b/lib/Cake/Console/Templates/skel/Config/Schema/db_acl.php @@ -9,11 +9,9 @@ * @since CakePHP(tm) v 0.2.9 */ -/* - * +/** * Using the Schema command line utility * cake schema run create DbAcl - * */ class DbAclSchema extends CakeSchema { diff --git a/lib/Cake/Console/Templates/skel/Config/Schema/i18n.php b/lib/Cake/Console/Templates/skel/Config/Schema/i18n.php index 47414d77bae..cd598b35e3d 100644 --- a/lib/Cake/Console/Templates/skel/Config/Schema/i18n.php +++ b/lib/Cake/Console/Templates/skel/Config/Schema/i18n.php @@ -4,9 +4,18 @@ * * Use it to configure database for i18n * + * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) + * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * For full copyright and license information, please see the LICENSE.txt + * Redistributions of files must retain the above copyright notice. + * + * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project * @package app.Config.Schema * @since CakePHP(tm) v 0.2.9 + * @license http://www.opensource.org/licenses/mit-license.php MIT License */ /** @@ -26,26 +35,26 @@ class I18nSchema extends CakeSchema { public $name = 'i18n'; /** - * Before event. + * Before callback. * - * @param array $event The event data. - * @return bool success + * @param array $event Schema object properties + * @return bool Should process continue */ public function before($event = array()) { return true; } /** - * After event. + * After callback. * - * @param array $event The event data. + * @param array $event Schema object properties * @return void */ public function after($event = array()) { } /** - * The i18n table property + * The i18n table definition * * @var array */ diff --git a/lib/Cake/Console/Templates/skel/Config/Schema/sessions.php b/lib/Cake/Console/Templates/skel/Config/Schema/sessions.php index 8ae847b3a1b..bd7b1efc343 100644 --- a/lib/Cake/Console/Templates/skel/Config/Schema/sessions.php +++ b/lib/Cake/Console/Templates/skel/Config/Schema/sessions.php @@ -4,15 +4,23 @@ * * Use it to configure database for Sessions * + * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) + * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * For full copyright and license information, please see the LICENSE.txt + * Redistributions of files must retain the above copyright notice. + * + * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project * @package app.Config.Schema * @since CakePHP(tm) v 0.2.9 + * @license http://www.opensource.org/licenses/mit-license.php MIT License */ /** * Using the Schema command line utility * cake schema run create Sessions - * */ class SessionsSchema extends CakeSchema { @@ -24,26 +32,26 @@ class SessionsSchema extends CakeSchema { public $name = 'Sessions'; /** - * Before event. + * Before callback. * - * @param array $event The event data. - * @return bool Success + * @param array $event Schema object properties + * @return bool Should process continue */ public function before($event = array()) { return true; } /** - * After event. + * After callback. * - * @param array $event The event data. + * @param array $event Schema object properties * @return void */ public function after($event = array()) { } /** - * cake_sessions table definition + * The cake_sessions table definition * * @var array */ diff --git a/lib/Cake/Console/Templates/skel/Config/bootstrap.php b/lib/Cake/Console/Templates/skel/Config/bootstrap.php index 7fe55949c65..8b54c36ecca 100644 --- a/lib/Cake/Console/Templates/skel/Config/bootstrap.php +++ b/lib/Cake/Console/Templates/skel/Config/bootstrap.php @@ -39,7 +39,6 @@ * 'Vendor' => array('/path/to/vendors/', '/next/path/to/vendors/'), * 'Plugin' => array('/path/to/plugins/', '/next/path/to/plugins/'), * )); - * */ /** @@ -48,7 +47,6 @@ * * Inflector::rules('singular', array('rules' => array(), 'irregular' => array(), 'uninflected' => array())); * Inflector::rules('plural', array('rules' => array(), 'irregular' => array(), 'uninflected' => array())); - * */ /** @@ -58,7 +56,6 @@ * * CakePlugin::loadAll(); // Loads all plugins at once * CakePlugin::load('DebugKit'); //Loads a single plugin named DebugKit - * */ /** diff --git a/lib/Cake/Console/Templates/skel/Config/core.php b/lib/Cake/Console/Templates/skel/Config/core.php index 11d8f9042d9..18d645a33bc 100644 --- a/lib/Cake/Console/Templates/skel/Config/core.php +++ b/lib/Cake/Console/Templates/skel/Config/core.php @@ -138,13 +138,11 @@ * Enables: * `admin_index()` and `/admin/controller/index` * `manager_index()` and `/manager/controller/index` - * */ //Configure::write('Routing.prefixes', array('admin')); /** * Turn off all caching application-wide. - * */ //Configure::write('Cache.disable', true); @@ -155,7 +153,6 @@ * public $cacheAction inside your controllers to define caching settings. * You can either set it controller-wide by setting public $cacheAction = true, * or in each action using $this->cacheAction = true. - * */ //Configure::write('Cache.check', true); @@ -204,7 +201,6 @@ * * To use database sessions, run the app/Config/Schema/sessions.php schema using * the cake shell command: cake schema create Sessions - * */ Configure::write('Session', array( 'defaults' => 'php' diff --git a/lib/Cake/Console/Templates/skel/Config/database.php.default b/lib/Cake/Console/Templates/skel/Config/database.php.default index 00ad15507c4..cc549a5f62d 100644 --- a/lib/Cake/Console/Templates/skel/Config/database.php.default +++ b/lib/Cake/Console/Templates/skel/Config/database.php.default @@ -1,7 +1,5 @@ * The origin email. See CakeEmail::from() about the valid values - * */ class EmailConfig { diff --git a/lib/Cake/Console/Templates/skel/View/Emails/html/default.ctp b/lib/Cake/Console/Templates/skel/View/Emails/html/default.ctp index 63874c1ccee..a1333dc1900 100644 --- a/lib/Cake/Console/Templates/skel/View/Emails/html/default.ctp +++ b/lib/Cake/Console/Templates/skel/View/Emails/html/default.ctp @@ -19,5 +19,4 @@ $content = explode("\n", $content); foreach ($content as $line): echo '

    ' . $line . "

    \n"; -endforeach; -?> \ No newline at end of file +endforeach; \ No newline at end of file diff --git a/lib/Cake/Console/Templates/skel/View/Errors/error400.ctp b/lib/Cake/Console/Templates/skel/View/Errors/error400.ctp index 8e4ff3d0a98..6c84d88faf4 100644 --- a/lib/Cake/Console/Templates/skel/View/Errors/error400.ctp +++ b/lib/Cake/Console/Templates/skel/View/Errors/error400.ctp @@ -17,4 +17,3 @@ if (Configure::read('debug') > 0): echo $this->element('exception_stack_trace'); endif; -?> diff --git a/lib/Cake/Console/Templates/skel/View/Errors/error500.ctp b/lib/Cake/Console/Templates/skel/View/Errors/error500.ctp index c1d5ffb55c1..339e140dabc 100644 --- a/lib/Cake/Console/Templates/skel/View/Errors/error500.ctp +++ b/lib/Cake/Console/Templates/skel/View/Errors/error500.ctp @@ -14,4 +14,3 @@ if (Configure::read('debug') > 0): echo $this->element('exception_stack_trace'); endif; -?> diff --git a/lib/Cake/Console/Templates/skel/View/Pages/home.ctp b/lib/Cake/Console/Templates/skel/View/Pages/home.ctp index 0a028702e39..5bac4537f3f 100644 --- a/lib/Cake/Console/Templates/skel/View/Pages/home.ctp +++ b/lib/Cake/Console/Templates/skel/View/Pages/home.ctp @@ -62,7 +62,7 @@ endif; $settings = Cache::settings(); if (!empty($settings)): echo ''; - echo __d('cake_dev', 'The %s is being used for core caching. To change the config edit %s', ''. $settings['engine'] . 'Engine', 'APP/Config/core.php'); + echo __d('cake_dev', 'The %s is being used for core caching. To change the config edit %s', '' . $settings['engine'] . 'Engine', 'APP/Config/core.php'); echo ''; else: echo ''; diff --git a/lib/Cake/Console/Templates/skel/webroot/css/cake.generic.css b/lib/Cake/Console/Templates/skel/webroot/css/cake.generic.css index 9bdf5307aef..ddfda2b4bc1 100644 --- a/lib/Cake/Console/Templates/skel/webroot/css/cake.generic.css +++ b/lib/Cake/Console/Templates/skel/webroot/css/cake.generic.css @@ -1,6 +1,5 @@ @charset "utf-8"; /** - * * Generic CSS for CakePHP * * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) @@ -84,7 +83,7 @@ p { line-height:20px; background: #003d4c url('../img/cake.icon.png') no-repeat left; color: #fff; - padding: 0px 30px; + padding: 0 30px; } #header h1 a { color: #fff; @@ -172,7 +171,7 @@ td.actions { white-space: nowrap; } table td.actions a { - margin: 0px 6px; + margin: 0 6px; padding:2px 5px; } @@ -334,7 +333,7 @@ option { input[type=checkbox] { clear: left; float: left; - margin: 0px 6px 7px 2px; + margin: 0 6px 7px 2px; width: auto; } div.checkbox label { @@ -363,7 +362,7 @@ form .submit input[type=submit] { background-image: -moz-linear-gradient(top, #76BF6B, #3B8230); border-color: #2d6324; color: #fff; - text-shadow: rgba(0, 0, 0, 0.5) 0px -1px 0px; + text-shadow: rgba(0, 0, 0, 0.5) 0 -1px 0; padding: 8px 10px; } form .submit input[type=submit]:hover { @@ -525,11 +524,11 @@ input[type=submit], -moz-border-radius: 4px; border-radius: 4px; text-decoration: none; - text-shadow: #fff 0px 1px 0px; + text-shadow: #fff 0 1px 0; min-width: 0; - -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0px 1px 1px rgba(0, 0, 0, 0.2); - -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0px 1px 1px rgba(0, 0, 0, 0.2); - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0px 1px 1px rgba(0, 0, 0, 0.2); + -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 1px rgba(0, 0, 0, 0.2); + -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 1px rgba(0, 0, 0, 0.2); + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 1px rgba(0, 0, 0, 0.2); -webkit-user-select: none; user-select: none; } @@ -549,7 +548,7 @@ input[type=submit]:active, background-image: -ms-linear-gradient(top, #dfdfdf, #eee); background-image: -o-linear-gradient(top, #dfdfdf, #eee); background-image: linear-gradient(top, #dfdfdf, #eee); - text-shadow: #eee 0px 1px 0px; + text-shadow: #eee 0 1px 0; -moz-box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.3); -webkit-box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.3); box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.3); @@ -625,15 +624,15 @@ pre { -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; - margin: 0px 4px 10px 2px; + margin: 0 4px 10px 2px; font-family: sans-serif; font-size: 14px; line-height: 14px; display: inline-block; text-decoration: none; - -moz-box-shadow: inset 0px 1px 0 rgba(0, 0, 0, 0.3); - -webkit-box-shadow: inset 0px 1px 0 rgba(0, 0, 0, 0.3); - box-shadow: inset 0px 1px 0 rgba(0, 0, 0, 0.3); + -moz-box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.3); + -webkit-box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.3); + box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.3); } .cake-code-dump pre { position: relative; @@ -645,13 +644,13 @@ pre { .cake-stack-trace pre { color: #000; background-color: #F0F0F0; - margin: 0px 0 10px 0; + margin: 0 0 10px 0; padding: 1em; overflow: auto; text-shadow: none; } .cake-stack-trace li { - padding: 10px 5px 0px; + padding: 10px 5px 0; margin: 0 0 4px 0; font-family: monospace; border: 1px solid #bbb; @@ -707,7 +706,7 @@ pre { } .code-coverage-results div.start { border:1px solid #aaa; - border-width:1px 1px 0px 1px; + border-width:1px 1px 0 1px; margin-top:30px; padding-top:5px; } diff --git a/lib/Cake/Console/Templates/skel/webroot/index.php b/lib/Cake/Console/Templates/skel/webroot/index.php index e546e52ca63..2db183b8d43 100644 --- a/lib/Cake/Console/Templates/skel/webroot/index.php +++ b/lib/Cake/Console/Templates/skel/webroot/index.php @@ -24,7 +24,6 @@ /** * The full path to the directory which holds "app", WITHOUT a trailing DS. - * */ if (!defined('ROOT')) { define('ROOT', dirname(dirname(dirname(__FILE__)))); @@ -32,7 +31,6 @@ /** * The actual directory name for the "app". - * */ if (!defined('APP_DIR')) { define('APP_DIR', basename(dirname(dirname(__FILE__)))); @@ -67,7 +65,6 @@ /** * Editing below this line should NOT be necessary. * Change at your own risk. - * */ if (!defined('WEBROOT_DIR')) { define('WEBROOT_DIR', basename(dirname(__FILE__))); diff --git a/lib/Cake/Console/Templates/skel/webroot/test.php b/lib/Cake/Console/Templates/skel/webroot/test.php index 0de048175a9..08eb92f3a2c 100644 --- a/lib/Cake/Console/Templates/skel/webroot/test.php +++ b/lib/Cake/Console/Templates/skel/webroot/test.php @@ -25,7 +25,6 @@ /** * The full path to the directory which holds "app", WITHOUT a trailing DS. - * */ if (!defined('ROOT')) { define('ROOT', dirname(dirname(dirname(__FILE__)))); @@ -33,7 +32,6 @@ /** * The actual directory name for the "app". - * */ if (!defined('APP_DIR')) { define('APP_DIR', basename(dirname(dirname(__FILE__)))); @@ -65,7 +63,6 @@ /** * Editing below this line should not be necessary. * Change at your own risk. - * */ if (!defined('WEBROOT_DIR')) { define('WEBROOT_DIR', basename(dirname(__FILE__))); From 5eedc0f2bb54ac4434e9feb6a453f4345ba4836c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Fri, 25 Sep 2015 17:55:01 +0200 Subject: [PATCH 321/336] Fix broken test --- lib/Cake/Console/Templates/default/classes/controller.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Console/Templates/default/classes/controller.ctp b/lib/Cake/Console/Templates/default/classes/controller.ctp index 3e5a3004e62..6beb4b4019f 100644 --- a/lib/Cake/Console/Templates/default/classes/controller.ctp +++ b/lib/Cake/Console/Templates/default/classes/controller.ctp @@ -23,10 +23,10 @@ echo "App::uses('{$plugin}AppController', '{$pluginPath}Controller');\n"; ?> /** * Controller - * Date: Fri, 25 Sep 2015 18:02:44 +0200 Subject: [PATCH 322/336] Correct return type Refs https://github.com/cakephp/cakephp/pull/7447#discussion_r40444444 --- lib/Cake/Event/CakeEventManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Event/CakeEventManager.php b/lib/Cake/Event/CakeEventManager.php index 9043fbf94e1..f647fd941d0 100644 --- a/lib/Cake/Event/CakeEventManager.php +++ b/lib/Cake/Event/CakeEventManager.php @@ -172,10 +172,10 @@ public function detach($callable, $eventKey = null) { foreach (array_keys($this->_listeners) as $eventKey) { $this->detach($callable, $eventKey); } - return null; + return; } if (empty($this->_listeners[$eventKey])) { - return null; + return; } foreach ($this->_listeners[$eventKey] as $priority => $callables) { foreach ($callables as $k => $callback) { From f7c472ea1e7c099e327e4c8a327df10235035638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Fri, 25 Sep 2015 18:03:36 +0200 Subject: [PATCH 323/336] Add note to param Refs: https://github.com/cakephp/cakephp/pull/7447#discussion_r40444483 --- lib/Cake/Log/Engine/FileLog.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Log/Engine/FileLog.php b/lib/Cake/Log/Engine/FileLog.php index 66d2ca5d2e1..988ed341feb 100644 --- a/lib/Cake/Log/Engine/FileLog.php +++ b/lib/Cake/Log/Engine/FileLog.php @@ -182,7 +182,7 @@ protected function _getFilename($type) { * Also if `rotate` count is reached oldest file is removed. * * @param string $filename Log file name - * @return mixed True if rotated successfully or false in case of error. + * @return mixed True if rotated successfully or false in case of error, otherwise null. * Void if file doesn't need to be rotated. */ protected function _rotateFile($filename) { From 1267586f23e49f5ea81f213f76fdebd441ccfdb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Fri, 25 Sep 2015 18:10:18 +0200 Subject: [PATCH 324/336] Re-add closing tags to ctp files Refs https://github.com/cakephp/cakephp/pull/7447#discussion_r40444715 --- lib/Cake/Console/Templates/default/views/view.ctp | 1 + lib/Cake/View/Errors/fatal_error.ctp | 1 + lib/Cake/View/Errors/missing_action.ctp | 1 + lib/Cake/View/Errors/missing_behavior.ctp | 1 + lib/Cake/View/Errors/missing_component.ctp | 1 + lib/Cake/View/Errors/missing_controller.ctp | 1 + lib/Cake/View/Errors/missing_database.ctp | 1 + lib/Cake/View/Errors/missing_datasource.ctp | 1 + lib/Cake/View/Errors/missing_datasource_config.ctp | 1 + lib/Cake/View/Errors/missing_helper.ctp | 1 + lib/Cake/View/Errors/missing_layout.ctp | 1 + lib/Cake/View/Errors/missing_plugin.ctp | 1 + lib/Cake/View/Errors/missing_table.ctp | 1 + lib/Cake/View/Errors/missing_view.ctp | 1 + lib/Cake/View/Errors/pdo_error.ctp | 1 + lib/Cake/View/Errors/private_action.ctp | 1 + lib/Cake/View/Errors/scaffold_error.ctp | 1 + 17 files changed, 17 insertions(+) diff --git a/lib/Cake/Console/Templates/default/views/view.ctp b/lib/Cake/Console/Templates/default/views/view.ctp index 8c0882eb484..83429beb4ff 100644 --- a/lib/Cake/Console/Templates/default/views/view.ctp +++ b/lib/Cake/Console/Templates/default/views/view.ctp @@ -133,3 +133,4 @@ echo "\t\n"; diff --git a/lib/Cake/View/Errors/fatal_error.ctp b/lib/Cake/View/Errors/fatal_error.ctp index 52b2a8a72c1..8749a8f5ae1 100644 --- a/lib/Cake/View/Errors/fatal_error.ctp +++ b/lib/Cake/View/Errors/fatal_error.ctp @@ -36,3 +36,4 @@ if (extension_loaded('xdebug')) { xdebug_print_function_stack(); } +?> \ No newline at end of file diff --git a/lib/Cake/View/Errors/missing_action.ctp b/lib/Cake/View/Errors/missing_action.ctp index f507cd11039..edc8311241f 100644 --- a/lib/Cake/View/Errors/missing_action.ctp +++ b/lib/Cake/View/Errors/missing_action.ctp @@ -40,3 +40,4 @@ class extends AppController {

    element('exception_stack_trace'); +?> \ No newline at end of file diff --git a/lib/Cake/View/Errors/missing_behavior.ctp b/lib/Cake/View/Errors/missing_behavior.ctp index dee50802ef0..e018ae73bca 100644 --- a/lib/Cake/View/Errors/missing_behavior.ctp +++ b/lib/Cake/View/Errors/missing_behavior.ctp @@ -38,3 +38,4 @@ class extends ModelBehavior { element('exception_stack_trace'); +?> \ No newline at end of file diff --git a/lib/Cake/View/Errors/missing_component.ctp b/lib/Cake/View/Errors/missing_component.ctp index 2bb1455e3ab..3ecc315543c 100644 --- a/lib/Cake/View/Errors/missing_component.ctp +++ b/lib/Cake/View/Errors/missing_component.ctp @@ -38,3 +38,4 @@ class extends Component { element('exception_stack_trace'); +?> diff --git a/lib/Cake/View/Errors/missing_controller.ctp b/lib/Cake/View/Errors/missing_controller.ctp index c20c9c87ab0..8bfc90b7e82 100644 --- a/lib/Cake/View/Errors/missing_controller.ctp +++ b/lib/Cake/View/Errors/missing_controller.ctp @@ -38,3 +38,4 @@ class AppController { element('exception_stack_trace'); +?> diff --git a/lib/Cake/View/Errors/missing_database.ctp b/lib/Cake/View/Errors/missing_database.ctp index 73c9ccd5067..adca1093614 100644 --- a/lib/Cake/View/Errors/missing_database.ctp +++ b/lib/Cake/View/Errors/missing_database.ctp @@ -30,3 +30,4 @@ element('exception_stack_trace'); +?> diff --git a/lib/Cake/View/Errors/missing_datasource.ctp b/lib/Cake/View/Errors/missing_datasource.ctp index 7b4868374a7..e8558e57cfc 100644 --- a/lib/Cake/View/Errors/missing_datasource.ctp +++ b/lib/Cake/View/Errors/missing_datasource.ctp @@ -31,3 +31,4 @@ $pluginDot = empty($plugin) ? null : $plugin . '.'; element('exception_stack_trace'); +?> diff --git a/lib/Cake/View/Errors/missing_datasource_config.ctp b/lib/Cake/View/Errors/missing_datasource_config.ctp index b08f2d56baa..115bdc7ba1e 100644 --- a/lib/Cake/View/Errors/missing_datasource_config.ctp +++ b/lib/Cake/View/Errors/missing_datasource_config.ctp @@ -26,3 +26,4 @@ element('exception_stack_trace'); +?> diff --git a/lib/Cake/View/Errors/missing_helper.ctp b/lib/Cake/View/Errors/missing_helper.ctp index 0da9aa00e97..6e2dc0d679e 100644 --- a/lib/Cake/View/Errors/missing_helper.ctp +++ b/lib/Cake/View/Errors/missing_helper.ctp @@ -38,3 +38,4 @@ class extends AppHelper { element('exception_stack_trace'); +?> diff --git a/lib/Cake/View/Errors/missing_layout.ctp b/lib/Cake/View/Errors/missing_layout.ctp index e1cf0dfcbc6..cf1b53e10ab 100644 --- a/lib/Cake/View/Errors/missing_layout.ctp +++ b/lib/Cake/View/Errors/missing_layout.ctp @@ -43,3 +43,4 @@ element('exception_stack_trace'); +?> diff --git a/lib/Cake/View/Errors/missing_plugin.ctp b/lib/Cake/View/Errors/missing_plugin.ctp index b2f02bc70b9..3e7b4d1c3e4 100644 --- a/lib/Cake/View/Errors/missing_plugin.ctp +++ b/lib/Cake/View/Errors/missing_plugin.ctp @@ -42,3 +42,4 @@ CakePlugin::loadAll(); element('exception_stack_trace'); +?> diff --git a/lib/Cake/View/Errors/missing_table.ctp b/lib/Cake/View/Errors/missing_table.ctp index 34e943e04f5..5fcf2ac3222 100644 --- a/lib/Cake/View/Errors/missing_table.ctp +++ b/lib/Cake/View/Errors/missing_table.ctp @@ -26,3 +26,4 @@ element('exception_stack_trace'); +?> diff --git a/lib/Cake/View/Errors/missing_view.ctp b/lib/Cake/View/Errors/missing_view.ctp index 37c3dcca81b..208afffe733 100644 --- a/lib/Cake/View/Errors/missing_view.ctp +++ b/lib/Cake/View/Errors/missing_view.ctp @@ -43,3 +43,4 @@ element('exception_stack_trace'); +?> diff --git a/lib/Cake/View/Errors/pdo_error.ctp b/lib/Cake/View/Errors/pdo_error.ctp index 71afc6f0a23..2f8d4aa2b4e 100644 --- a/lib/Cake/View/Errors/pdo_error.ctp +++ b/lib/Cake/View/Errors/pdo_error.ctp @@ -35,3 +35,4 @@

    element('exception_stack_trace'); +?> diff --git a/lib/Cake/View/Errors/private_action.ctp b/lib/Cake/View/Errors/private_action.ctp index 00810609eee..0fd18585591 100644 --- a/lib/Cake/View/Errors/private_action.ctp +++ b/lib/Cake/View/Errors/private_action.ctp @@ -26,3 +26,4 @@ element('exception_stack_trace'); +?> diff --git a/lib/Cake/View/Errors/scaffold_error.ctp b/lib/Cake/View/Errors/scaffold_error.ctp index 998d75e76a8..9cfe10490ff 100644 --- a/lib/Cake/View/Errors/scaffold_error.ctp +++ b/lib/Cake/View/Errors/scaffold_error.ctp @@ -35,3 +35,4 @@ function _scaffoldError() {
    if (isset($error) && $error instanceof Exception) { echo $this->element('exception_stack_trace'); } +?> \ No newline at end of file From 41abccc062c175edcb86e4c036494218df361729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Fri, 25 Sep 2015 18:12:20 +0200 Subject: [PATCH 325/336] Update param annotation Refs https://github.com/cakephp/cakephp/pull/7447#discussion_r40444634 --- lib/Cake/Routing/Dispatcher.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Routing/Dispatcher.php b/lib/Cake/Routing/Dispatcher.php index 87c0a81161d..35a2df21ede 100644 --- a/lib/Cake/Routing/Dispatcher.php +++ b/lib/Cake/Routing/Dispatcher.php @@ -137,7 +137,7 @@ protected function _attachFilters($manager) { * @param CakeRequest $request Request object to dispatch. * @param CakeResponse $response Response object to put the results of the dispatch into. * @param array $additionalParams Settings array ("bare", "return") which is melded with the GET and POST params - * @return string|void if `$request['return']` is set then it returns response body, null otherwise + * @return string|null if `$request['return']` is set then it returns response body, null otherwise * @triggers Dispatcher.beforeDispatch $this, compact('request', 'response', 'additionalParams') * @triggers Dispatcher.afterDispatch $this, compact('request', 'response') * @throws MissingControllerException When the controller is missing. From a6d62cb6a870f206b5ae23b8b61c8e59ba146416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Fri, 25 Sep 2015 20:10:47 +0200 Subject: [PATCH 326/336] Removed $stringClean Resfs: https://github.com/cakephp/cakephp/pull/7448#discussion_r40450663 --- lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php b/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php index f9a677a9c01..da97150c370 100644 --- a/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php +++ b/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php @@ -327,7 +327,6 @@ public function testAssertTextEquals() { */ public function testAssertTextStartsWith() { $stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!"; - // $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; $this->assertStringStartsWith("some\nstring", $stringDirty); $this->assertStringStartsNotWith("some\r\nstring\r\nwith", $stringDirty); @@ -344,8 +343,6 @@ public function testAssertTextStartsWith() { */ public function testAssertTextStartsNotWith() { $stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!"; - // $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; - $this->assertTextStartsNotWith("some\nstring\nwithout", $stringDirty); } @@ -356,8 +353,6 @@ public function testAssertTextStartsNotWith() { */ public function testAssertTextEndsWith() { $stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!"; - // $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; - $this->assertTextEndsWith("string\nwith\r\ndifferent\rline endings!", $stringDirty); $this->assertTextEndsWith("string\r\nwith\ndifferent\nline endings!", $stringDirty); } @@ -369,8 +364,6 @@ public function testAssertTextEndsWith() { */ public function testAssertTextEndsNotWith() { $stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!"; - // $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; - $this->assertStringEndsNotWith("different\nline endings", $stringDirty); $this->assertTextEndsNotWith("different\rline endings", $stringDirty); } @@ -382,11 +375,8 @@ public function testAssertTextEndsNotWith() { */ public function testAssertTextContains() { $stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!"; - // $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; - $this->assertContains("different", $stringDirty); $this->assertNotContains("different\rline", $stringDirty); - $this->assertTextContains("different\rline", $stringDirty); } @@ -397,8 +387,6 @@ public function testAssertTextContains() { */ public function testAssertTextNotContains() { $stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!"; - // $stringClean = "some\nstring\nwith\ndifferent\nline endings!"; - $this->assertTextNotContains("different\rlines", $stringDirty); } From ab7e8f8491fb734c1d7004b32f051a22a3eda3e5 Mon Sep 17 00:00:00 2001 From: ADmad Date: Mon, 28 Sep 2015 09:48:50 +0530 Subject: [PATCH 327/336] Update debugkit links to 2.x compatible branch Refs cakephp/debug_kit#372 --- app/View/Pages/home.ctp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/View/Pages/home.ctp b/app/View/Pages/home.ctp index c3f98b106d5..67078a984b6 100644 --- a/app/View/Pages/home.ctp +++ b/app/View/Pages/home.ctp @@ -138,7 +138,7 @@ endif; echo ''; echo __d('cake_dev', 'DebugKit is not installed. It will help you inspect and debug different aspects of your application.'); echo '
    '; - echo __d('cake_dev', 'You can install it from %s', $this->Html->link('GitHub', 'https://github.com/cakephp/debug_kit')); + echo __d('cake_dev', 'You can install it from %s', $this->Html->link('GitHub', 'https://github.com/cakephp/debug_kit/tree/2.2')); echo '
    '; endif; ?> @@ -178,7 +178,7 @@ You can also add some CSS styles for your pages at: %s.',

    • - Html->link('DebugKit', 'https://github.com/cakephp/debug_kit') ?>: + Html->link('DebugKit', 'https://github.com/cakephp/debug_kit/tree/2.2') ?>:
    • From f1160b74011c2adab158e487bc3f9e24f0ad0a07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Mon, 28 Sep 2015 12:47:14 +0200 Subject: [PATCH 328/336] Update link to DebugKit 2.2 branch Refs https://github.com/cakephp/debug_kit/issues/372 --- app/View/Pages/home.ctp | 2 +- lib/Cake/Console/Templates/skel/View/Pages/home.ctp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/View/Pages/home.ctp b/app/View/Pages/home.ctp index c3f98b106d5..3f2e825a7a2 100644 --- a/app/View/Pages/home.ctp +++ b/app/View/Pages/home.ctp @@ -178,7 +178,7 @@ You can also add some CSS styles for your pages at: %s.',

      • - Html->link('DebugKit', 'https://github.com/cakephp/debug_kit') ?>: + Html->link('DebugKit', 'https://github.com/cakephp/debug_kit/tree/2.2') ?>:
      • diff --git a/lib/Cake/Console/Templates/skel/View/Pages/home.ctp b/lib/Cake/Console/Templates/skel/View/Pages/home.ctp index 5bac4537f3f..55dfdbedf96 100644 --- a/lib/Cake/Console/Templates/skel/View/Pages/home.ctp +++ b/lib/Cake/Console/Templates/skel/View/Pages/home.ctp @@ -181,7 +181,7 @@ You can also add some CSS styles for your pages at: %s.',

        • - Html->link('DebugKit', 'https://github.com/cakephp/debug_kit') ?>: + Html->link('DebugKit', 'https://github.com/cakephp/debug_kit/tree/2.2') ?>:
        • From 2d82a120afe6f2a56cc2de2fd3b38d7bcf347589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Mon, 28 Sep 2015 12:47:25 +0200 Subject: [PATCH 329/336] CS --- app/Config/bootstrap.php | 2 +- lib/Cake/Console/Templates/skel/Config/bootstrap.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Config/bootstrap.php b/app/Config/bootstrap.php index 03cda9cae71..1eace32fb4b 100644 --- a/app/Config/bootstrap.php +++ b/app/Config/bootstrap.php @@ -64,7 +64,7 @@ * advanced ways of loading plugins * * CakePlugin::loadAll(); // Loads all plugins at once - * CakePlugin::load('DebugKit'); //Loads a single plugin named DebugKit + * CakePlugin::load('DebugKit'); // Loads a single plugin named DebugKit */ /** diff --git a/lib/Cake/Console/Templates/skel/Config/bootstrap.php b/lib/Cake/Console/Templates/skel/Config/bootstrap.php index 8b54c36ecca..0cf81bec339 100644 --- a/lib/Cake/Console/Templates/skel/Config/bootstrap.php +++ b/lib/Cake/Console/Templates/skel/Config/bootstrap.php @@ -55,7 +55,7 @@ * advanced ways of loading plugins * * CakePlugin::loadAll(); // Loads all plugins at once - * CakePlugin::load('DebugKit'); //Loads a single plugin named DebugKit + * CakePlugin::load('DebugKit'); // Loads a single plugin named DebugKit */ /** From 7b20c804f44a1ddcacb11e2f9d686557dc4dbe05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Mon, 28 Sep 2015 12:48:40 +0200 Subject: [PATCH 330/336] Use caret operator for depending on DebugKit --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d5eae1773bd..5c2ac669232 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ }, "require-dev": { "phpunit/phpunit": "3.7.*", - "cakephp/debug_kit" : "2.2.*", + "cakephp/debug_kit" : "^2.2.0", "cakephp/cakephp-codesniffer": "^1.0.0" }, "bin": [ From 26a05a4e87e45cbf8ba5884ef381364210d9c200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Mon, 28 Sep 2015 12:51:30 +0200 Subject: [PATCH 331/336] Update another link to DebugKit 2.2 branch --- app/View/Pages/home.ctp | 2 +- lib/Cake/Console/Templates/skel/View/Pages/home.ctp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/View/Pages/home.ctp b/app/View/Pages/home.ctp index 3f2e825a7a2..67078a984b6 100644 --- a/app/View/Pages/home.ctp +++ b/app/View/Pages/home.ctp @@ -138,7 +138,7 @@ endif; echo ''; echo __d('cake_dev', 'DebugKit is not installed. It will help you inspect and debug different aspects of your application.'); echo '
          '; - echo __d('cake_dev', 'You can install it from %s', $this->Html->link('GitHub', 'https://github.com/cakephp/debug_kit')); + echo __d('cake_dev', 'You can install it from %s', $this->Html->link('GitHub', 'https://github.com/cakephp/debug_kit/tree/2.2')); echo '
          '; endif; ?> diff --git a/lib/Cake/Console/Templates/skel/View/Pages/home.ctp b/lib/Cake/Console/Templates/skel/View/Pages/home.ctp index 55dfdbedf96..ad84a25539e 100644 --- a/lib/Cake/Console/Templates/skel/View/Pages/home.ctp +++ b/lib/Cake/Console/Templates/skel/View/Pages/home.ctp @@ -141,7 +141,7 @@ if (isset($filePresent)): echo ''; echo __d('cake_dev', 'DebugKit is not installed. It will help you inspect and debug different aspects of your application.'); echo '
          '; - echo __d('cake_dev', 'You can install it from %s', $this->Html->link('GitHub', 'https://github.com/cakephp/debug_kit')); + echo __d('cake_dev', 'You can install it from %s', $this->Html->link('GitHub', 'https://github.com/cakephp/debug_kit/tree/2.2')); echo '
          '; endif; ?> From c3e08fde308ad6ed488ecff4fc5cd3618d99b645 Mon Sep 17 00:00:00 2001 From: ADmad Date: Mon, 28 Sep 2015 22:52:51 +0530 Subject: [PATCH 332/336] Load config file before checking class existence. Closes #7465 --- lib/Cake/Network/Email/CakeEmail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index 823c85f65fc..027cd539d7f 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -360,7 +360,7 @@ public function __construct($config = null) { if ($config) { $this->config($config); - } elseif (class_exists($this->_configClass) && config('email')) { + } elseif (config('email') && class_exists($this->_configClass)) { $this->_configInstance = new $this->_configClass(); if (isset($this->_configInstance->default)) { $this->config('default'); From 13f147940fbf18482fa9db8d1b93fd423008cedc Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 28 Sep 2015 21:04:23 -0400 Subject: [PATCH 333/336] Correct inflection of virus. Instead of viri, it should be viruses. Refs #7466 --- lib/Cake/Test/Case/Utility/InflectorTest.php | 4 ++-- lib/Cake/Utility/Inflector.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/InflectorTest.php b/lib/Cake/Test/Case/Utility/InflectorTest.php index 638ba54dc87..9df596e78dd 100644 --- a/lib/Cake/Test/Case/Utility/InflectorTest.php +++ b/lib/Cake/Test/Case/Utility/InflectorTest.php @@ -128,7 +128,7 @@ public function testInflectingSingulars() { $this->assertEquals(Inflector::singularize('stimuli'), 'stimulus'); $this->assertEquals(Inflector::singularize('syllabi'), 'syllabus'); $this->assertEquals(Inflector::singularize('termini'), 'terminus'); - $this->assertEquals(Inflector::singularize('viri'), 'virus'); + $this->assertEquals(Inflector::singularize('viruses'), 'virus'); $this->assertEquals(Inflector::singularize('people'), 'person'); $this->assertEquals(Inflector::singularize('gloves'), 'glove'); $this->assertEquals(Inflector::singularize('doves'), 'dove'); @@ -246,7 +246,7 @@ public function testInflectingPlurals() { $this->assertEquals(Inflector::pluralize('stimulus'), 'stimuli'); $this->assertEquals(Inflector::pluralize('syllabus'), 'syllabi'); $this->assertEquals(Inflector::pluralize('terminus'), 'termini'); - $this->assertEquals(Inflector::pluralize('virus'), 'viri'); + $this->assertEquals(Inflector::pluralize('virus'), 'viruses'); $this->assertEquals(Inflector::pluralize('person'), 'people'); $this->assertEquals(Inflector::pluralize('people'), 'people'); $this->assertEquals(Inflector::pluralize('glove'), 'gloves'); diff --git a/lib/Cake/Utility/Inflector.php b/lib/Cake/Utility/Inflector.php index 6644661c349..40b9de2810e 100644 --- a/lib/Cake/Utility/Inflector.php +++ b/lib/Cake/Utility/Inflector.php @@ -47,7 +47,7 @@ class Inflector { '/(? '\1en', '/(c)hild$/i' => '\1hildren', '/(buffal|tomat)o$/i' => '\1\2oes', - '/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|vir)us$/i' => '\1i', + '/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin)us$/i' => '\1i', '/us$/i' => 'uses', '/(alias)$/i' => '\1es', '/(ax|cris|test)is$/i' => '\1es', From 0502e0731a60769244e5c87b520e9e5e867a0e9a Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 28 Sep 2015 21:13:09 -0400 Subject: [PATCH 334/336] Update version number to 2.7.4 --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index c7f798220d5..da75153a056 100644 --- a/lib/Cake/VERSION.txt +++ b/lib/Cake/VERSION.txt @@ -17,4 +17,4 @@ // @license http://www.opensource.org/licenses/mit-license.php MIT License // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -2.7.3 +2.7.4 From 17c3358d772cd0459431105207e0041297bbbc70 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 29 Sep 2015 21:41:33 -0400 Subject: [PATCH 335/336] Revert part of the changes in 1ede742d92 These variables are used by the HTML test reporter. --- lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php b/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php index d877d556f8d..3e68005f3a8 100644 --- a/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php +++ b/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php @@ -58,7 +58,7 @@ public function sendContentType() { */ public function paintDocumentStart() { ob_start(); - $this->params['baseDir']; + $baseDir = $this->params['baseDir']; include CAKE . 'TestSuite' . DS . 'templates' . DS . 'header.php'; } @@ -69,7 +69,7 @@ public function paintDocumentStart() { * @return void */ public function paintTestMenu() { - $this->baseUrl() . '?show=cases'; + $cases = $this->baseUrl() . '?show=cases'; $plugins = App::objects('plugin', null, false); sort($plugins); include CAKE . 'TestSuite' . DS . 'templates' . DS . 'menu.php'; From 3fa5c4ff9406309aa52dcf5ef604ebbcae882dd6 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 1 Oct 2015 21:03:56 -0400 Subject: [PATCH 336/336] Update version number to 2.7.5 --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index da75153a056..dbae9b96081 100644 --- a/lib/Cake/VERSION.txt +++ b/lib/Cake/VERSION.txt @@ -17,4 +17,4 @@ // @license http://www.opensource.org/licenses/mit-license.php MIT License // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -2.7.4 +2.7.5