Skip to content
This repository has been archived by the owner. It is now read-only.

Workaround for double-template rendering with forward() plug-in. #2206

Conversation

@demiankatz
Copy link
Contributor

@demiankatz demiankatz commented Aug 20, 2012

If a caller returns the value of $this->forward()->dispatch() in a controller action while the InjectViewModelListener is active, the same view model gets attached to the layout twice, and the PHP template will be rendered twice, wasting resources and possibly causing strange side effects. This commit detaches the problem listener before dispatching a forwarded action so that the output of dispatch() can be safely returned by the calling action. It also provides a generic, extensible mechanism for detaching other listeners in different use cases.

…ntroller action while the InjectViewModelListener is active, the same view model gets attached to the layout twice, and the PHP template will be rendered twice, wasting resources and possibly causing strange side effects. This commit detaches the problem listener before dispatching a forwarded action. It also provides a generic, extensible mechanism for detaching other listeners in different use cases.
@travisbot
Copy link

@travisbot travisbot commented Aug 20, 2012

This pull request passes (merged 0b8fc7a into 5dd58b8).

public function getListenersToDetach()
{
// If a blacklist has not been explicitly set, return the default:
if (is_null($this->listenersToDetach)) {
Copy link
Member

@weierophinney weierophinney Aug 20, 2012

The convention within the framework is to use "null === $this->listenersToDetach", or, if you despise yoda conditions, "$this->listenersToDetach === null", instead of is_null().

weierophinney added a commit that referenced this issue Aug 20, 2012
- Per comments on issue.
@weierophinney
Copy link
Member

@weierophinney weierophinney commented Aug 20, 2012

I took care of all suggestions above when merging.

@weierophinney weierophinney merged commit 0b8fc7a into zendframework:master Aug 20, 2012
1 check passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants