refactor: inline werk365/etagconditionals to unblock laravel 13#737
Merged
Conversation
three middlewares (SetEtag, IfNoneMatch, IfMatch) plus the static EtagConditionals helper move into app/Http/Middleware/Etag/. route aliases (setEtag, ifNoneMatch, ifMatch) shift from the package's service provider into Kernel.php's $routeMiddleware. trigger: the L13 readiness audit (composer why-not laravel/framework "^13.0") flagged werk365/etagconditionals as the lone dep blocker. upstream PR #28 ("Support Laravel 13.x") has sat open since April 2026, last push was nine months ago, and we were already pinned to dev-master to get L11/L12 support — no tagged path forward. behaviour parity with two deliberate simplifications, both called out in docs/design-decisions.md: - if_match_weak / if_none_match_weak config knobs dropped; both hardcoded to true. monica never overrode the env vars. - the 'etag' middleware group, the facade, and the Middleware base class with name() are removed. monica only ever used the three aliases individually. coverage: 15 new cases in tests/Feature/Http/Middleware/Etag/ (unit-port + HEAD + kernel-alias resolution). the existing StorageControllerTest still exercises the live integration on /store/{file}. full PHPUnit (1745 tests) green, PHPStan clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Claude-Session: c609e463-b87a-4011-a563-2f7d6a694177
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
werk365/etagconditionalsdependency with three in-tree middlewares (SetEtag,IfNoneMatch,IfMatch) plus the staticEtagConditionalshelper, all underapp/Http/Middleware/Etag/. The three route-middleware aliases (setEtag,ifNoneMatch,ifMatch) shift from the package's auto-discovered service provider intoapp/Http/Kernel.php's$routeMiddlewarearray.composer why-not laravel/framework "^13.0"reports only the standard list of packages that have published L13-compatible newer releases (debugbar^4, tinker^3, cloudflare^4, google2fa-laravel^3, hashids^14) — no irreplaceable blocker remains.docs/design-decisions.md(new "ETag conditional middleware: replaced inline" section), including the two deliberate simplifications: theif_match_weak/if_none_match_weakconfig knobs are dropped (Monica never overrode them), and the unusedetagmiddleware group / facade /Middlewarebase class are removed.Why
Upstream
werk365/etagconditionalsis dormant. PR #28 ("Support Laravel 13.x") has sat open since 2026-04, the previous L11/L12 PR sat open for 13 months, and the repo's last push was nine months ago — Monica was already pinned todev-masterto get L11/L12 support. The middleware surface is ~120 lines and the upstream tests fully specify the behaviour, so inlining costs less than maintaining a soft-fork or VCS-pinning a PR branch.What this looks like for
StorageControllerZero call-site change. The controller's
__constructstill does$this->middleware(['setEtag', 'ifMatch', 'ifNoneMatch']). The aliases now resolve throughKernel.phpinstead of the package's service provider.The
EtagConditionals::etagGenerateUsing(...)closure registration inAppServiceProvider::boot()continues to work via a one-line import swap. The closure (sha1-of-URL, cached forever) is unchanged.Test plan
tests/Feature/Http/Middleware/Etag/SetEtagTest.php(3 cases — default md5 path, registered-callback path, HEAD response path)tests/Feature/Http/Middleware/Etag/IfNoneMatchTest.php(4 cases — match, no-match, weak-tag, HEAD-match-304)tests/Feature/Http/Middleware/Etag/IfMatchTest.php(8 cases — match, list-match, wildcard, mismatch, list-mismatch, weak-tag, non-PATCH passthrough, Kernel-alias resolution)tests/Feature/StorageControllerTest.phpcontinues to exercise the live/store/{file}integration with the new alias resolution (all 15 cases green)