Merge branch 'master' into 2.6

This commit is contained in:
mark_story 2014-11-29 22:00:00 -05:00
commit 543f05e3d0
14 changed files with 81 additions and 32 deletions

View file

@ -107,7 +107,11 @@ class MemcachedEngine extends CacheEngine {
return true;
}
$this->_Memcached = new Memcached($this->settings['persistent'] ? (string)$this->settings['persistent'] : null);
if (!$this->settings['persistent']) {
$this->_Memcached = new Memcached();
} else {
$this->_Memcached = new Memcached((string)$this->settings['persistent']);
}
$this->_setOptions();
if (count($this->_Memcached->getServerList())) {

View file

@ -354,8 +354,8 @@ class Postgres extends DboSource {
if ($this->execute('DELETE FROM ' . $this->fullTableName($table))) {
if (isset($this->_sequenceMap[$table]) && $reset != true) {
foreach ($this->_sequenceMap[$table] as $sequence) {
list($schema, $sequence) = explode('.', $sequence);
$this->_execute("ALTER SEQUENCE \"{$schema}\".\"{$sequence}\" RESTART WITH 1");
$quoted = $this->name($sequence);
$this->_execute("ALTER SEQUENCE {$quoted} RESTART WITH 1");
}
}
return true;

View file

@ -1510,7 +1510,9 @@ class CakeResponse {
protected function _flushBuffer() {
//@codingStandardsIgnoreStart
@flush();
@ob_flush();
if (ob_get_level()) {
@ob_flush();
}
//@codingStandardsIgnoreEnd
}

View file

@ -1359,7 +1359,7 @@ class CakeEmail {
$cut = ($wrapLength == CakeEmail::LINE_LENGTH_MUST);
foreach ($lines as $line) {
if (empty($line)) {
if (empty($line) && $line !== '0') {
$formatted[] = '';
continue;
}

View file

@ -907,11 +907,10 @@ class HttpSocket extends CakeSocket {
* Builds a request line according to HTTP/1.1 specs. Activate quirks mode to work outside specs.
*
* @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
* @throws SocketException
*/
protected function _buildRequestLine($request = array(), $versionToken = 'HTTP/1.1') {
protected function _buildRequestLine($request = array()) {
$asteriskMethods = array('OPTIONS');
if (is_string($request)) {
@ -937,7 +936,8 @@ class HttpSocket extends CakeSocket {
if (!$this->quirksMode && $request['uri'] === '*' && !in_array($request['method'], $asteriskMethods)) {
throw new SocketException(__d('cake_dev', 'HttpSocket::_buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.', implode(',', $asteriskMethods)));
}
return $request['method'] . ' ' . $request['uri'] . ' ' . $versionToken . "\r\n";
$version = isset($request['version']) ? $request['version'] : '1.1';
return $request['method'] . ' ' . $request['uri'] . ' HTTP/' . $version . "\r\n";
}
/**

View file

@ -221,28 +221,29 @@ class HttpSocketResponse implements ArrayAccess {
$chunkLength = null;
while ($chunkLength !== 0) {
if (!preg_match('/^([0-9a-f]+) *(?:;(.+)=(.+))?(?:\r\n|\n)/iU', $body, $match)) {
throw new SocketException(__d('cake_dev', 'HttpSocket::_decodeChunkedBody - Could not parse malformed chunk.'));
if (!preg_match('/^([0-9a-f]+)[ ]*(?:;(.+)=(.+))?(?:\r\n|\n)/iU', $body, $match)) {
// Handle remaining invalid data as one big chunk.
preg_match('/^(.*?)\r\n/', $body, $invalidMatch);
$length = isset($invalidMatch[1]) ? strlen($invalidMatch[1]) : 0;
$match = array(
0 => '',
1 => dechex($length)
);
}
$chunkSize = 0;
$hexLength = 0;
$chunkExtensionValue = '';
if (isset($match[0])) {
$chunkSize = $match[0];
}
if (isset($match[1])) {
$hexLength = $match[1];
}
if (isset($match[3])) {
$chunkExtensionValue = $match[3];
}
$body = substr($body, strlen($chunkSize));
$chunkLength = hexdec($hexLength);
$chunk = substr($body, 0, $chunkLength);
$decodedBody .= $chunk;
if ($chunkLength !== 0) {
$body = substr($body, strlen($chunkSize));
$decodedBody .= substr($body, 0, $chunkLength);
if ($chunkLength) {
$body = substr($body, $chunkLength + strlen("\r\n"));
}
}

View file

@ -2416,6 +2416,25 @@ HTML;
$this->assertEquals($expected, $result['message']);
}
/**
* testZeroOnlyLinesNotBeingEmptied()
*
* @return void
*/
public function testZeroOnlyLinesNotBeingEmptied() {
$message = "Lorem\r\n0\r\n0\r\nipsum";
$this->CakeEmail->reset();
$this->CakeEmail->transport('Debug');
$this->CakeEmail->from('cake@cakephp.org');
$this->CakeEmail->to('cake@cakephp.org');
$this->CakeEmail->subject('Wordwrap Test');
$this->CakeEmail->config(array('empty'));
$result = $this->CakeEmail->send($message);
$expected = "{$message}\r\n\r\n";
$this->assertEquals($expected, $result['message']);
}
/**
* CakeEmailTest::assertLineLengths()
*

View file

@ -15,7 +15,6 @@
* @since CakePHP(tm) v 1.2.0.4206
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('HttpResponse', 'Network/Http');
/**
@ -453,12 +452,13 @@ class HttpResponseTest extends CakeTestCase {
/**
* testDecodeChunkedBodyError method
*
* @expectedException SocketException
* @return void
*/
public function testDecodeChunkedBodyError() {
$encoded = "19\r\nThis is a chunked message\r\nE\r\n\nThat is cool\n\r\n";
$this->HttpResponse->decodeChunkedBody($encoded);
$result = $this->HttpResponse->decodeChunkedBody($encoded);
$expected = "This is a chunked message\nThat is cool\n";
$this->assertEquals($expected, $result['body']);
}
/**

View file

@ -138,8 +138,8 @@ class TestHttpSocket extends HttpSocket {
* @param string $versionToken The version token to use, defaults to HTTP/1.1
* @return string Request line
*/
public function buildRequestLine($request = array(), $versionToken = 'HTTP/1.1') {
return parent::_buildRequestLine($request, $versionToken);
public function buildRequestLine($request = array()) {
return parent::_buildRequestLine($request);
}
/**
@ -529,6 +529,7 @@ class HttpSocketTest extends CakeTestCase {
),
array(
'request' => array(
'version' => '1.0',
'method' => 'POST',
'uri' => 'https://www.cakephp.org/posts/add',
'body' => array('name' => 'HttpSocket-is-released', 'date' => 'today'),
@ -536,6 +537,8 @@ class HttpSocketTest extends CakeTestCase {
),
'expectation' => array(
'request' => array(
'version' => '1.0',
'line' => "POST /posts/add HTTP/1.0\r\n",
'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 38\r\nCookie: foo=bar\r\n",
'cookies' => array(
'foo' => array('value' => 'bar'),
@ -1297,9 +1300,6 @@ class HttpSocketTest extends CakeTestCase {
$r = $this->Socket->buildRequestLine($request);
$this->assertEquals("GET /search?q=socket HTTP/1.1\r\n", $r);
$r = $this->Socket->buildRequestLine($request, 'CAKE-HTTP/0.1');
$this->assertEquals("GET /search?q=socket CAKE-HTTP/0.1\r\n", $r);
$request = array('method' => 'OPTIONS', 'uri' => '*');
$r = $this->Socket->buildRequestLine($request);
$this->assertEquals("OPTIONS * HTTP/1.1\r\n", $r);
@ -1311,6 +1311,17 @@ class HttpSocketTest extends CakeTestCase {
$r = $this->Socket->buildRequestLine("GET * HTTP/1.1\r\n");
$this->assertEquals("GET * HTTP/1.1\r\n", $r);
$request = array(
'version' => '1.0',
'method' => 'GET',
'uri' => array(
'path' => '/search',
'query' => array('q' => 'socket')
)
);
$r = $this->Socket->buildRequestLine($request);
$this->assertEquals("GET /search?q=socket HTTP/1.0\r\n", $r);
}
/**

View file

@ -15,7 +15,9 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
require_once 'PHPUnit/TextUI/TestRunner.php';
if (!defined('__PHPUNIT_PHAR__')) {
require_once 'PHPUnit/TextUI/TestRunner.php';
}
App::uses('CakeFixtureManager', 'TestSuite/Fixture');

View file

@ -16,7 +16,9 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
require_once 'PHPUnit/TextUI/Command.php';
if (!defined('__PHPUNIT_PHAR__')) {
require_once 'PHPUnit/TextUI/Command.php';
}
App::uses('CakeTestRunner', 'TestSuite');
App::uses('CakeTestLoader', 'TestSuite');

View file

@ -151,6 +151,12 @@ class CakeTestSuiteDispatcher {
} elseif (is_dir($vendor . DS . 'PHPUnit')) {
ini_set('include_path', $vendor . PATH_SEPARATOR . ini_get('include_path'));
break;
} elseif (is_file($vendor . DS . 'phpunit.phar')) {
$backup = $GLOBALS['_SERVER']['SCRIPT_NAME'];
$GLOBALS['_SERVER']['SCRIPT_NAME'] = '-';
$included = include_once $vendor . DS . 'phpunit.phar';
$GLOBALS['_SERVER']['SCRIPT_NAME'] = $backup;
return $included;
}
}
include 'PHPUnit' . DS . 'Autoload.php';

View file

@ -15,7 +15,9 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
require_once 'PHPUnit/TextUI/ResultPrinter.php';
if (!defined('__PHPUNIT_PHAR__')) {
require_once 'PHPUnit/TextUI/ResultPrinter.php';
}
/**
* CakeBaseReporter contains common reporting features used in the CakePHP Test suite

View file

@ -148,6 +148,8 @@ App::uses('Cache', 'Cache');
App::uses('Object', 'Core');
App::uses('Multibyte', 'I18n');
App::$bootstrapping = true;
/**
* Full URL prefix
*/
@ -170,8 +172,6 @@ Configure::write('App.imageBaseUrl', IMAGES_URL);
Configure::write('App.cssBaseUrl', CSS_URL);
Configure::write('App.jsBaseUrl', JS_URL);
App::$bootstrapping = true;
Configure::bootstrap(isset($boot) ? $boot : true);
if (function_exists('mb_internal_encoding')) {