The $chained property on queued jobs can become corrupted during
serialization/deserialization in certain edge cases (e.g., when using
Redis as the queue driver with specific serialization configurations).
When $chained becomes a non-array value, array_shift() throws a
TypeError. This change adds an is_array() guard to both
ChainedBatch::attachRemainderOfChainToEndOfBatch() and
Queueable::dispatchNextJobInChain() to gracefully handle corrupted
data by treating non-array values as an empty chain.
This is a defensive, backward-compatible fix that:
- Does not change behavior for valid array values
- Prevents TypeError exceptions from crashing jobs
- Treats corrupted chains as empty (safe default)