Ticket #600 (closed Patch: fixed)

Opened 7 months ago

Last modified 6 months ago

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

trunk_system_core_Event.php.patch (1.6 kB) - added by allain 7 months ago.
Small patches to the Event class

Change History

Changed 7 months ago by allain

Small patches to the Event class

Changed 6 months ago by Shadowhand

  • status changed from new to assigned

Changed 6 months ago by Shadowhand

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in r2696, merged in r2697.

Note: See TracTickets for help on using tickets.