Repository navigation
fix: refresh REQUEST after URI GET normalization #10606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -368,6 +368,8 @@ public function unsetRequest(string $key): self | |
| * Get all $_REQUEST values. | ||
| * | ||
| * @return array<string, request_items> | ||
| * | ||
| * @internal | ||
|
Comment on lines
+371
to
+372
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be on but
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, that's true - my mistake. I keep forgetting that this class is already internal. |
||
| */ | ||
| public function getRequestArray(): array | ||
| { | ||
|
|
@@ -387,6 +389,51 @@ public function setRequestArray(array $array): self | |
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the merged $_GET, $_POST, and $_COOKIE data according to the | ||
| * `request_order` (or `variables_order`) ini setting, without mutating | ||
| * $_REQUEST. | ||
| * | ||
| * PHP populates $_REQUEST only once at the start of the request. When | ||
| * $_GET is modified later (e.g. by SiteURIFactory), $_REQUEST becomes | ||
| * stale. This method returns the current merged values so callers can | ||
| * read up-to-date request data without relying on the stale $_REQUEST. | ||
| * | ||
| * @param string|null $requestOrder Overrides the `request_order` ini | ||
| * setting. Useful for testing, since the | ||
| * ini setting cannot be changed at runtime. | ||
| * | ||
| * @return array<string, request_items> | ||
| */ | ||
| public function getRequestData(?string $requestOrder = null): array | ||
|
paulbalandan marked this conversation as resolved.
|
||
| { | ||
| $requestOrder ??= (string) ini_get('request_order'); | ||
|
|
||
| if ($requestOrder === '') { | ||
| $requestOrder = (string) ini_get('variables_order'); | ||
| } | ||
|
|
||
| if ($requestOrder === '') { | ||
| $requestOrder = 'GP'; | ||
| } | ||
|
|
||
| $request = []; | ||
|
|
||
| foreach (array_unique(str_split(strtoupper($requestOrder))) as $type) { | ||
| match ($type) { | ||
| // array_replace_recursive() matches PHP's own $_REQUEST merge | ||
| // (php_autoglobal_merge): numeric keys are preserved and | ||
| // array values are merged recursively. | ||
| 'G' => $request = array_replace_recursive($request, $this->get), | ||
| 'P' => $request = array_replace_recursive($request, $this->post), | ||
| 'C' => $request = array_replace_recursive($request, $this->cookie), | ||
| default => null, | ||
| }; | ||
| } | ||
|
|
||
| return $request; | ||
| } | ||
|
|
||
| /** | ||
| * Get all $_FILES values. | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,6 +63,7 @@ Bugs Fixed | |
| - **Helpers:** Fixed a bug where ``get_dir_file_info()`` returned incomplete entries for subdirectories and missing files instead of omitting them. | ||
| - **Helpers:** Fixed a bug where ``word_wrap()`` entered an infinite loop when the character limit was below 2. Over-length words are now kept whole in that case. | ||
| - **Honeypot:** Fixed a bug where bot detection returned an HTTP 500 response instead of 403 (Forbidden). | ||
| - **HTTP:** Fixed stale ``$_REQUEST`` values after ``SiteURIFactory`` normalizes GET parameters, so ``Validation::withRequest()`` reads the normalized values while unrelated REQUEST entries are preserved. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. v4.7.5 was already released. This needs to be rebased and moved to v4.7.6 |
||
| - **I18n:** Fixed a bug where ``Time::today()``, ``Time::yesterday()``, and ``Time::tomorrow()`` ignored the specified ``$timezone`` and ``setTestNow()`` when calculating the day. | ||
| - **Logger:** Fixed a bug where interpolating a log message with array or non-stringable context values could raise PHP warnings or errors. | ||
| - **Validation:** Fixed a bug where ``valid_cc_number`` accepted non-digit characters (e.g., a decimal point) in the card number. Such values could pass the Luhn check and triggered an ``Undefined array key`` warning inside it; the number is now checked with ``ctype_digit()``. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.