Skip to content

Conversation

@QDenka
Copy link

@QDenka QDenka commented Feb 8, 2026

Problem

When multiple requests write to the deduplication store file simultaneously, partially written lines can be read by concurrent processes. This causes Undefined array key 1 and Undefined array key 2 errors on the list($timestamp, $level, $message) = explode(':', $store[$i], 3) line in isDuplicate().

Solution

  1. Skip invalid/incomplete lines in isDuplicate() — if a line doesn't have all 3 expected parts after explode(), it's skipped instead of causing an error. Worst case: a duplicate notification is sent (acceptable trade-off).
  2. Add LOCK_EX flag to file_put_contents() when appending to the deduplication store, reducing the chance of partially written lines.

Related

Fixes #1950

As suggested by @Seldaek in #1950 (comment)

When multiple requests write to the deduplication store file simultaneously,
partially written lines can be read by concurrent processes. This causes
'Undefined array key' errors when trying to destructure incomplete lines.

Changes:
- Skip incomplete/invalid lines in isDuplicate() instead of crashing
- Add LOCK_EX flag to file_put_contents() for atomic writes

Fixes Seldaek#1950
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Undefined array key in DeduplicationHandler

1 participant