Merge branch 'master' into 2.3

This commit is contained in:
mark_story 2012-09-28 21:20:24 -04:00
commit 59e948fb1b
9 changed files with 76 additions and 44 deletions

View file

@ -183,6 +183,7 @@ class WincacheEngine extends CacheEngine {
* @return boolean success
**/
public function clearGroup($group) {
$success = null;
wincache_ucache_inc($this->settings['prefix'] . $group, 1, $success);
return $success;
}

View file

@ -215,7 +215,8 @@ class ShellDispatcher {
return $Shell->main();
}
}
throw new MissingShellMethodException(array('shell' => $shell, 'method' => $arg));
throw new MissingShellMethodException(array('shell' => $shell, 'method' => $command));
}
/**

View file

@ -295,11 +295,11 @@ class ExceptionRenderer {
$this->controller->layoutPath = null;
$this->controller->subDir = null;
$this->controller->viewPath = 'Errors/';
$this->controller->viewClass = 'View';
$this->controller->layout = 'error';
$this->controller->helpers = array('Form', 'Html', 'Session');
$this->controller->render($template);
$view = new View($this->controller);
$this->controller->response->body($view->render($template, 'error'));
$this->controller->response->type('html');
$this->controller->response->send();
}

View file

@ -148,11 +148,14 @@ class TranslateBehavior extends ModelBehavior {
if (empty($query['fields'])) {
$addFields = $fields;
} elseif (is_array($query['fields'])) {
$isAllFields = (
in_array($Model->alias . '.' . '*', $query['fields']) ||
in_array($Model->escapeField('*'), $query['fields'])
);
foreach ($fields as $key => $value) {
$field = (is_numeric($key)) ? $value : $key;
if (
in_array($Model->escapeField('*'), $query['fields']) ||
$isAllFields ||
in_array($Model->alias . '.' . $field, $query['fields']) ||
in_array($field, $query['fields'])
) {

View file

@ -3261,7 +3261,7 @@ class Model extends Object implements CakeEventListener {
return array($with, array_unique(array_merge($assoc[$with], $keys)));
}
trigger_error(
__d('cake_dev', 'Invalid join model settings in %s', $model->alias),
__d('cake_dev', 'Invalid join model settings in %s. The association parameter has the wrong type, expecting a string or array, but was passed type: %s', $this->alias, gettype($assoc)),
E_USER_WARNING
);
}

View file

@ -325,7 +325,7 @@ class CakeEmail {
if ($this->_appCharset !== null) {
$this->charset = $this->_appCharset;
}
$this->_domain = env('HTTP_HOST');
$this->_domain = preg_replace('/\:\d+$/', '', env('HTTP_HOST'));
if (empty($this->_domain)) {
$this->_domain = php_uname('n');
}

View file

@ -691,25 +691,49 @@ class ExceptionRendererTest extends CakeTestCase {
$exception = new MissingHelperException(array('class' => 'Fail'));
$ExceptionRenderer = new ExceptionRenderer($exception);
$ExceptionRenderer->controller = $this->getMock('Controller');
$ExceptionRenderer->controller = $this->getMock('Controller', array('render'));
$ExceptionRenderer->controller->helpers = array('Fail', 'Boom');
$ExceptionRenderer->controller->request = $this->getMock('CakeRequest');
$ExceptionRenderer->controller->expects($this->at(2))
$ExceptionRenderer->controller->expects($this->at(0))
->method('render')
->with('missingHelper')
->will($this->throwException($exception));
$ExceptionRenderer->controller->expects($this->at(4))
->method('render')
->with('error500')
->will($this->returnValue(true));
$response = $this->getMock('CakeResponse');
$response->expects($this->once())
->method('body')
->with($this->stringContains('Helper class Fail'));
$ExceptionRenderer->controller->response = $this->getMock('CakeResponse');
$ExceptionRenderer->controller->response = $response;
$ExceptionRenderer->render();
sort($ExceptionRenderer->controller->helpers);
$this->assertEquals(array('Form', 'Html', 'Session'), $ExceptionRenderer->controller->helpers);
}
/**
* Test that exceptions in beforeRender() are handled by outputMessageSafe
*
* @return void
*/
public function testRenderExceptionInBeforeRender() {
$exception = new NotFoundException('Not there, sorry');
$ExceptionRenderer = new ExceptionRenderer($exception);
$ExceptionRenderer->controller = $this->getMock('Controller', array('beforeRender'));
$ExceptionRenderer->controller->request = $this->getMock('CakeRequest');
$ExceptionRenderer->controller->expects($this->any())
->method('beforeRender')
->will($this->throwException($exception));
$response = $this->getMock('CakeResponse');
$response->expects($this->once())
->method('body')
->with($this->stringContains('Not there, sorry'));
$ExceptionRenderer->controller->response = $response;
$ExceptionRenderer->render();
}
/**
* Test that missing subDir/layoutPath don't cause other fatal errors.
*
@ -719,32 +743,31 @@ class ExceptionRendererTest extends CakeTestCase {
$exception = new NotFoundException();
$ExceptionRenderer = new ExceptionRenderer($exception);
$ExceptionRenderer->controller = $this->getMock('Controller');
$ExceptionRenderer->controller = $this->getMock('Controller', array('render'));
$ExceptionRenderer->controller->helpers = array('Fail', 'Boom');
$ExceptionRenderer->controller->layoutPath = 'json';
$ExceptionRenderer->controller->subDir = 'json';
$ExceptionRenderer->controller->viewClass = 'Json';
$ExceptionRenderer->controller->request = $this->getMock('CakeRequest');
$ExceptionRenderer->controller->expects($this->at(1))
$ExceptionRenderer->controller->expects($this->once())
->method('render')
->with('error400')
->will($this->throwException($exception));
$ExceptionRenderer->controller->expects($this->at(3))
->method('render')
->with('error500')
->will($this->returnValue(true));
$ExceptionRenderer->controller->response = $this->getMock('CakeResponse');
$ExceptionRenderer->controller->response->expects($this->once())
$response = $this->getMock('CakeResponse');
$response->expects($this->once())
->method('body')
->with($this->stringContains('Not Found'));
$response->expects($this->once())
->method('type')
->with('html');
$ExceptionRenderer->controller->response = $response;
$ExceptionRenderer->render();
$this->assertEquals('', $ExceptionRenderer->controller->layoutPath);
$this->assertEquals('', $ExceptionRenderer->controller->subDir);
$this->assertEquals('View', $ExceptionRenderer->controller->viewClass);
$this->assertEquals('Errors/', $ExceptionRenderer->controller->viewPath);
}

View file

@ -411,14 +411,18 @@ class CakeEmailTest extends CakeTestCase {
* @return void
*/
public function testMessageIdWithDomain() {
$result = $this->CakeEmail->getHeaders();
$expected = '@' . (env('HTTP_HOST') ? env('HTTP_HOST') : php_uname('n')) . '>';
$this->assertTextContains($expected, $result['Message-ID']);
$this->CakeEmail->domain('example.org');
$result = $this->CakeEmail->getHeaders();
$expected = '@example.org>';
$this->assertTextContains($expected, $result['Message-ID']);
$_SERVER['HTTP_HOST'] = 'example.org';
$result = $this->CakeEmail->getHeaders();
$this->assertTextContains('example.org', $result['Message-ID']);
$_SERVER['HTTP_HOST'] = 'example.org:81';
$result = $this->CakeEmail->getHeaders();
$this->assertTextNotContains(':81', $result['Message-ID']);
}
/**

View file

@ -1826,32 +1826,32 @@ class ValidationTest extends CakeTestCase {
$this->assertTrue(Validation::url('ftp://cakephp.org/pub/cake'));
$this->assertTrue(Validation::url('ftp://192.168.0.1/pub/cake'));
$this->assertTrue(Validation::url('sftp://192.168.0.1/pub/cake'));
$this->assertFalse(Validation::url('ftps://256.168.0.1/pub/cake'));
$this->assertFalse(Validation::url('ftp://256.168.0.1/pub/cake'));
$this->assertTrue(Validation::url('https://my.domain.com/gizmo/app?class=MySip;proc=start'));
$this->assertTrue(Validation::url('www.domain.tld'));
$this->assertTrue(Validation::url('http://123456789112345678921234567893123456789412345678951234567896123.com'));
$this->assertTrue(Validation::url('http://www.domain.com/blogs/index.php?blog=6&tempskin=_rss2'));
$this->assertTrue(Validation::url('http://www.domain.com/blogs/parenth()eses.php'));
$this->assertTrue(Validation::url('http://www.domain.com/index.php?get=params&get2=params'));
$this->assertTrue(Validation::url('http://www.domain.com/ndex.php?get=params&get2=params#anchor'));
$this->assertTrue(Validation::url('http://www.domain.com/real%20url%20encodeing'));
$this->assertTrue(Validation::url('http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science)'));
$this->assertTrue(Validation::url('http://www.cakephp.org', true));
$this->assertTrue(Validation::url('http://example.com/~userdir/'));
$this->assertTrue(Validation::url('http://underscore_subdomain.example.org'));
$this->assertTrue(Validation::url('http://_jabber._tcp.gmail.com'));
$this->assertFalse(Validation::url('ftps://256.168.0.1/pub/cake'));
$this->assertFalse(Validation::url('ftp://256.168.0.1/pub/cake'));
$this->assertFalse(Validation::url('http://w_w.domain.co_m'));
$this->assertFalse(Validation::url('http://www.domain.12com'));
$this->assertFalse(Validation::url('http://www.domain.longttldnotallowed'));
$this->assertFalse(Validation::url('http://www.-invaliddomain.tld'));
$this->assertFalse(Validation::url('http://www.domain.-invalidtld'));
$this->assertTrue(Validation::url('http://123456789112345678921234567893123456789412345678951234567896123.com'));
$this->assertFalse(Validation::url('http://this-domain-is-too-loooooong-by-icann-rules-maximum-length-is-63.com'));
$this->assertTrue(Validation::url('http://www.domain.com/blogs/index.php?blog=6&tempskin=_rss2'));
$this->assertTrue(Validation::url('http://www.domain.com/blogs/parenth()eses.php'));
$this->assertTrue(Validation::url('http://www.domain.com/index.php?get=params&get2=params'));
$this->assertTrue(Validation::url('http://www.domain.com/ndex.php?get=params&get2=params#anchor'));
$this->assertFalse(Validation::url('http://www.domain.com/fakeenco%ode'));
$this->assertTrue(Validation::url('http://www.domain.com/real%20url%20encodeing'));
$this->assertTrue(Validation::url('http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science)'));
$this->assertFalse(Validation::url('http://en.(wikipedia).org/'));
$this->assertFalse(Validation::url('www.cakephp.org', true));
$this->assertTrue(Validation::url('http://www.cakephp.org', true));
$this->assertTrue(Validation::url('http://example.com/~userdir/'));
$this->assertTrue(Validation::url('http://underscore_subdomain.example.org'));
$this->assertTrue(Validation::url('http://_jabber._tcp.gmail.com'));
$this->assertFalse(Validation::url('http://www.underscore_domain.org'));
$this->assertFalse(Validation::url('http://_jabber._tcp.g_mail.com'));
$this->assertFalse(Validation::url('http://en.(wikipedia).org/'));
$this->assertFalse(Validation::url('http://www.domain.com/fakeenco%ode'));
$this->assertFalse(Validation::url('www.cakephp.org', true));
$this->assertTrue(Validation::url('http://example.com/~userdir/subdir/index.html'));
$this->assertTrue(Validation::url('http://www.zwischenraume.de'));