IBX-11276: Adjusted iterator_to_array usage for SendersLocator#7
IBX-11276: Adjusted iterator_to_array usage for SendersLocator#7
iterator_to_array usage for SendersLocator#7Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a bug where Ibexa Messenger fails to send messages to queue for background processing due to duplicate keys when using iterator_to_array on generators with yield from statements.
Changes:
- Modified
iterator_to_arraycall to disable key preservation, preventing duplicate keys from causing classes to be excluded - Added test coverage for multiple generator scenarios
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/bundle/Transport/Sender/SendersLocator.php | Fixed iterator_to_array to use false for preserve_keys parameter to handle generators with duplicate keys |
| tests/bundle/Transport/Sender/SendersLocatorTest.php | Added test case verifying correct behavior when multiple generators are used |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| yield from ['stdClass']; | ||
| yield from ['AnotherClass']; |
There was a problem hiding this comment.
The test uses yield from on arrays which doesn't reproduce the duplicate key issue described in the PR. When using yield from on arrays with numeric keys (like ['stdClass']), both arrays have key 0, which would be overwritten. The test should use explicit keys or demonstrate the actual duplicate key scenario to properly validate the fix. Consider: yield 'key1' => 'stdClass'; yield 'key1' => 'AnotherClass'; or using generators that produce duplicate keys.
There was a problem hiding this comment.
That's exactly what it does, it produces duplicate keys.
Nice catch Copilot.
Description:
Under certain circumstances Ibexa Messenger will fail to send a message to queue for background processing.
This is due to the fact that
Ibexa\Bundle\Messenger\Transport\MessageProviderRegistry::getHandledClasses()return from internalGenerators, which share keys (inyield from).This causes specific classes to be excluded from queueing.
For QA:
Documentation: