Skip to content

Improve performance of CheckSystemEnvironment middleware#6604

Merged
dtdesign merged 2 commits intoWoltLab:6.2from
TimWolla:version-check-optimization
Feb 26, 2026
Merged

Improve performance of CheckSystemEnvironment middleware#6604
dtdesign merged 2 commits intoWoltLab:6.2from
TimWolla:version-check-optimization

Conversation

@TimWolla
Copy link
Member

See individual commits.

The version checking condition can be evaluated by OPcache at compile time,
eliding the entire middleware's logic (except for passing along the request to
the next middleware) in the common case of running a supported PHP version.
Particularly it avoids a useless call to `->isACPRequest()`.

Before:

    wcf\http\middleware\CheckSystemEnvironment::process:
         ; (lines=11, args=2, vars=2, tmps=1)
         ; (after optimizer)
         ; wcfsetup/install/files/lib/http/middleware/CheckSystemEnvironment.class.php:27-43
    0000 CV0($request) = RECV 1
    0001 CV1($handler) = RECV 2
    0002 INIT_STATIC_METHOD_CALL 0 string("wcf\\system\\request\\RequestHandler") string("getInstance")
    0003 V2 = DO_FCALL
    0004 INIT_METHOD_CALL 0 V2 string("isACPRequest")
    0005 DO_FCALL
    0006 INIT_METHOD_CALL 1 CV1($handler) string("handle")
    0007 SEND_VAR_EX CV0($request) 1
    0008 V2 = DO_FCALL
    0009 VERIFY_RETURN_TYPE V2
    0010 RETURN V2
    LIVE RANGES:
         2: 0009 - 0010 (tmp/var)

After:

    wcf\http\middleware\CheckSystemEnvironment::process:
         ; (lines=7, args=2, vars=2, tmps=1)
         ; (after optimizer)
         ; wcfsetup/install/files/lib/http/middleware/CheckSystemEnvironment.class.php:27-43
    0000 CV0($request) = RECV 1
    0001 CV1($handler) = RECV 2
    0002 INIT_METHOD_CALL 1 CV1($handler) string("handle")
    0003 SEND_VAR_EX CV0($request) 1
    0004 V2 = DO_FCALL
    0005 VERIFY_RETURN_TYPE V2
    0006 RETURN V2
    LIVE RANGES:
         2: 0005 - 0006 (tmp/var)
This allows OPcache to evaluate the condition at compile-time. While not
particularly important in this case, it's good for consistency.
@dtdesign dtdesign merged commit 34d41f9 into WoltLab:6.2 Feb 26, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants