SuiteInitSubscriberTrait incorrectly appends `'receiveModuleContainer'` listener · Issue #6861 · Codeception/Codeception · GitHub
Skip to content

SuiteInitSubscriberTrait incorrectly appends 'receiveModuleContainer' listener #6861

Closed

Description

@dantleech

Hi

The SuiteInitSubscrtiberTrait was introduced recently in:

https://github.com/Codeception/Codeception/pull/6851/files#diff-4cd87484550c33eba1e84bdee7530fca0a946ea5c25de6a085e3d30f534d70cdL47

But it incorrectly appends the listener so that any extension listening suite.init causes:

[26-May-2025 06:38:58 UTC] PHP Fatal error:  Uncaught TypeError: Symfony\Component\EventDispatcher\EventDispatcher::addListener(): Argument #3 ($priority) must be of type int, string given, called in /data/vendor/symfony/event-dispatcher/EventDispatcher.php on line 178 and defined in /data/vendor/symfony/event-dispatcher/EventDispatcher.php:129

This is because Symfony expects one of:

'suite.init' => 'methodName',
'suite.init' => [
   'methodName'
]
'suite.init' => [
    ['methodName', 10], // listener priorirty
]

The new code assumes 2 but appends and appends to the array:

'suite.init' => [
    'methodName',
    'receiveModuleContainer',
],

And Symfony tries to use receiveModuleContainer as a priotity (as with 3) causing the error above. Currently there is no way to listen on suite.init.

Activity

  1. TavoNiievez commented on May 26, 2025

    @TavoNiievez
    Member

    Hi @dantleech ,

    before the commit you reference getSubscribedEvents was also included by default in the abstract Extension class with exactly the same code:

    Could you explain why moving the function to a trait and using it as before introduces the error you indicate?

  2. dantleech commented on May 26, 2025

    @dantleech
    Author

    Sorry - I assumed it was introduced in that MR, the last version that worked was in 5.2.2:

    https://github.com/Codeception/Codeception/blob/5.2.2/src/Codeception/Extension.php#L49

  3. TavoNiievez commented on May 26, 2025

    @TavoNiievez
    Member

    Understood.

    So you are referring to this PR:

    https://github.com/Codeception/Codeception/pull/6849/files#diff-4cd87484550c33eba1e84bdee7530fca0a946ea5c25de6a085e3d30f534d70cd

    It looks like you are right. I sent a PR to restore the previous version.

  4. dantleech commented on May 26, 2025

    @dantleech
    Author

    Thanks for the quick work!

  5. TavoNiievez commented on May 26, 2025

    @TavoNiievez
    Member

    Released as version 5.3.2

    Please update, and thanks for reporting!

  6. dantleech commented on May 26, 2025

    @dantleech
    Author

    Confirmed, thanks again!

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions