Skip to content

Commit

Permalink
Merge branch 'master' into 2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Sep 29, 2012
2 parents 51245ce + 853d866 commit 59e948f
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 39 deletions.
1 change: 1 addition & 0 deletions lib/Cake/Cache/Engine/WincacheEngine.php
Expand Up @@ -183,6 +183,7 @@ public function groups() {
* @return boolean success
**/
public function clearGroup($group) {
$success = null;
wincache_ucache_inc($this->settings['prefix'] . $group, 1, $success);
return $success;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/Console/ShellDispatcher.php
Expand Up @@ -215,7 +215,8 @@ public function dispatch() {
return $Shell->main();
}
}
throw new MissingShellMethodException(array('shell' => $shell, 'method' => $arg));

throw new MissingShellMethodException(array('shell' => $shell, 'method' => $command));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Error/ExceptionRenderer.php
Expand Up @@ -295,11 +295,11 @@ protected function _outputMessageSafe($template) {
$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();
}
Expand Down
7 changes: 5 additions & 2 deletions lib/Cake/Model/Behavior/TranslateBehavior.php
Expand Up @@ -148,11 +148,14 @@ public function beforeFind(Model $Model, $query) {
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'])
) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Model.php
Expand Up @@ -3261,7 +3261,7 @@ public function joinModel($assoc, $keys = array()) {
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
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Network/Email/CakeEmail.php
Expand Up @@ -325,7 +325,7 @@ public function __construct($config = null) {
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');
}
Expand Down
57 changes: 40 additions & 17 deletions lib/Cake/Test/Case/Error/ExceptionRendererTest.php
Expand Up @@ -691,25 +691,49 @@ public function testMissingRenderSafe() {
$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.
*
Expand All @@ -719,32 +743,31 @@ public function testMissingSubdirRenderSafe() {
$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);
}

Expand Down
12 changes: 8 additions & 4 deletions lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
Expand Up @@ -411,14 +411,18 @@ public function testDomain() {
* @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']);
}

/**
Expand Down
22 changes: 11 additions & 11 deletions lib/Cake/Test/Case/Utility/ValidationTest.php
Expand Up @@ -1826,32 +1826,32 @@ public function testUrl() {
$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->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('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->assertFalse(Validation::url('http://this-domain-is-too-loooooong-by-icann-rules-maximum-length-is-63.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'));
Expand Down

0 comments on commit 59e948f

Please sign in to comment.