Skip to content

Conversation

@simonLeary42
Copy link
Collaborator

@simonLeary42 simonLeary42 commented Dec 19, 2025

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/expectWarning functions.

@simonLeary42 simonLeary42 marked this pull request as draft December 19, 2025 21:02
@simonLeary42 simonLeary42 changed the title remove all getPostData getQueryParameter remove getPostData, getQueryParameter Dec 19, 2025
@simonLeary42 simonLeary42 force-pushed the remove-getpostdata-getqueryparameter branch from 6c35f50 to cbaebaa Compare December 19, 2025 21:17
Copy link
Contributor

Copilot AI left a 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() and getQueryParameter() methods from UnityHTTPD class
  • Replaced all usages with direct $_POST and $_GET access throughout the codebase
  • Updated CSRF token validation to use direct $_POST access

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants