Merge branch '2.7' into 2.8

This commit is contained in:
mark_story 2015-12-20 21:59:43 -05:00
commit 37fe25909f
15 changed files with 97 additions and 48 deletions

View file

@ -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 test2;' -U postgres -d cakephp_test; fi"
- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE SCHEMA test3;' -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 - chmod -R 777 ./app/tmp
- sudo apt-get install lighttpd
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.3" ]] ; then pecl install timezonedb ; fi - 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 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" - sh -c "if [ '$PHPCS' = '1' ]; then ~/.composer/vendor/bin/phpcs --config-set installed_paths ~/.composer/vendor/cakephp/cakephp-codesniffer; fi"

View file

@ -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 There are a few guidelines that we need contributors to follow so that we have a
chance of keeping on top of things. 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 ## Getting Started
* Make sure you have a [GitHub account](https://github.com/signup/free). * Make sure you have a [GitHub account](https://github.com/signup/free).

View file

@ -403,6 +403,9 @@ class SchemaShell extends AppShell {
$this->out(); $this->out();
$this->out(__d('cake_console', 'Updating Database...')); $this->out(__d('cake_console', 'Updating Database...'));
$this->_run($contents, 'update', $Schema); $this->_run($contents, 'update', $Schema);
Configure::write('Cache.disable', false);
Cache::clear(false, '_cake_model_');
} }
$this->out(__d('cake_console', 'End update.')); $this->out(__d('cake_console', 'End update.'));

View file

@ -419,7 +419,7 @@ class AuthComponent extends Component {
} else { } else {
$url = $this->unauthorizedRedirect; $url = $this->unauthorizedRedirect;
} }
$controller->redirect($url, null, true); $controller->redirect($url);
return false; return false;
} }

View file

@ -478,6 +478,7 @@ class I18n {
* *
* @param string $filename Binary .mo file to load * @param string $filename Binary .mo file to load
* @return mixed Array of translations on success or false on failure * @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) { public static function loadMo($filename) {
$translations = false; $translations = false;
@ -486,7 +487,6 @@ class I18n {
// Binary files extracted makes non-standard local variables // Binary files extracted makes non-standard local variables
if ($data = file_get_contents($filename)) { if ($data = file_get_contents($filename)) {
$translations = array(); $translations = array();
$context = null;
$header = substr($data, 0, 20); $header = substr($data, 0, 20);
$header = unpack('L1magic/L1version/L1count/L1o_msg/L1o_trn', $header); $header = unpack('L1magic/L1version/L1count/L1o_msg/L1o_trn', $header);
extract($header); extract($header);
@ -496,6 +496,7 @@ class I18n {
$r = unpack("L1len/L1offs", substr($data, $o_msg + $n * 8, 8)); $r = unpack("L1len/L1offs", substr($data, $o_msg + $n * 8, 8));
$msgid = substr($data, $r["offs"], $r["len"]); $msgid = substr($data, $r["offs"], $r["len"]);
unset($msgid_plural); unset($msgid_plural);
$context = null;
if (strpos($msgid, "\x04") !== false) { if (strpos($msgid, "\x04") !== false) {
list($context, $msgid) = explode("\x04", $msgid); list($context, $msgid) = explode("\x04", $msgid);

View file

@ -129,10 +129,17 @@ class CakeSocket {
$this->disconnect(); $this->disconnect();
} }
$hasProtocol = strpos($this->config['host'], '://') !== false;
if ($hasProtocol) {
list($this->config['protocol'], $this->config['host']) = explode('://', $this->config['host']);
}
$scheme = null; $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'] . '://'; $scheme = $this->config['protocol'] . '://';
} }
if (!empty($this->config['proxy'])) {
$scheme = 'tcp://';
}
$host = $this->config['host']; $host = $this->config['host'];
if (isset($this->config['request']['uri']['host'])) { if (isset($this->config['request']['uri']['host'])) {
@ -185,6 +192,9 @@ class CakeSocket {
$this->config['request']['uri']['port'] . ' HTTP/1.1'; $this->config['request']['uri']['port'] . ' HTTP/1.1';
$req[] = 'Host: ' . $this->config['host']; $req[] = 'Host: ' . $this->config['host'];
$req[] = 'User-Agent: php proxy'; $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"); fwrite($this->connection, implode("\r\n", $req) . "\r\n\r\n");

View file

@ -340,9 +340,9 @@ class SmtpTransport extends AbstractTransport {
/** /**
* Protected method for sending data to SMTP connection * Protected method for sending data to SMTP connection
* *
* @param string $data data to be sent to SMTP server * @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 * @param string|bool $checkCode Code to check for in server response, false to skip
* @return void * @return string|null The matched code, or null if nothing matched
* @throws SocketException * @throws SocketException
*/ */
protected function _smtpSend($data, $checkCode = '250') { protected function _smtpSend($data, $checkCode = '250') {

View file

@ -668,6 +668,13 @@ class HttpSocket extends CakeSocket {
throw new SocketException(__d('cake_dev', 'The %s does not support proxy authentication.', $authClass)); throw new SocketException(__d('cake_dev', 'The %s does not support proxy authentication.', $authClass));
} }
call_user_func_array("$authClass::proxyAuthentication", array($this, &$this->_proxy)); 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');
}
}
} }
/** /**

View file

@ -2054,6 +2054,9 @@ class I18nTest extends CakeTestCase {
$this->assertSame("danspartij", __x('social gathering', 'ball')); $this->assertSame("danspartij", __x('social gathering', 'ball'));
$this->assertSame("balans", __('balance')); $this->assertSame("balans", __('balance'));
$this->assertSame("saldo", __x('money', 'balance')); $this->assertSame("saldo", __x('money', 'balance'));
// MO file is sorted by msgid, 'zoo' should be last
$this->assertSame("dierentuin", __('zoo'));
} }
/** /**

View file

@ -265,6 +265,24 @@ class CakeSocketTest extends CakeTestCase {
$this->Socket->enableCrypto('tls', 'client'); $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 * _connectSocketToSslTls
* *

View file

@ -19,6 +19,25 @@
App::uses('HttpSocket', 'Network/Http'); App::uses('HttpSocket', 'Network/Http');
App::uses('BasicAuthentication', '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 * BasicMethodTest class
* *
@ -60,4 +79,26 @@ class BasicAuthenticationTest extends CakeTestCase {
$this->assertEquals('Basic bWFyazpzZWNyZXQ=', $http->request['header']['Proxy-Authorization']); $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']));
}
} }

View file

@ -917,42 +917,6 @@ class ValidationTest extends CakeTestCase {
$this->assertFalse(Validation::comparison('0x02', '>=', 1.5), 'hex string data fails'); $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 * testCustom method
* *

View file

@ -26,4 +26,7 @@ msgstr "balans"
msgctxt "money" msgctxt "money"
msgid "balance" msgid "balance"
msgstr "saldo" msgstr "saldo"
msgid "zoo"
msgstr "dierentuin"

View file

@ -231,10 +231,6 @@ class Validation {
* @return bool Success * @return bool Success
*/ */
public static function comparison($check1, $operator = null, $check2 = null) { public static function comparison($check1, $operator = null, $check2 = null) {
if (is_array($check1)) {
extract($check1, EXTR_OVERWRITE);
}
if ((float)$check1 != $check1) { if ((float)$check1 != $check1) {
return false; return false;
} }