ZF-7380: gotoReferer for Zend_Controller_Action_Helper_Redirector

Issue Type: New Feature Created: 2009-07-24T04:18:34.000+0000 Last Updated: 2012-11-20T20:53:17.000+0000 Status: Closed Fix version(s): Reporter: Markus (rockaut) Assignee: None Tags: - Zend_Controller

Related issues: Attachments:


It would be fine to have a function wich redirects you to the referer, like:

/** * Redirects to the refering page if one exists; * If not does nothing; * * $options is an optional associative array that can be used to control * redirect behaviour. The available option keys are: * - exit: boolean flag indicating whether or not to halt script execution when done * - prependBase: boolean flag indicating whether or not to prepend the base URL when a relative URL is provided * - code: integer HTTP status code to use with redirect. Should be between 300 and 307. * * @param array $options * @return void */ public function gotoReferer(array $options = array()) { if($this->getRequest() instanceof Zend_Controller_Request_Http) { $referer = $this->getRequest()->getHeader('REFERER'); $this->gotoUrl($referer, $options); } }


Posted by julien PAULI (doctorrock83) on 2009-07-24T13:05:08.000+0000

Please, note that referer might be not present in some cases. Advanced http clients can easilly play with it (spoof it), or simply suppress it

Posted by Markus (rockaut) on 2009-07-25T12:04:25.000+0000

Yes that's true for sure, but like in most cases if you are aware of security concerns it can be usefull.

Hmm, maybee if no referer is present it should be false returned or simply null. Don't know witch fits more for ZF.

Posted by Dolf Schimmel (Freeaqingme) (freak) on 2009-07-25T12:30:08.000+0000

I think it would be better to add a getReferer() method to Zend_Controller_Request_Http which would return null if the referer url could not be determined. Then you could just feed the url returned by that getReferer() method to the redirector action helper.

Btw, if the referer is always (on lighttpd, apache and IIS) in $_SERVER['HTTP_REFERER'] I think we don't need any of this at all.

Posted by Rob Allen (rob) on 2012-11-20T20:53:17.000+0000

Bulk change of all issues last updated before 1st January 2010 as "Won't Fix".

Feel free to re-open and provide a patch if you want to fix this issue.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.