-
Notifications
You must be signed in to change notification settings - Fork 173
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove lorispath from PSR7 request #9055
Remove lorispath from PSR7 request #9055
Conversation
$query = implode( | ||
"&", | ||
array_map( | ||
fn ($key, $value) => $key . "=" . $value, | ||
array_keys($params), | ||
$params | ||
) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not use http_build_query
because the parameters should already be URL-encoded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? Shouldn't it have been handled internally by the library after $serverrequest = $serverrequest->withQueryParams($params);
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? Shouldn't it have been handled internally by the library after
$serverrequest = $serverrequest->withQueryParams($params);
?
Yes it is, the request stores both the query parameters as an array and as a string in the URI. Changing one does not affect the other.
htdocs/index.php
Outdated
// Remove the lorispath from the URI query parameters. | ||
// Both the request query parameters and the URI query string must be updated. | ||
$params = $serverrequest->getQueryParams(); | ||
$params = array_diff_key($params, ["lorispath" => null]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$params = array_diff_key($params, ["lorispath" => null]); | |
unset($params['lorispath']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL PHP arrays are copy-on-write.
Applied.
Brief summary of changes
Removes
lorispath
from the PSR7 request's query parameters and uri query string (both must be updated separately).Manipulating arrays in PHP is so verbose 馃槾.
Testing instructions
var dump
$serverrequest
Links to related issues