Dispatching to a good controller but wrong action triggers a Fatal Error #3186

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
@ThomasCantonnet
Contributor

ThomasCantonnet commented Dec 9, 2012

Fixes #3180

@@ -51,6 +51,9 @@ public function notFoundAction()
$event = $this->getEvent();
$routeMatch = $event->getRouteMatch();
+ if($response instanceof \Zend\Console\Response) {
+ return null;
+ }
$response->setStatusCode(404);
$routeMatch->setParam('action', 'not-found');

This comment has been minimized.

@weierophinney

weierophinney Dec 11, 2012

Member

I think the test is wrong. We still want the route match change; we simply want to not set the status code, unless we have an HTTP response.

@weierophinney

weierophinney Dec 11, 2012

Member

I think the test is wrong. We still want the route match change; we simply want to not set the status code, unless we have an HTTP response.

This comment has been minimized.

@ThomasCantonnet

ThomasCantonnet Dec 11, 2012

Contributor

Do we want to return a ViewModel ? I can move the routeMatch or conditionally set the status code + return the ViewModel on \Zend\Http\Response. Which one is preferable ?

@ThomasCantonnet

ThomasCantonnet Dec 11, 2012

Contributor

Do we want to return a ViewModel ? I can move the routeMatch or conditionally set the status code + return the ViewModel on \Zend\Http\Response. Which one is preferable ?

weierophinney added a commit that referenced this pull request Dec 11, 2012

[#3186] Only set status code if response is HTTP
- Inverted condition from original PR; only set status code if we have
  an HTTP request

weierophinney added a commit that referenced this pull request Dec 11, 2012

@ghost ghost assigned weierophinney Dec 11, 2012

@ThomasCantonnet

This comment has been minimized.

Show comment
Hide comment
@ThomasCantonnet

ThomasCantonnet Dec 16, 2012

Contributor

@weierophinney this fix now triggers a different fatal error:

PHP Fatal error: Call to undefined method Zend\View\Model\ViewModel::getResult() in Zend/Mvc/View/Console/DefaultRenderingStrategy.php on line 94

Fix for this is returning a ConsoleModel instead of ViewModel on Console\Response in Zend/Mvc/Controller/AbstractActionController.php. Want me to do another PR?

Contributor

ThomasCantonnet commented Dec 16, 2012

@weierophinney this fix now triggers a different fatal error:

PHP Fatal error: Call to undefined method Zend\View\Model\ViewModel::getResult() in Zend/Mvc/View/Console/DefaultRenderingStrategy.php on line 94

Fix for this is returning a ConsoleModel instead of ViewModel on Console\Response in Zend/Mvc/Controller/AbstractActionController.php. Want me to do another PR?

weierophinney added a commit to weierophinney/zendframework that referenced this pull request Dec 19, 2012

Better capabilities surrounding console notFoundAction
- Return a console response for non-HTTP response types; resolves comment noted
  in zendframework/zendframework#3186
@weierophinney

This comment has been minimized.

Show comment
Hide comment
@weierophinney

weierophinney Dec 19, 2012

Member

@h3daz #3254 fixes the issue you saw. :)

Member

weierophinney commented Dec 19, 2012

@h3daz #3254 fixes the issue you saw. :)

@ThomasCantonnet

This comment has been minimized.

Show comment
Hide comment
@ThomasCantonnet

ThomasCantonnet Dec 19, 2012

Contributor

@weierophinney beautiful :p

Contributor

ThomasCantonnet commented Dec 19, 2012

@weierophinney beautiful :p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment