diff --git a/.travis.yml b/.travis.yml index 69e87f0e9..297d3e631 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,6 @@ before_script: - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE SCHEMA test2;' -U postgres -d cakephp_test; fi" - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE SCHEMA test3;' -U postgres -d cakephp_test; fi" - chmod -R 777 ./app/tmp - - sudo apt-get install lighttpd - if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.3" ]] ; then pecl install timezonedb ; fi - sh -c "if [ '$PHPCS' = '1' ]; then composer global require 'cakephp/cakephp-codesniffer:1.*'; fi" - sh -c "if [ '$PHPCS' = '1' ]; then ~/.composer/vendor/bin/phpcs --config-set installed_paths ~/.composer/vendor/cakephp/cakephp-codesniffer; fi" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c991e2460..0917011e9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,6 +9,10 @@ CakePHP loves to welcome your contributions. There are several ways to help out: There are a few guidelines that we need contributors to follow so that we have a chance of keeping on top of things. +## Code of Conduct + +Help us keep CakePHP open and inclusive. Please read and follow our [Code of Conduct](https://github.com/cakephp/code-of-conduct/blob/master/CODE_OF_CONDUCT.md). + ## Getting Started * Make sure you have a [GitHub account](https://github.com/signup/free). diff --git a/lib/Cake/Console/Command/SchemaShell.php b/lib/Cake/Console/Command/SchemaShell.php index 8589d1238..a2ddfcc0a 100644 --- a/lib/Cake/Console/Command/SchemaShell.php +++ b/lib/Cake/Console/Command/SchemaShell.php @@ -403,6 +403,9 @@ class SchemaShell extends AppShell { $this->out(); $this->out(__d('cake_console', 'Updating Database...')); $this->_run($contents, 'update', $Schema); + + Configure::write('Cache.disable', false); + Cache::clear(false, '_cake_model_'); } $this->out(__d('cake_console', 'End update.')); diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index 56b6a06dd..b6e7c1231 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -419,7 +419,7 @@ class AuthComponent extends Component { } else { $url = $this->unauthorizedRedirect; } - $controller->redirect($url, null, true); + $controller->redirect($url); return false; } diff --git a/lib/Cake/I18n/I18n.php b/lib/Cake/I18n/I18n.php index 1ce5aae48..1b79fa2f8 100644 --- a/lib/Cake/I18n/I18n.php +++ b/lib/Cake/I18n/I18n.php @@ -478,6 +478,7 @@ class I18n { * * @param string $filename Binary .mo file to load * @return mixed Array of translations on success or false on failure + * @link https://www.gnu.org/software/gettext/manual/html_node/MO-Files.html */ public static function loadMo($filename) { $translations = false; @@ -486,7 +487,6 @@ class I18n { // Binary files extracted makes non-standard local variables if ($data = file_get_contents($filename)) { $translations = array(); - $context = null; $header = substr($data, 0, 20); $header = unpack('L1magic/L1version/L1count/L1o_msg/L1o_trn', $header); extract($header); @@ -496,6 +496,7 @@ class I18n { $r = unpack("L1len/L1offs", substr($data, $o_msg + $n * 8, 8)); $msgid = substr($data, $r["offs"], $r["len"]); unset($msgid_plural); + $context = null; if (strpos($msgid, "\x04") !== false) { list($context, $msgid) = explode("\x04", $msgid); diff --git a/lib/Cake/Network/CakeSocket.php b/lib/Cake/Network/CakeSocket.php index 2c8e01fa3..4d380ad2a 100644 --- a/lib/Cake/Network/CakeSocket.php +++ b/lib/Cake/Network/CakeSocket.php @@ -129,10 +129,17 @@ class CakeSocket { $this->disconnect(); } + $hasProtocol = strpos($this->config['host'], '://') !== false; + if ($hasProtocol) { + list($this->config['protocol'], $this->config['host']) = explode('://', $this->config['host']); + } $scheme = null; - if (!empty($this->config['protocol']) && strpos($this->config['host'], '://') === false && empty($this->config['proxy'])) { + if (!empty($this->config['protocol'])) { $scheme = $this->config['protocol'] . '://'; } + if (!empty($this->config['proxy'])) { + $scheme = 'tcp://'; + } $host = $this->config['host']; if (isset($this->config['request']['uri']['host'])) { @@ -185,6 +192,9 @@ class CakeSocket { $this->config['request']['uri']['port'] . ' HTTP/1.1'; $req[] = 'Host: ' . $this->config['host']; $req[] = 'User-Agent: php proxy'; + if (!empty($this->config['proxyauth'])) { + $req[] = 'Proxy-Authorization: ' . $this->config['proxyauth']; + } fwrite($this->connection, implode("\r\n", $req) . "\r\n\r\n"); diff --git a/lib/Cake/Network/Email/SmtpTransport.php b/lib/Cake/Network/Email/SmtpTransport.php index f37dadf99..64d0090b5 100644 --- a/lib/Cake/Network/Email/SmtpTransport.php +++ b/lib/Cake/Network/Email/SmtpTransport.php @@ -340,9 +340,9 @@ class SmtpTransport extends AbstractTransport { /** * Protected method for sending data to SMTP connection * - * @param string $data data to be sent to SMTP server - * @param string|bool $checkCode code to check for in server response, false to skip - * @return void + * @param string|null $data Data to be sent to SMTP server + * @param string|bool $checkCode Code to check for in server response, false to skip + * @return string|null The matched code, or null if nothing matched * @throws SocketException */ protected function _smtpSend($data, $checkCode = '250') { diff --git a/lib/Cake/Network/Http/HttpSocket.php b/lib/Cake/Network/Http/HttpSocket.php index 0356391b8..308487094 100644 --- a/lib/Cake/Network/Http/HttpSocket.php +++ b/lib/Cake/Network/Http/HttpSocket.php @@ -668,6 +668,13 @@ class HttpSocket extends CakeSocket { throw new SocketException(__d('cake_dev', 'The %s does not support proxy authentication.', $authClass)); } call_user_func_array("$authClass::proxyAuthentication", array($this, &$this->_proxy)); + + if (!empty($this->request['header']['Proxy-Authorization'])) { + $this->config['proxyauth'] = $this->request['header']['Proxy-Authorization']; + if ($this->request['uri']['scheme'] === 'https') { + $this->request['header'] = Hash::remove($this->request['header'], 'Proxy-Authorization'); + } + } } /** diff --git a/lib/Cake/Test/Case/I18n/I18nTest.php b/lib/Cake/Test/Case/I18n/I18nTest.php index faac0e069..51ab95259 100644 --- a/lib/Cake/Test/Case/I18n/I18nTest.php +++ b/lib/Cake/Test/Case/I18n/I18nTest.php @@ -2054,6 +2054,9 @@ class I18nTest extends CakeTestCase { $this->assertSame("danspartij", __x('social gathering', 'ball')); $this->assertSame("balans", __('balance')); $this->assertSame("saldo", __x('money', 'balance')); + + // MO file is sorted by msgid, 'zoo' should be last + $this->assertSame("dierentuin", __('zoo')); } /** diff --git a/lib/Cake/Test/Case/Network/CakeSocketTest.php b/lib/Cake/Test/Case/Network/CakeSocketTest.php index d68774fe0..e93882d06 100644 --- a/lib/Cake/Test/Case/Network/CakeSocketTest.php +++ b/lib/Cake/Test/Case/Network/CakeSocketTest.php @@ -265,6 +265,24 @@ class CakeSocketTest extends CakeTestCase { $this->Socket->enableCrypto('tls', 'client'); } +/** + * Test that protocol in the host doesn't cause cert errors. + * + * @return void + */ + public function testConnectProtocolInHost() { + $this->skipIf(!extension_loaded('openssl'), 'OpenSSL is not enabled cannot test SSL.'); + $configSslTls = array('host' => 'ssl://smtp.gmail.com', 'port' => 465, 'timeout' => 5); + $socket = new CakeSocket($configSslTls); + try { + $socket->connect(); + $this->assertEquals('smtp.gmail.com', $socket->config['host']); + $this->assertEquals('ssl', $socket->config['protocol']); + } catch (SocketException $e) { + $this->markTestSkipped('Cannot test network, skipping.'); + } + } + /** * _connectSocketToSslTls * diff --git a/lib/Cake/Test/Case/Network/Http/BasicAuthenticationTest.php b/lib/Cake/Test/Case/Network/Http/BasicAuthenticationTest.php index f7b4d6109..7ae8349b3 100644 --- a/lib/Cake/Test/Case/Network/Http/BasicAuthenticationTest.php +++ b/lib/Cake/Test/Case/Network/Http/BasicAuthenticationTest.php @@ -19,6 +19,25 @@ App::uses('HttpSocket', 'Network/Http'); App::uses('BasicAuthentication', 'Network/Http'); +/** + * class TestSslHttpSocket + * + * @package Cake.Test.Case.Network.Http + */ +class TestSslHttpSocket extends HttpSocket { + +/** + * testSetProxy method + * + * @return void + */ + public function testSetProxy($proxy = null) { + $this->_proxy = $proxy; + $this->_setProxy(); + } + +} + /** * BasicMethodTest class * @@ -60,4 +79,26 @@ class BasicAuthenticationTest extends CakeTestCase { $this->assertEquals('Basic bWFyazpzZWNyZXQ=', $http->request['header']['Proxy-Authorization']); } +/** + * testProxyAuthenticationSsl method + * + * @return void + */ + public function testProxyAuthenticationSsl() { + $http = new TestSslHttpSocket(); + $http->request['uri']['scheme'] = 'https'; + $proxy = array( + 'host' => 'localhost', + 'port' => 3128, + 'method' => 'Basic', + 'user' => 'mark', + 'pass' => 'secret' + ); + + $http->testSetProxy($proxy); + + $this->assertEquals('Basic bWFyazpzZWNyZXQ=', $http->config['proxyauth']); + $this->assertFalse(isset($http->request['header']['Proxy-Authorization'])); + } + } diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index 21bb3acb1..8b326f166 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -917,42 +917,6 @@ class ValidationTest extends CakeTestCase { $this->assertFalse(Validation::comparison('0x02', '>=', 1.5), 'hex string data fails'); } -/** - * testComparisonAsArray method - * - * @return void - */ - public function testComparisonAsArray() { - $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => 'is greater', 'check2' => 6))); - $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => '>', 'check2' => 6))); - $this->assertTrue(Validation::comparison(array('check1' => 6, 'operator' => 'is less', 'check2' => 7))); - $this->assertTrue(Validation::comparison(array('check1' => 6, 'operator' => '<', 'check2' => 7))); - $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => 'greater or equal', 'check2' => 7))); - $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => '>=', 'check2' => 7))); - $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => 'greater or equal', 'check2' => 6))); - $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => '>=', 'check2' => 6))); - $this->assertTrue(Validation::comparison(array('check1' => 6, 'operator' => 'less or equal', 'check2' => 7))); - $this->assertTrue(Validation::comparison(array('check1' => 6, 'operator' => '<=', 'check2' => 7))); - $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => 'equal to', 'check2' => 7))); - $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => '==', 'check2' => 7))); - $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => 'not equal', 'check2' => 6))); - $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => '!=', 'check2' => 6))); - $this->assertFalse(Validation::comparison(array('check1' => 6, 'operator' => 'is greater', 'check2' => 7))); - $this->assertFalse(Validation::comparison(array('check1' => 6, 'operator' => '>', 'check2' => 7))); - $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => 'is less', 'check2' => 6))); - $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => '<', 'check2' => 6))); - $this->assertFalse(Validation::comparison(array('check1' => 6, 'operator' => 'greater or equal', 'check2' => 7))); - $this->assertFalse(Validation::comparison(array('check1' => 6, 'operator' => '>=', 'check2' => 7))); - $this->assertFalse(Validation::comparison(array('check1' => 6, 'operator' => 'greater or equal', 'check2' => 7))); - $this->assertFalse(Validation::comparison(array('check1' => 6, 'operator' => '>=', 'check2' => 7))); - $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => 'less or equal', 'check2' => 6))); - $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => '<=', 'check2' => 6))); - $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => 'equal to', 'check2' => 6))); - $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => '==', 'check2' => 6))); - $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => 'not equal', 'check2' => 7))); - $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => '!=', 'check2' => 7))); - } - /** * testCustom method * diff --git a/lib/Cake/Test/test_app/Locale/nld/LC_MESSAGES/default.po b/lib/Cake/Test/test_app/Locale/nld/LC_MESSAGES/default.po index dfee4f93e..9bfcc2e4b 100644 --- a/lib/Cake/Test/test_app/Locale/nld/LC_MESSAGES/default.po +++ b/lib/Cake/Test/test_app/Locale/nld/LC_MESSAGES/default.po @@ -26,4 +26,7 @@ msgstr "balans" msgctxt "money" msgid "balance" -msgstr "saldo" \ No newline at end of file +msgstr "saldo" + +msgid "zoo" +msgstr "dierentuin" 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 index bb89fa6e9..83a8e6273 100644 Binary files a/lib/Cake/Test/test_app/Locale/nld_mo/LC_MESSAGES/default.mo and b/lib/Cake/Test/test_app/Locale/nld_mo/LC_MESSAGES/default.mo differ diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index 83a05dcea..2f20d2739 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -231,10 +231,6 @@ class Validation { * @return bool Success */ public static function comparison($check1, $operator = null, $check2 = null) { - if (is_array($check1)) { - extract($check1, EXTR_OVERWRITE); - } - if ((float)$check1 != $check1) { return false; }