Skip to content

Dispatcher passes the event name instead of the event object to later listeners #475

Open

Description

@caseysoftware

In w2p_System_Dispatcher::publish() the wildcard-resource loop reuses the parameter name:

foreach ($this->_listeners['*'] as $event => $listeners) {
    if ($event == $eventName) {
        foreach ($listeners as $listener) {
            $listener->publish($event);   // a string, not the event

After this loop $event holds the last event name (a string), so it is also what the later resource-specific loops pass to their listeners. BaseObject::publish(w2p_System_Event $event) would then throw a TypeError.

Nothing subscribes with resource * today (each BaseObject only subscribes itself to its own class), so this is latent. The change-capture listener in the API proposal subscribes to every resource, so it would hit this immediately.

Fix: rename the loop variable ($name => $listeners).

Found by reading the code on dev-5.0.0 @ 179b4eaf; not yet reproduced on a running install.

Part of #488 (Phase 0 of the REST API and MCP server proposal (#471)).

Activity

  1. added
    php
    api
    on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiphp

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions