diff --git a/lib/Cake/Cache/Engine/WincacheEngine.php b/lib/Cake/Cache/Engine/WincacheEngine.php index 542172c0c..8e81312ab 100644 --- a/lib/Cake/Cache/Engine/WincacheEngine.php +++ b/lib/Cake/Cache/Engine/WincacheEngine.php @@ -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; } diff --git a/lib/Cake/Console/ShellDispatcher.php b/lib/Cake/Console/ShellDispatcher.php index 6eb0e1624..162e8f508 100644 --- a/lib/Cake/Console/ShellDispatcher.php +++ b/lib/Cake/Console/ShellDispatcher.php @@ -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)); } /** diff --git a/lib/Cake/Error/ExceptionRenderer.php b/lib/Cake/Error/ExceptionRenderer.php index 6d7670b1f..9b402e4ed 100644 --- a/lib/Cake/Error/ExceptionRenderer.php +++ b/lib/Cake/Error/ExceptionRenderer.php @@ -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(); } diff --git a/lib/Cake/Model/Behavior/TranslateBehavior.php b/lib/Cake/Model/Behavior/TranslateBehavior.php index cf91c9495..47d7974de 100644 --- a/lib/Cake/Model/Behavior/TranslateBehavior.php +++ b/lib/Cake/Model/Behavior/TranslateBehavior.php @@ -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']) ) { diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 940c64a02..d1da12016 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -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 ); } diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index 61371dc8c..8f53cd217 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -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'); } diff --git a/lib/Cake/Test/Case/Error/ExceptionRendererTest.php b/lib/Cake/Test/Case/Error/ExceptionRendererTest.php index 57b41b41a..4f6969898 100644 --- a/lib/Cake/Test/Case/Error/ExceptionRendererTest.php +++ b/lib/Cake/Test/Case/Error/ExceptionRendererTest.php @@ -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); } diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index ae19b80f0..5c2a9de01 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -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']); } /** diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index 856bdac9f..56f935a1b 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -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'));