Reset stop-propagation flag when triggering event #4147

Closed
wants to merge 3 commits into
from

Projects

None yet

1 participant

@weierophinney
Member

@macnibblet noticed that if an event listener on, say, the dispatch event called stopPropagation on the event, nothing was rendered in the response. On investigation, I discovered that the "stop propagation" flag on the MvcEvent was not being reset between different events that were being triggered. When triggering events in sequence, using the same event object, this is problematic, as the first listener in a subsequent trigger will be executed normally, but no others will be.

The solution is to reset the flag at the start of trigger (and triggerUntil). This PR does that, providing unit tests for the EventManager, and integration tests for the Application object.

weierophinney added some commits Mar 29, 2013
@weierophinney weierophinney Wrote test proving assertion
- Test adds listeners to each event; listener sets a flag to the value
  of the "stop propagation" flag of the event, and then in turn sets
  that flag to true.
- Ideally, the first listener should _never_ see the stopPropagation
  flag set to true; it should be false prior to triggering the event.
3832027
@weierophinney weierophinney Resolve issue with event propagation
- Better testing for event propagation issue
  - In the case of the route event returning early, a response was
    always returned by run(). Updated to use a data provider, and
    first test the route event, and then test with all other events.
- Solution was best implemented in the EventManager by setting the
  propagation flag prior to executing triggerListeners().
2d6910a
@weierophinney weierophinney Add tests to EventManager for propagation issue
- Tests that both trigger() and triggerUntil() will reset the
  stopPropagation flag as they start their work.
9faca29
@akrabat akrabat added a commit that referenced this pull request Mar 29, 2013
@akrabat akrabat Merge branch 'hotfix/4147' into develop
Forward port #4147
876a18f
@akrabat akrabat added a commit that closed this pull request Mar 29, 2013
@akrabat akrabat Merge branch 'hotfix/4147'
CLose #4147
ac9c3f9
@akrabat akrabat closed this in ac9c3f9 Mar 29, 2013
@gianarb gianarb pushed a commit to zendframework/zend-eventmanager that referenced this pull request May 15, 2015
@akrabat akrabat Merge branch 'hotfix/4147' 2963b07
@gianarb gianarb pushed a commit to zendframework/zend-eventmanager that referenced this pull request May 15, 2015
@akrabat akrabat Merge branch 'hotfix/4147' into develop 486ca02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment