Skip to content

Commit

Permalink
Don't return true from view classes' render() method.
Browse files Browse the repository at this point in the history
It cause's Controller:render() to set the response body as `true`.

Refs #2780
  • Loading branch information
ADmad committed Feb 5, 2014
1 parent 2cd7212 commit d948925
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
6 changes: 2 additions & 4 deletions lib/Cake/Test/Case/View/MediaViewTest.php
Expand Up @@ -80,8 +80,7 @@ public function testRender() {
$this->MediaView->response->expects($this->once())
->method('send');

$result = $this->MediaView->render();
$this->assertTrue($result);
$this->MediaView->render();
}

/**
Expand Down Expand Up @@ -119,8 +118,7 @@ public function testRenderCachingAndName() {
$this->MediaView->response->expects($this->once())
->method('send');

$result = $this->MediaView->render();
$this->assertTrue($result);
$this->MediaView->render();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/View/ViewTest.php
Expand Up @@ -1024,7 +1024,7 @@ public function testRender() {
$this->assertRegExp("/<title>yo what up<\/title>/", $result);
$this->assertRegExp("/<p><a href=\"flash\">yo what up<\/a><\/p>/", $result);

$this->assertTrue($View->render(false, 'flash'));
$this->assertNull($View->render(false, 'flash'));

$this->PostsController->helpers = array('Session', 'Cache', 'Html');
$this->PostsController->constructClasses();
Expand Down
3 changes: 1 addition & 2 deletions lib/Cake/View/MediaView.php
Expand Up @@ -62,7 +62,7 @@ class MediaView extends View {
*
* @param string $view Not used
* @param string $layout Not used
* @return boolean
* @return void
*/
public function render($view = null, $layout = null) {
$name = $download = $id = $modified = $path = $cache = $mimeType = $compress = null;
Expand Down Expand Up @@ -94,7 +94,6 @@ public function render($view = null, $layout = null) {
$this->response->compress();
}
$this->response->send();
return true;
}

}
4 changes: 2 additions & 2 deletions lib/Cake/View/View.php
Expand Up @@ -445,12 +445,12 @@ public function elementExists($name) {
*
* @param string $view Name of view file to use
* @param string $layout Layout to use.
* @return string Rendered Element
* @return string|null Rendered content or null if content already rendered and returned earlier.
* @throws CakeException If there is an error in the view.
*/
public function render($view = null, $layout = null) {
if ($this->hasRendered) {
return true;
return;
}
$this->Blocks->set('content', '');

Expand Down

0 comments on commit d948925

Please sign in to comment.