From 2b4b2ef2c867793e50a4605488d83f1c5119a8c1 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Wed, 25 Jan 2017 16:44:24 +0100 Subject: [PATCH 01/13] Fix for incorrect @return phpdoccomment --- app/Controller/PagesController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Controller/PagesController.php b/app/Controller/PagesController.php index f4bc815f946..e9ba9d9bd02 100644 --- a/app/Controller/PagesController.php +++ b/app/Controller/PagesController.php @@ -40,7 +40,7 @@ class PagesController extends AppController { /** * Displays a view * - * @return void + * @return \Cake\Network\Response|null * @throws ForbiddenException When a directory traversal attempt. * @throws NotFoundException When the view file could not be found * or MissingViewException in debug mode. From 259972a78562ad4843e5dad5edd9a16f37cb6be7 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Fri, 27 Jan 2017 10:33:49 +0100 Subject: [PATCH 02/13] Fix for incorrect @return phpdoccomment --- lib/Cake/Console/TaskCollection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Console/TaskCollection.php b/lib/Cake/Console/TaskCollection.php index 3fafddd1384..3c237d26e06 100644 --- a/lib/Cake/Console/TaskCollection.php +++ b/lib/Cake/Console/TaskCollection.php @@ -64,7 +64,7 @@ public function __construct(Shell $Shell) { * * @param string $task Task name to load * @param array $settings Settings for the task. - * @return Task A task object, Either the existing loaded task or a new one. + * @return AppShell A task object, Either the existing loaded task or a new one. * @throws MissingTaskException when the task could not be found */ public function load($task, $settings = array()) { From 6818268a27e010af960a7e3f1cc5b56600bef84d Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Fri, 16 Dec 2016 21:34:41 +0100 Subject: [PATCH 03/13] New Validation::(min|max)ByteLength() addition --- lib/Cake/Test/Case/Utility/ValidationTest.php | 28 +++++++++++++++++++ lib/Cake/Utility/Validation.php | 26 +++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index 9b34c03b107..bec844dcb73 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -1825,6 +1825,20 @@ public function testMaxLength() { $this->assertFalse(Validation::maxLength('ÆΔΩЖÇ', 3)); } +/** + * maxLengthBytes method + * + * @return void + */ + public function testMaxLengthBytes() { + $this->assertTrue(Validation::maxLengthBytes('ab', 3)); + $this->assertTrue(Validation::maxLengthBytes('abc', 3)); + $this->assertTrue(Validation::maxLengthBytes('ÆΔΩЖÇ', 10)); + $this->assertTrue(Validation::maxLengthBytes('ÆΔΩЖÇ', 11)); + $this->assertFalse(Validation::maxLengthBytes('abcd', 3)); + $this->assertFalse(Validation::maxLengthBytes('ÆΔΩЖÇ', 9)); + } + /** * testMinLength method * @@ -1839,6 +1853,20 @@ public function testMinLength() { $this->assertTrue(Validation::minLength('ÆΔΩЖÇ', 2)); } +/** + * minLengthBytes method + * + * @return void + */ + public function testMinLengthBytes() { + $this->assertFalse(Validation::minLengthBytes('ab', 3)); + $this->assertFalse(Validation::minLengthBytes('ÆΔΩЖÇ', 11)); + $this->assertTrue(Validation::minLengthBytes('abc', 3)); + $this->assertTrue(Validation::minLengthBytes('abcd', 3)); + $this->assertTrue(Validation::minLengthBytes('ÆΔΩЖÇ', 10)); + $this->assertTrue(Validation::minLengthBytes('ÆΔΩЖÇ', 9)); + } + /** * testUrl method * diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index 12338846311..8ee3c10a01d 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -539,7 +539,7 @@ public static function ip($check, $type = 'both') { } /** - * Checks whether the length of a string is greater or equal to a minimal length. + * Checks whether the length of a string (in character) is greater or equal to a minimal length. * * @param string $check The string to test * @param int $min The minimal string length @@ -550,7 +550,7 @@ public static function minLength($check, $min) { } /** - * Checks whether the length of a string is smaller or equal to a maximal length.. + * Checks whether the length of a string (in character) is smaller or equal to a maximal length.. * * @param string $check The string to test * @param int $max The maximal string length @@ -560,6 +560,28 @@ public static function maxLength($check, $max) { return mb_strlen($check) <= $max; } +/** + * Checks whether the length of a string (in bytes) is greater or equal to a minimal length. + * + * @param string $check The string to test + * @param int $min The minimal string length + * @return bool Success + */ + public static function minLengthBytes($check, $min) { + return strlen($check) >= $min; + } + +/** + * Checks whether the length of a string (in bytes) is smaller or equal to a maximal length.. + * + * @param string $check The string to test + * @param int $max The maximal string length + * @return bool Success + */ + public static function maxLengthBytes($check, $max) { + return strlen($check) <= $max; + } + /** * Checks that a value is a monetary amount. * From 043858d9e61632127ed9eafb476637254385f577 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Sun, 18 Dec 2016 21:06:51 +0100 Subject: [PATCH 04/13] Fixed typo --- lib/Cake/Utility/Validation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index 8ee3c10a01d..da614de1d80 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -539,7 +539,7 @@ public static function ip($check, $type = 'both') { } /** - * Checks whether the length of a string (in character) is greater or equal to a minimal length. + * Checks whether the length of a string (in characters) is greater or equal to a minimal length. * * @param string $check The string to test * @param int $min The minimal string length @@ -550,7 +550,7 @@ public static function minLength($check, $min) { } /** - * Checks whether the length of a string (in character) is smaller or equal to a maximal length.. + * Checks whether the length of a string (in characters) is smaller or equal to a maximal length.. * * @param string $check The string to test * @param int $max The maximal string length From 7944f512adc477f46912b59200f96c6e60642fcf Mon Sep 17 00:00:00 2001 From: chinpei215 Date: Mon, 30 Jan 2017 03:21:58 +0900 Subject: [PATCH 05/13] Fix ModelTaskTest for tests passing --- .../Test/Case/Console/Command/Task/ModelTaskTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php index da5b8d7cb85..a9351400576 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('24', 'y', '18', 'n')); + ->will($this->onConsecutiveCalls('26', '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', '24', 'n')); + ->will($this->onConsecutiveCalls('999999', '26', '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('24', 'y', 's')); + ->will($this->onConsecutiveCalls('26', '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('24', 's')); + ->will($this->onConsecutiveCalls('26', '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('35', '24', 'n', '10', 's')); + ->will($this->onConsecutiveCalls('37', '26', 'n', '10', 's')); $this->Task->interactive = true; $Model = $this->getMock('Model'); $Model->primaryKey = 'id'; From 4335048bf8c011827864d7e6b82e880d0fa57a95 Mon Sep 17 00:00:00 2001 From: Mponos George Date: Tue, 7 Feb 2017 13:13:35 +0200 Subject: [PATCH 06/13] Cakephp should be in the required packages Cakephp should be in the required packages --- app/composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/composer.json b/app/composer.json index bf5c67cc8dc..e18edfb0331 100644 --- a/app/composer.json +++ b/app/composer.json @@ -19,11 +19,11 @@ }, "require": { "php": ">=5.3.0", - "ext-mcrypt": "*" + "ext-mcrypt": "*", + "cakephp/cakephp": "~2.9" }, "require-dev": { - "phpunit/phpunit": "3.7.*", - "cakephp/cakephp": "~2.9" + "phpunit/phpunit": "3.7.*" }, "suggest": { "cakephp/cakephp-codesniffer": "Easily check code formatting against the CakePHP coding standards." From f7360266f0197a5d8fefae47dc745db575270c9a Mon Sep 17 00:00:00 2001 From: Livia Scapin Date: Wed, 8 Feb 2017 13:48:22 +0100 Subject: [PATCH 07/13] Fix invalid return value hint --- 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 7a12ec155cf..96a0183d1f1 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -1006,7 +1006,7 @@ public function param($name) { * @param string $callback A decoding callback that will convert the string data to another * representation. Leave empty to access the raw input data. You can also * supply additional parameters for the decoding callback using var args, see above. - * @return The decoded/processed request data. + * @return mixed The decoded/processed request data. */ public function input($callback = null) { $input = $this->_readInput(); From 3f10a0227aeaa3d178d6a93fd4a830c52818a4d9 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 13 Feb 2017 21:50:51 -0500 Subject: [PATCH 08/13] Allow false/true to be read as keys in Hash::get(). While these are not values within the documented types, there exist use cases in CakeSession that necessitate these to be supported types. Refs #10196 --- lib/Cake/Test/Case/Utility/HashTest.php | 11 +++++++---- lib/Cake/Utility/Hash.php | 6 ++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index 53b1d40c823..5618ddc8b83 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -236,10 +236,13 @@ public function testGet() { */ public function testGetEmptyKey() { $data = array( - '' => 'some value' + true => 'true value', + false => 'false value', + '' => 'some value', ); - $result = Hash::get($data, ''); - $this->assertSame($data[''], $result); + $this->assertSame($data[''], Hash::get($data, '')); + $this->assertSame($data[false], Hash::get($data, false)); + $this->assertSame($data[true], Hash::get($data, true)); } /** @@ -249,7 +252,7 @@ public function testGetEmptyKey() { * @return void */ public function testGetInvalidPath() { - Hash::get(array('one' => 'two'), true); + Hash::get(array('one' => 'two'), new StdClass()); } /** diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index 2ca530ece25..af7a098eb2d 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -48,11 +48,13 @@ public static function get(array $data, $path, $default = null) { } if (is_string($path) || is_numeric($path)) { $parts = explode('.', $path); + } elseif (is_bool($path) || $path === null) { + $parts = [$path]; } else { if (!is_array($path)) { throw new InvalidArgumentException(__d('cake_dev', - 'Invalid Parameter %s, should be dot separated path or array.', - $path + 'Invalid path parameter: %s, should be dot separated path or array.', + var_export($path, true) )); } $parts = $path; From 34158407b2ef8131b9a4223439137f5834879c99 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 13 Feb 2017 22:37:44 -0500 Subject: [PATCH 09/13] Exit early if SMTP connection fails. If the SMTP connection is disconnected (read() returns false) we should exit early and not wait for the read timeout. This has the added benefit of making the mocks much simpler. Refs #10221 --- lib/Cake/Network/Email/SmtpTransport.php | 6 +- .../Case/Network/Email/SmtpTransportTest.php | 176 +++++++----------- 2 files changed, 75 insertions(+), 107 deletions(-) diff --git a/lib/Cake/Network/Email/SmtpTransport.php b/lib/Cake/Network/Email/SmtpTransport.php index b0761d4965c..6e5e6f95935 100644 --- a/lib/Cake/Network/Email/SmtpTransport.php +++ b/lib/Cake/Network/Email/SmtpTransport.php @@ -352,7 +352,11 @@ protected function _smtpSend($data, $checkCode = '250') { $response = ''; $startTime = time(); while (substr($response, -2) !== "\r\n" && ((time() - $startTime) < $this->_config['timeout'])) { - $response .= $this->_socket->read(); + $bytes = $this->_socket->read(); + if ($bytes === false || $bytes === null) { + break; + } + $response .= $bytes; } if (substr($response, -2) !== "\r\n") { throw new SocketException(__d('cake_dev', 'SMTP timeout.')); diff --git a/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php b/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php index 712ea54ae60..ef5f75b5eec 100644 --- a/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php +++ b/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php @@ -83,11 +83,13 @@ public function setUp() { */ public function testConnectEhlo() { $this->socket->expects($this->any())->method('connect')->will($this->returnValue(true)); - $this->socket->expects($this->at(0))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n")); - $this->socket->expects($this->at(2))->method('write')->with("EHLO localhost\r\n"); - $this->socket->expects($this->at(3))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(4))->method('read')->will($this->returnValue("250 Accepted\r\n")); + $this->socket->expects($this->any()) + ->method('read') + ->will($this->onConsecutiveCalls( + "220 Welcome message\r\n", + "250 Accepted\r\n" + )); + $this->socket->expects($this->once())->method('write')->with("EHLO localhost\r\n"); $this->SmtpTransport->connect(); } @@ -99,18 +101,14 @@ public function testConnectEhlo() { public function testConnectEhloTls() { $this->SmtpTransport->config(array('tls' => true)); $this->socket->expects($this->any())->method('connect')->will($this->returnValue(true)); - $this->socket->expects($this->at(0))->method('read')->will($this->returnValue(false)); $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n")); $this->socket->expects($this->at(2))->method('write')->with("EHLO localhost\r\n"); - $this->socket->expects($this->at(3))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(4))->method('read')->will($this->returnValue("250 Accepted\r\n")); - $this->socket->expects($this->at(5))->method('write')->with("STARTTLS\r\n"); - $this->socket->expects($this->at(6))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(7))->method('read')->will($this->returnValue("220 Server ready\r\n")); - $this->socket->expects($this->at(8))->method('enableCrypto')->with('tls')->will($this->returnValue(true)); - $this->socket->expects($this->at(9))->method('write')->with("EHLO localhost\r\n"); - $this->socket->expects($this->at(10))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(11))->method('read')->will($this->returnValue("250 Accepted\r\n")); + $this->socket->expects($this->at(3))->method('read')->will($this->returnValue("250 Accepted\r\n")); + $this->socket->expects($this->at(4))->method('write')->with("STARTTLS\r\n"); + $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("220 Server ready\r\n")); + $this->socket->expects($this->at(6))->method('enableCrypto')->with('tls')->will($this->returnValue(true)); + $this->socket->expects($this->at(7))->method('write')->with("EHLO localhost\r\n"); + $this->socket->expects($this->at(8))->method('read')->will($this->returnValue("250 Accepted\r\n")); $this->SmtpTransport->connect(); } @@ -124,14 +122,11 @@ public function testConnectEhloTls() { public function testConnectEhloTlsOnNonTlsServer() { $this->SmtpTransport->config(array('tls' => true)); $this->socket->expects($this->any())->method('connect')->will($this->returnValue(true)); - $this->socket->expects($this->at(0))->method('read')->will($this->returnValue(false)); $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n")); $this->socket->expects($this->at(2))->method('write')->with("EHLO localhost\r\n"); - $this->socket->expects($this->at(3))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(4))->method('read')->will($this->returnValue("250 Accepted\r\n")); - $this->socket->expects($this->at(5))->method('write')->with("STARTTLS\r\n"); - $this->socket->expects($this->at(6))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(7))->method('read')->will($this->returnValue("500 5.3.3 Unrecognized command\r\n")); + $this->socket->expects($this->at(3))->method('read')->will($this->returnValue("250 Accepted\r\n")); + $this->socket->expects($this->at(4))->method('write')->with("STARTTLS\r\n"); + $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("500 5.3.3 Unrecognized command\r\n")); $this->SmtpTransport->connect(); } @@ -145,14 +140,11 @@ public function testConnectEhloTlsOnNonTlsServer() { public function testConnectEhloNoTlsOnRequiredTlsServer() { $this->SmtpTransport->config(array('tls' => false, 'username' => 'user', 'password' => 'pass')); $this->socket->expects($this->any())->method('connect')->will($this->returnValue(true)); - $this->socket->expects($this->at(0))->method('read')->will($this->returnValue(false)); $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n")); $this->socket->expects($this->at(2))->method('write')->with("EHLO localhost\r\n"); - $this->socket->expects($this->at(3))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(4))->method('read')->will($this->returnValue("250 Accepted\r\n")); - $this->socket->expects($this->at(5))->method('write')->with("AUTH LOGIN\r\n"); - $this->socket->expects($this->at(6))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(7))->method('read')->will($this->returnValue("504 5.7.4 Unrecognized authentication type\r\n")); + $this->socket->expects($this->at(3))->method('read')->will($this->returnValue("250 Accepted\r\n")); + $this->socket->expects($this->at(4))->method('write')->with("AUTH LOGIN\r\n"); + $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("504 5.7.4 Unrecognized authentication type\r\n")); $this->SmtpTransport->connect(); $this->SmtpTransport->auth(); } @@ -164,14 +156,11 @@ public function testConnectEhloNoTlsOnRequiredTlsServer() { */ public function testConnectHelo() { $this->socket->expects($this->any())->method('connect')->will($this->returnValue(true)); - $this->socket->expects($this->at(0))->method('read')->will($this->returnValue(false)); $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n")); $this->socket->expects($this->at(2))->method('write')->with("EHLO localhost\r\n"); - $this->socket->expects($this->at(3))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(4))->method('read')->will($this->returnValue("200 Not Accepted\r\n")); - $this->socket->expects($this->at(5))->method('write')->with("HELO localhost\r\n"); - $this->socket->expects($this->at(6))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(7))->method('read')->will($this->returnValue("250 Accepted\r\n")); + $this->socket->expects($this->at(3))->method('read')->will($this->returnValue("200 Not Accepted\r\n")); + $this->socket->expects($this->at(4))->method('write')->with("HELO localhost\r\n"); + $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("250 Accepted\r\n")); $this->SmtpTransport->connect(); } @@ -184,14 +173,11 @@ public function testConnectHelo() { */ public function testConnectFail() { $this->socket->expects($this->any())->method('connect')->will($this->returnValue(true)); - $this->socket->expects($this->at(0))->method('read')->will($this->returnValue(false)); $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n")); $this->socket->expects($this->at(2))->method('write')->with("EHLO localhost\r\n"); - $this->socket->expects($this->at(3))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(4))->method('read')->will($this->returnValue("200 Not Accepted\r\n")); - $this->socket->expects($this->at(5))->method('write')->with("HELO localhost\r\n"); - $this->socket->expects($this->at(6))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(7))->method('read')->will($this->returnValue("200 Not Accepted\r\n")); + $this->socket->expects($this->at(3))->method('read')->will($this->returnValue("200 Not Accepted\r\n")); + $this->socket->expects($this->at(4))->method('write')->with("HELO localhost\r\n"); + $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("200 Not Accepted\r\n")); $this->SmtpTransport->connect(); } @@ -202,14 +188,11 @@ public function testConnectFail() { */ public function testAuth() { $this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n"); - $this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(2))->method('read')->will($this->returnValue("334 Login\r\n")); - $this->socket->expects($this->at(3))->method('write')->with("bWFyaw==\r\n"); - $this->socket->expects($this->at(4))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("334 Pass\r\n")); - $this->socket->expects($this->at(6))->method('write')->with("c3Rvcnk=\r\n"); - $this->socket->expects($this->at(7))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(8))->method('read')->will($this->returnValue("235 OK\r\n")); + $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("334 Login\r\n")); + $this->socket->expects($this->at(2))->method('write')->with("bWFyaw==\r\n"); + $this->socket->expects($this->at(3))->method('read')->will($this->returnValue("334 Pass\r\n")); + $this->socket->expects($this->at(4))->method('write')->with("c3Rvcnk=\r\n"); + $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("235 OK\r\n")); $this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story')); $this->SmtpTransport->auth(); } @@ -223,8 +206,7 @@ public function testAuth() { */ public function testAuthNotRecognized() { $this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n"); - $this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(2))->method('read')->will($this->returnValue("500 5.3.3 Unrecognized command\r\n")); + $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("500 5.3.3 Unrecognized command\r\n")); $this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story')); $this->SmtpTransport->auth(); } @@ -238,8 +220,8 @@ public function testAuthNotRecognized() { */ public function testAuthNotImplemented() { $this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n"); - $this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(2))->method('read')->will($this->returnValue("502 5.3.3 Command not implemented\r\n")); + $this->socket->expects($this->at(1))->method('read') + ->will($this->returnValue("502 5.3.3 Command not implemented\r\n")); $this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story')); $this->SmtpTransport->auth(); } @@ -253,8 +235,8 @@ public function testAuthNotImplemented() { */ public function testAuthBadSequence() { $this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n"); - $this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(2))->method('read')->will($this->returnValue("503 5.5.1 Already authenticated\r\n")); + $this->socket->expects($this->at(1))->method('read') + ->will($this->returnValue("503 5.5.1 Already authenticated\r\n")); $this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story')); $this->SmtpTransport->auth(); } @@ -268,11 +250,9 @@ public function testAuthBadSequence() { */ public function testAuthBadUsername() { $this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n"); - $this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(2))->method('read')->will($this->returnValue("334 Login\r\n")); - $this->socket->expects($this->at(3))->method('write')->with("bWFyaw==\r\n"); - $this->socket->expects($this->at(4))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("535 5.7.8 Authentication failed\r\n")); + $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("334 Login\r\n")); + $this->socket->expects($this->at(2))->method('write')->with("bWFyaw==\r\n"); + $this->socket->expects($this->at(3))->method('read')->will($this->returnValue("535 5.7.8 Authentication failed\r\n")); $this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story')); $this->SmtpTransport->auth(); } @@ -286,14 +266,11 @@ public function testAuthBadUsername() { */ public function testAuthBadPassword() { $this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n"); - $this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(2))->method('read')->will($this->returnValue("334 Login\r\n")); - $this->socket->expects($this->at(3))->method('write')->with("bWFyaw==\r\n"); - $this->socket->expects($this->at(4))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("334 Pass\r\n")); - $this->socket->expects($this->at(6))->method('write')->with("c3Rvcnk=\r\n"); - $this->socket->expects($this->at(7))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(8))->method('read')->will($this->returnValue("535 5.7.8 Authentication failed\r\n")); + $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("334 Login\r\n")); + $this->socket->expects($this->at(2))->method('write')->with("bWFyaw==\r\n"); + $this->socket->expects($this->at(3))->method('read')->will($this->returnValue("334 Pass\r\n")); + $this->socket->expects($this->at(4))->method('write')->with("c3Rvcnk=\r\n"); + $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("535 5.7.8 Authentication failed\r\n")); $this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story')); $this->SmtpTransport->auth(); } @@ -323,20 +300,15 @@ public function testRcpt() { $email->cc(array('mark@cakephp.org' => 'Mark Story', 'juan@cakephp.org' => 'Juan Basso')); $this->socket->expects($this->at(0))->method('write')->with("MAIL FROM:\r\n"); - $this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(2))->method('read')->will($this->returnValue("250 OK\r\n")); - $this->socket->expects($this->at(3))->method('write')->with("RCPT TO:\r\n"); - $this->socket->expects($this->at(4))->method('read')->will($this->returnValue(false)); + $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("250 OK\r\n")); + $this->socket->expects($this->at(2))->method('write')->with("RCPT TO:\r\n"); + $this->socket->expects($this->at(3))->method('read')->will($this->returnValue("250 OK\r\n")); + $this->socket->expects($this->at(4))->method('write')->with("RCPT TO:\r\n"); $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("250 OK\r\n")); - $this->socket->expects($this->at(6))->method('write')->with("RCPT TO:\r\n"); - $this->socket->expects($this->at(7))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(8))->method('read')->will($this->returnValue("250 OK\r\n")); - $this->socket->expects($this->at(9))->method('write')->with("RCPT TO:\r\n"); - $this->socket->expects($this->at(10))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(11))->method('read')->will($this->returnValue("250 OK\r\n")); - $this->socket->expects($this->at(12))->method('write')->with("RCPT TO:\r\n"); - $this->socket->expects($this->at(13))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(14))->method('read')->will($this->returnValue("250 OK\r\n")); + $this->socket->expects($this->at(6))->method('write')->with("RCPT TO:\r\n"); + $this->socket->expects($this->at(7))->method('read')->will($this->returnValue("250 OK\r\n")); + $this->socket->expects($this->at(8))->method('write')->with("RCPT TO:\r\n"); + $this->socket->expects($this->at(9))->method('read')->will($this->returnValue("250 OK\r\n")); $this->SmtpTransport->sendRcpt($email); } @@ -353,11 +325,9 @@ public function testRcptWithReturnPath() { $email->returnPath('pleasereply@cakephp.org', 'CakePHP Return'); $this->socket->expects($this->at(0))->method('write')->with("MAIL FROM:\r\n"); - $this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(2))->method('read')->will($this->returnValue("250 OK\r\n")); - $this->socket->expects($this->at(3))->method('write')->with("RCPT TO:\r\n"); - $this->socket->expects($this->at(4))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("250 OK\r\n")); + $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("250 OK\r\n")); + $this->socket->expects($this->at(2))->method('write')->with("RCPT TO:\r\n"); + $this->socket->expects($this->at(3))->method('read')->will($this->returnValue("250 OK\r\n")); $this->SmtpTransport->sendRcpt($email); } @@ -398,11 +368,9 @@ public function testSendData() { $data .= "\r\n\r\n.\r\n"; $this->socket->expects($this->at(0))->method('write')->with("DATA\r\n"); - $this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(2))->method('read')->will($this->returnValue("354 OK\r\n")); - $this->socket->expects($this->at(3))->method('write')->with($data); - $this->socket->expects($this->at(4))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("250 OK\r\n")); + $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("354 OK\r\n")); + $this->socket->expects($this->at(2))->method('write')->with($data); + $this->socket->expects($this->at(3))->method('read')->will($this->returnValue("250 OK\r\n")); $this->SmtpTransport->sendData($email); } @@ -443,20 +411,18 @@ public function testGetLastResponse() { $this->assertEmpty($this->SmtpTransport->getLastResponse()); $this->socket->expects($this->any())->method('connect')->will($this->returnValue(true)); - $this->socket->expects($this->at(0))->method('read')->will($this->returnValue(false)); $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n")); $this->socket->expects($this->at(2))->method('write')->with("EHLO localhost\r\n"); - $this->socket->expects($this->at(3))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(4))->method('read')->will($this->returnValue("250-PIPELINING\r\n")); - $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("250-SIZE 102400000\r\n")); - $this->socket->expects($this->at(6))->method('read')->will($this->returnValue("250-VRFY\r\n")); - $this->socket->expects($this->at(7))->method('read')->will($this->returnValue("250-ETRN\r\n")); - $this->socket->expects($this->at(8))->method('read')->will($this->returnValue("250-STARTTLS\r\n")); - $this->socket->expects($this->at(9))->method('read')->will($this->returnValue("250-AUTH PLAIN LOGIN\r\n")); - $this->socket->expects($this->at(10))->method('read')->will($this->returnValue("250-AUTH=PLAIN LOGIN\r\n")); - $this->socket->expects($this->at(11))->method('read')->will($this->returnValue("250-ENHANCEDSTATUSCODES\r\n")); - $this->socket->expects($this->at(12))->method('read')->will($this->returnValue("250-8BITMIME\r\n")); - $this->socket->expects($this->at(13))->method('read')->will($this->returnValue("250 DSN\r\n")); + $this->socket->expects($this->at(3))->method('read')->will($this->returnValue("250-PIPELINING\r\n")); + $this->socket->expects($this->at(4))->method('read')->will($this->returnValue("250-SIZE 102400000\r\n")); + $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("250-VRFY\r\n")); + $this->socket->expects($this->at(6))->method('read')->will($this->returnValue("250-ETRN\r\n")); + $this->socket->expects($this->at(7))->method('read')->will($this->returnValue("250-STARTTLS\r\n")); + $this->socket->expects($this->at(8))->method('read')->will($this->returnValue("250-AUTH PLAIN LOGIN\r\n")); + $this->socket->expects($this->at(9))->method('read')->will($this->returnValue("250-AUTH=PLAIN LOGIN\r\n")); + $this->socket->expects($this->at(10))->method('read')->will($this->returnValue("250-ENHANCEDSTATUSCODES\r\n")); + $this->socket->expects($this->at(11))->method('read')->will($this->returnValue("250-8BITMIME\r\n")); + $this->socket->expects($this->at(12))->method('read')->will($this->returnValue("250 DSN\r\n")); $this->SmtpTransport->connect(); $expected = array( @@ -479,11 +445,9 @@ public function testGetLastResponse() { $email->to('cake@cakephp.org', 'CakePHP'); $this->socket->expects($this->at(0))->method('write')->with("MAIL FROM:\r\n"); - $this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(2))->method('read')->will($this->returnValue("250 OK\r\n")); - $this->socket->expects($this->at(3))->method('write')->with("RCPT TO:\r\n"); - $this->socket->expects($this->at(4))->method('read')->will($this->returnValue(false)); - $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("250 OK\r\n")); + $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("250 OK\r\n")); + $this->socket->expects($this->at(2))->method('write')->with("RCPT TO:\r\n"); + $this->socket->expects($this->at(3))->method('read')->will($this->returnValue("250 OK\r\n")); $this->SmtpTransport->sendRcpt($email); From 84a15dc9df9c7d2e81c491a4b879f627999f536b Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 14 Feb 2017 14:12:38 -0500 Subject: [PATCH 10/13] Fix short-array usage. --- 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 af7a098eb2d..cdc56478488 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -49,7 +49,7 @@ public static function get(array $data, $path, $default = null) { if (is_string($path) || is_numeric($path)) { $parts = explode('.', $path); } elseif (is_bool($path) || $path === null) { - $parts = [$path]; + $parts = array($path); } else { if (!is_array($path)) { throw new InvalidArgumentException(__d('cake_dev', From 2304ca379a1098ad573024e3db64c3b342bab8f8 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Fri, 17 Feb 2017 16:59:35 +0100 Subject: [PATCH 11/13] PHPDoc fixes Found with Phan --- lib/Cake/Network/CakeResponse.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index c0141a53ffc..596bc46f0e6 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -806,8 +806,8 @@ public function disableCache() { /** * Sets the correct headers to instruct the client to cache the response. * - * @param string $since a valid time since the response text has not been modified - * @param string $time a valid time for cache expiry + * @param string|int $since a valid time since the response text has not been modified + * @param string|int $time a valid time for cache expiry * @return void */ public function cache($since, $time = '+1 day') { @@ -1067,7 +1067,7 @@ public function etag($tag = null, $weak = false) { * Returns a DateTime object initialized at the $time param and using UTC * as timezone * - * @param string|DateTime $time Valid time string or unix timestamp or DateTime object. + * @param DateTime|int|string $time Valid time string or unix timestamp or DateTime object. * @return DateTime */ protected function _getUTCDate($time = null) { From 3978f87c581357d8ee8ef088810aace2ffcefa0e Mon Sep 17 00:00:00 2001 From: kanonji Date: Tue, 28 Feb 2017 00:16:53 +0900 Subject: [PATCH 12/13] Stringify values to avoid trap of in_array() type juggling --- .../Test/Case/View/Helper/FormHelperTest.php | 54 +++++++++++++++++++ lib/Cake/View/Helper/FormHelper.php | 2 +- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 81dda0ea38b..7c9f70cc843 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -4979,6 +4979,60 @@ public function testSelectBoolean() { $this->assertTags($result, $expected); } +/** + * test that select() with numeric label of optiongroup. + * + * @return void + */ + public function testSelectOptionGroupWithNumericLabel() { + $options = array( + 1 => array( + 1 => '1Foo', + 2 => '2Bar', + 3 => '3Baz', + 4 => '1', + 5 => '2', + 6 => '3', + 7 => 1, + 8 => 2, + 9 => 3, + ), + 2 => array( + 11 => '1Foo', + 12 => '2Bar', + 13 => '3Baz', + 14 => '1', + 15 => '2', + 16 => '3', + 17 => 1, + 18 => 2, + 19 => 3, + ), + ); + $result = $this->Form->select('Model.field', $options, array('empty' => false)); + $expected = array( + 'select' => array('name' => 'data[Model][field]', 'id' => 'ModelField'), + array('optgroup' => array('label' => '1')), + array('option' => array('value' => '1')), '1Foo', '/option', + array('option' => array('value' => '2')), '2Bar', '/option', + array('option' => array('value' => '3')), '3Baz', '/option', + array('option' => array('value' => '6')), '3', '/option', + array('option' => array('value' => '9')), '3', '/option', + '/optgroup', + array('optgroup' => array('label' => '2')), + array('option' => array('value' => '11')), '1Foo', '/option', + array('option' => array('value' => '12')), '2Bar', '/option', + array('option' => array('value' => '13')), '3Baz', '/option', + array('option' => array('value' => '14')), '1', '/option', + array('option' => array('value' => '16')), '3', '/option', + array('option' => array('value' => '17')), '1', '/option', + array('option' => array('value' => '19')), '3', '/option', + '/optgroup', + '/select' + ); + $this->assertTags($result, $expected); + } + /** * test that select() with optiongroups listens to the escape param. * diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 9133a4c3fb5..0d6dd7dd503 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2832,7 +2832,7 @@ protected function _selectOptions($elements = array(), $parents = array(), $show } else { $select[] = $this->Html->useTag('optiongroupend'); } - $parents[] = $name; + $parents[] = (string)$name; } $select = array_merge($select, $this->_selectOptions( $title, $parents, $showParents, $attributes From 03e7fa0710b37f44bd1d90c4ecc8bf4d4bdded6d Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 28 Feb 2017 22:27:17 -0500 Subject: [PATCH 13/13] Update version number to 2.9.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 7e4c5d7b876..2cfeb3fd893 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.9.5 +2.9.6