Fix "Undefined array key 0" warning in MultiRPC constructor#36
Conversation
`self::$freeRelays` is not guaranteed to be 0-indexed: entries are removed via `unset(self::$freeRelays[$relayIndex])` in `occupyRelay()` and `occupyRelayAsync()` (lines 171, 194), and PHP's auto-increment retains the highest key ever used when appending. After enough churn in a long-running worker (e.g. RoadRunner), the static array can end up with keys like `[1 => ..., 3 => ...]` — `count() > 0` holds, but `self::$freeRelays[0]` raises `Warning: Undefined array key 0`. Switch to `array_key_first()`, mirroring the `$occupiedRelays` branch two lines below.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR updates ChangesRelay Selection Robustness
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
self::$freeRelaysis not guaranteed to be 0-indexed: entries are removed viaunset(self::$freeRelays[$relayIndex])inoccupyRelay()andoccupyRelayAsync()(lines 171, 194), and PHP's auto-increment retains the highest key ever used when appending. After enough churn in a long-running worker (e.g. RoadRunner), the static array can end up with keys like[1 => ..., 3 => ...]—count() > 0holds, butself::$freeRelays[0]raisesWarning: Undefined array key 0.Switch to
array_key_first(), mirroring the$occupiedRelaysbranch two lines below.Summary by CodeRabbit