[2.x] fix: add missing getHidden() to Log\Context\Repository stub#4633
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Laravel 13's queue handler calls
getHidden()on the log context repository when releasing unique-job locks after aModelNotFoundException(CallQueuedHandler::ensureUniqueJobLockIsReleasedViaContext).Flarum's stub at
framework/core/src/Log/Context/Repository.phpimplementedaddHidden,forgetHidden, andallHiddenbut notgetHidden. So any queued job whose subject (post, discussion, etc.) was deleted between dispatch and execution turned a benignModelNotFoundExceptioninto a cluster of fatalError: Call to undefined method Flarum\Log\Context\Repository::getHidden()— one per pending job for that subject.Add
getHidden()mirroringget()for the hidden array. With nothing writing to the hidden context in a fresh worker, the call returnsnulland Laravel's handler silently skips lock cleanup — the intended no-op-on-empty path.Fixes #4611
Changes
framework/core/src/Log/Context/Repository.php— addgetHidden(string $key, mixed $default = null): mixed.framework/core/tests/unit/Log/Context/RepositoryTest.php— 4 unit tests coveringgetHiddenreturn value, default fallback, add/get/forget round-trip, and isolation between public and hidden arrays.Test plan
Call to undefined methoderrors, exactly the runtime error users hit.ModelNotFoundExceptionquietly without the fatal cascade.Notes
Repositorymethods (pullHidden,hasHidden,pushHidden, …) — adding those is out of scope here. This PR fixes the specific path that's currently fataling in production.