Zend Framework: Zend_Controller_Action Component Proposal
| Proposed Component Name | Zend_Controller_Action |
|---|---|
| Developer Notes | http://framework.zend.com/wiki/display/ZFDEV/Zend_Controller_Action |
| Proposers | My E-mail Address |
| Revision | 1.1 - 18 July 2006 - First revision (wiki revision: 5) |
Table of Contents
1. Overview
This is a simple suggestion for a modification to the _redirect member of Zend_Controller_Action.
I was attempting to write a simple logout procedure for some test code, and found that the logout redirect that used _redirect within a class, was failing with no evident output to redirect due to 'Headers already sent'
In the end it was whitespace at the end of my LogoutController that was causing the issue. However, the way I found it
was that using the PHP5 function headers_sent, I modified the code inside the library for Zend_Controller_Action to use the optional $file and $line variables to find where the header issue was being caused.
Perhaps this is something you might want to use in the _redirect function, since the output it gives upon failure can be used to help troubleshoot a very simple error which can plague the unwary coder for a fair while before discovering the issue, especially if the whitespace is hiding after the closing ?> tag in a Controller file as in my case.
2. References
3. Component Requirements, Constraints, and Acceptance Criteria
4. Dependencies on Other Framework Components
5. Theory of Operation
6. Milestones / Tasks
7. Class Index
- Zend_Controller_Action
3 Comments
comments.show.hideSep 20, 2006
Rob Allen
You could make _redirect() more robust to headers already sent issues by augmenting it to do something like:
replace:
with
Oct 10, 2006
Matthew Weier O'Phinney
There are several issues with this approach:
The OP's proposal is a simple solution that can be implemented quickly, and helps the developer find the root cause of the issue quickly.
Oct 11, 2006
Matthew Weier O'Phinney
This proposal is accepted and will be implemented by the Zend devteam.