[IMPROVEMENT] HTTP: Don't use SuperGlobalDropInReplacement in produ…#11471
Open
mjansenDatabay wants to merge 1 commit intoILIAS-eLearning:release_11from
Open
Conversation
…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.
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.
…ction
The
SuperGlobalDropInReplacementwas 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 anArrayAccessobject that throws anOutOfBoundsExceptionthe 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 (
DEVMODEonly), it always throws anOutOfBoundsExceptionon write attempts, unconditionally. The$throwOnValueAssignmentflag 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.