Skip to content

[2.x] fix: add missing getHidden() to Log\Context\Repository stub#4633

Merged
imorland merged 1 commit into
2.xfrom
im/log-context-gethidden
May 6, 2026
Merged

[2.x] fix: add missing getHidden() to Log\Context\Repository stub#4633
imorland merged 1 commit into
2.xfrom
im/log-context-gethidden

Conversation

@imorland
Copy link
Copy Markdown
Member

@imorland imorland commented May 6, 2026

Summary

Laravel 13's queue handler calls getHidden() on the log context repository when releasing unique-job locks after a ModelNotFoundException (CallQueuedHandler::ensureUniqueJobLockIsReleasedViaContext).

Flarum's stub at framework/core/src/Log/Context/Repository.php implemented addHidden, forgetHidden, and allHidden but not getHidden. So any queued job whose subject (post, discussion, etc.) was deleted between dispatch and execution turned a benign ModelNotFoundException into a cluster of fatal Error: Call to undefined method Flarum\Log\Context\Repository::getHidden() — one per pending job for that subject.

Add getHidden() mirroring get() for the hidden array. With nothing writing to the hidden context in a fresh worker, the call returns null and Laravel's handler silently skips lock cleanup — the intended no-op-on-empty path.

Fixes #4611

Changes

  • framework/core/src/Log/Context/Repository.php — add getHidden(string $key, mixed $default = null): mixed.
  • New framework/core/tests/unit/Log/Context/RepositoryTest.php — 4 unit tests covering getHidden return value, default fallback, add/get/forget round-trip, and isolation between public and hidden arrays.

Test plan

  • Unit tests pass (4 tests, 9 assertions).
  • Verified the new tests catch the original bug — reverting the fix produces 4× Call to undefined method errors, exactly the runtime error users hit.
  • Manual: dispatch a queued job that touches a soon-to-be-deleted model (e.g. mention a user, then delete the post immediately); confirm the worker logs the ModelNotFoundException quietly without the fatal cascade.

Notes

  • The stub still doesn't implement many other Laravel Repository methods (pullHidden, hasHidden, pushHidden, …) — adding those is out of scope here. This PR fixes the specific path that's currently fataling in production.

Laravel 12's queue handler calls getHidden() on the context repository
when releasing unique-job locks after a ModelNotFoundException
(CallQueuedHandler::ensureUniqueJobLockIsReleasedViaContext). Our stub
implemented addHidden, forgetHidden, and allHidden but not getHidden,
so any queued job whose subject was deleted between dispatch and
execution turned a benign ModelNotFoundException into a cluster of
fatal "Call to undefined method" errors.

Add getHidden() mirroring get() for the hidden array. With nothing
writing to the hidden context in a fresh worker, the call returns null
and Laravel's handler silently skips lock cleanup — the intended
no-op-on-empty path.

Add unit coverage for the hidden-array methods.

Fixes #4611
@imorland imorland requested a review from a team as a code owner May 6, 2026 19:44
@imorland imorland added this to the 2.0.0-rc.2 milestone May 6, 2026
@imorland imorland merged commit d6dc7c4 into 2.x May 6, 2026
25 checks passed
@imorland imorland deleted the im/log-context-gethidden branch May 6, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flarum\Log\Context\Repository stub missing getHidden() — every queued-job ModelNotFoundException cascades into a fatal Error

1 participant