Ticket #600 (closed Patch: fixed)
Inconsitent Behaviour in Event Class
| Reported by: | allain | Owned by: | Shadowhand |
|---|---|---|---|
| Priority: | minor | Milestone: | 2.1.2 |
| Component: | Core | Version: | SVN HEAD |
| Keywords: | event | Cc: |
Description
The event class appears to disallow having a callback registered twice in Event::add but doesn't check for it during add_before or add_after.
Specifically the following code does not fail, but should:
$cb1 = array('Test', 'a');
$cb2 = array('Test', 'b');
Event::add('test', $cb1);
Event::add('test', $cb2);
Event::add_before('test', $cb1, $cb1);
Event::add_after('test', $cb2, $cb1);
$this->assert_equal(2, count(Event::get('test')));
Also Event::add returns true if the callback was registered but false otherwise, add_before and add_after don't always do so. Since they return true as long as the arguments are not empty.
If this is the expected behaviour I apologize, but I've attached a patch if it isn't.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.
