-
Notifications
You must be signed in to change notification settings - Fork 11
remove getPostData, getQueryParameter #430
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: main
Are you sure you want to change the base?
Conversation
6c35f50 to
cbaebaa
Compare
cbaebaa to
871e541
Compare
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.
Pull request overview
This PR removes the getPostData() and getQueryParameter() helper methods from UnityHTTPD class, replacing them with direct $_POST and $_GET array access. The approach relies on an existing error handler that converts undefined array key warnings into exceptions, though this changes the error response from "bad request" (400) to "internal server error" (500) for missing parameters.
Key changes:
- Removed
getPostData()andgetQueryParameter()methods fromUnityHTTPDclass - Replaced all usages with direct
$_POSTand$_GETaccess throughout the codebase - Updated CSRF token validation to use direct
$_POSTaccess
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
resources/lib/UnityHTTPD.php |
Removed getPostData() and getQueryParameter() methods; updated validatePostCSRFToken() to use direct $_POST access |
webroot/panel/pi.php |
Replaced getPostData() calls with direct $_POST access; removed $getUserFromPost closure |
webroot/panel/modal/pi_search.php |
Replaced getQueryParameter() with direct $_GET access |
webroot/panel/groups.php |
Replaced getPostData() with direct $_POST access |
webroot/panel/ajax/get_group_members.php |
Replaced getQueryParameter() with direct $_GET access |
webroot/panel/ajax/delete_message.php |
Replaced multiple getPostData() calls with direct $_POST access |
webroot/panel/account.php |
Replaced multiple getPostData() calls with direct $_POST access |
webroot/js/ajax/ssh_validate.php |
Replaced getPostData() with direct $_POST access |
webroot/js/ajax/ssh_generate.php |
Replaced getQueryParameter() with $_GET access for optional parameter |
webroot/api/content/index.php |
Replaced getQueryParameter() calls with $_GET access, using null coalescing for optional parameter |
webroot/admin/pi-mgmt.php |
Replaced multiple getPostData() calls with direct $_POST access; removed $getUserFromPost closure |
webroot/admin/ajax/get_page_contents.php |
Replaced getQueryParameter() with direct $_GET access |
webroot/admin/ajax/get_group_members.php |
Replaced getQueryParameter() with direct $_GET access |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
This PR is at odds with #429.
Because we have an error handler registered which will convert any undefined array key warning into an exception, we don't need functions for strict array access.
One change of note is that a missing post data or query parameter used to cause "bad request", now it causes "internal server error".
I'm unsure about this because the error handler is a bit of a hack. Also, because phpunit doesn't play nice with user defined error handlers, tests cannot rely on its behavior. To make matters worse, PHPUnit deprecated the
expectNotice/expectWarningfunctions.