Skip to content

Pre-release 4.2.118 → 4.2.117 — task 4.5 (global hooks): v13 global middleware replaces App::before/after/down - #90

Merged
agissept merged 1 commit into
masterfrom
pre-release/4.2.118
Oct 2, 2026
Merged

agissept merged 1 commit into
masterfrom
pre-release/4.2.118

Conversation

@oonid

@oonid oonid commented Oct 1, 2026 •

Copy link
Copy Markdown

Task 4.5, global hooks — v13 global middleware replaces App::before/after/down

Stacks on #89. The fork's Application runs a global middleware stack around the route dispatch, the way v13's Http\Kernel does, and drops L4.2's application hooks. The app can register its global middleware through v13's API now. After the flip, bootstrap/app.php's withMiddleware() hands the same registration to v13's kernel.

Changes

  • Global middleware on Illuminate\Foundation\Application (v13 Http\Kernel API; the fork has no HTTP kernel):
    • setGlobalMiddleware() and getGlobalMiddleware().
    • dispatch() sends the request through Illuminate\Routing\Pipeline (v13's kernel uses the same class) to the router.
    • shouldSkipMiddleware() (v13 API): the stack is skipped while middleware.disable is true. That's how the app turns off filters in tests, so this brings back L4.2's "global filters are off in tests", lost in the routing swap (4.2.108).
    • Exceptions still leave the pipeline for the fork Handler. The routing Pipeline only renders them itself when Contracts\Debug\ExceptionHandler is bound, and the fork binds it only for the queue worker.
  • Illuminate\Foundation\Configuration\Middleware: v13's withMiddleware() object, under v13's name, with use() and getGlobalMiddleware(). The fork ships none of v13's default global middleware, so use() defines the whole stack, as it does on v13.
  • Removed, none of them in v13: before(), after(), down() and its illuminate.app.down event, finish() and callFinishCallbacks(), and shutdown(). terminate() keeps the terminating callbacks. isDownForMaintenance() stays, because v13's queue worker calls it.
  • Tests: new FoundationGlobalMiddlewareTest (6 tests):
    • order around the dispatch;
    • a middleware response short-circuits the router;
    • skipped only while middleware is disabled;
    • exceptions reach handle();
    • the Middleware object defines the stack;
    • the L4.2 hooks are gone.

Not in this PR

  • The cookie and session StackPHP middlewares (MiddlewareBuilder) stay until the kernel middleware arrays land.
  • down/up still write the fork's app.manifest/down file.

Branch history

pre-release/4.2.117 was rebased (new SHAs, same tree) after this branch was cut. Rewriting pre-release/4.2.118 wasn't possible from this session, so it merges the rebased 4.2.117 in (d52ab323, no file changes). The diff against 4.2.117 is this slice only. The commit list also shows the pre-rebase copies of the 4.2.109–4.2.117 commits, and a rebase onto 4.2.117 drops them.

Verification

  • Fork:
    • suite 292 green on PHPUnit 11.5.56 (286 plus the 6 new tests);
    • ratchet green, every pattern at baseline;
    • the new tests catch real breaks: ignoring middleware.disable and reversing the stack each turn them red.
  • Downstream: the dicoding app pair dicoding-dev/dicoding#5977 (feature/platform/framework-4.2.118-rc1) moves its hooks onto this API. It ran with vendor installed exactly from its lock:
    • Psalm (full project, no cache): no errors.
    • Unit suite: 8935 green.
    • Integration suite: all 3005 tests, including 6 new global-middleware tests. Only the 4 long-standing failures remain, 196 are skipped, and no test is flagged risky.
    • Through the stacked client outside the testing environment: the maintenance page (503) while down, and the referral cookies and session key when up.
  • Checks ran in a cloud container without deck (PHP 8.4.26, MariaDB 10.11).

Tag

4.2.118 is on d52ab323, this branch's head.

🤖 Generated with Claude Code

https://claude.ai/code/session_0169SsatCE8LhaTsQTPiGtVo

@agissept
agissept added this pull request to stack #91 October 1, 2026 06:28
Base automatically changed from pre-release/4.2.117 to master October 2, 2026 07:49
…wn (task 4.5)

The Application now hosts v13's global middleware stack (Http\Kernel's
setGlobalMiddleware/getGlobalMiddleware) and runs it through
Illuminate\Routing\Pipeline around the route dispatch, as v13's Kernel does.
The stack is skipped while 'middleware.disable' is true (v13's
shouldSkipMiddleware), which restores L4.2's "global filters off in tests"
parity lost in the routing swap.

Removed the L4.2 hooks with no v13 counterpart: before(), after(), down()
(and the illuminate.app.down event), finish()/callFinishCallbacks() and
shutdown(). terminate() keeps the terminating callbacks.
isDownForMaintenance() stays; v13's queue worker calls it.

Added Foundation\Configuration\Middleware, the use()/getGlobalMiddleware()
subset of v13's withMiddleware() object, so the app's registration keeps its
meaning after the flip.

Fork suite 292 green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0169SsatCE8LhaTsQTPiGtVo
@agissept
agissept force-pushed the pre-release/4.2.118 branch from d52ab32 to d2e5980 Compare October 2, 2026 08:38
@agissept
agissept marked this pull request as ready for review October 2, 2026 08:41
@agissept
agissept merged commit 1fbedff into master Oct 2, 2026
2 checks passed
@agissept
agissept deleted the pre-release/4.2.118 branch October 2, 2026 08:54
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.

3 participants