Skip to content

[IMPROVEMENT] HTTP: Don't use SuperGlobalDropInReplacement in produ…#11471

Open
mjansenDatabay wants to merge 1 commit intoILIAS-eLearning:release_11from
mjansenDatabay:improvement/11/super-global-dir-only-in-devmode
Open

[IMPROVEMENT] HTTP: Don't use SuperGlobalDropInReplacement in produ…#11471
mjansenDatabay wants to merge 1 commit intoILIAS-eLearning:release_11from
mjansenDatabay:improvement/11/super-global-dir-only-in-devmode

Conversation

@mjansenDatabay
Copy link
Copy Markdown
Contributor

@mjansenDatabay mjansenDatabay commented Apr 24, 2026

…ction

The SuperGlobalDropInReplacement was introduced to educate developers and enforce the principle that HTTP request values are immutable, direct reads from or writes to $_GET, $_POST, $_COOKIE and $_REQUEST should be replaced by proper PSR-7 request handling via $DIC->http()->wrapper() The replacement acts as a guardrail: it wraps the superglobals in an ArrayAccess object that throws an OutOfBoundsException the moment any code tries to assign a value, making bad practices immediately visible rather than silently tolerated.

This commit inverts the logic of the SuperGlobalDropInReplacement:

  • The replacement is now ONLY activated when DEVMODE is enabled. In production, the native PHP superglobals are left untouched, eliminating the compatibility risk for third-party libraries entirely.

  • When the replacement IS active (DEVMODE only), it always throws an OutOfBoundsException on write attempts, unconditionally. The $throwOnValueAssignment flag and the corresponding conditional branch are removed as they are no longer needed. The strict behavior is now the only behavior, making the class simpler and its contract clear.


If approved, please pick this to trunk.

…ction

The `SuperGlobalDropInReplacement` was introduced to educate developers and
enforce the principle that HTTP request values are immutable, direct reads
from or writes to $_GET, $_POST, $_COOKIE and $_REQUEST should be replaced
by proper PSR-7 request handling via the DIC. The replacement acts as a
guardrail: it wraps the superglobals in an `ArrayAccess` object that throws
an `OutOfBoundsException` the moment any code tries to assign a value,
making bad practices immediately visible rather than silently tolerated.

This commit inverts the logic of the `SuperGlobalDropInReplacement`:

- The replacement is now ONLY activated when DEVMODE is enabled.
  In production, the native PHP superglobals are left untouched,
  eliminating the compatibility risk for third-party libraries entirely.

- When the replacement IS active (`DEVMODE` only), it always throws an
  `OutOfBoundsException` on write attempts, unconditionally. The
  `$throwOnValueAssignment` flag and the corresponding conditional branch
  are removed as they are no longer needed. The strict behavior is now
  the only behavior, making the class simpler and its contract clear.
@mjansenDatabay mjansenDatabay added improvement php Pull requests that update Php code labels Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement php Pull requests that update Php code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants