Skip to content

Conversation

@simonLeary42
Copy link
Collaborator

@simonLeary42 simonLeary42 commented Dec 19, 2025

This PR is at odds with #430.

It also splits off the $die_if_key_not_exists functionality from getQueryParameter into a separate function getOptionalQueryParameter, and adds the getOptionalPostData function.

I'm unsure about this because it's ugly and not actually necessary thanks to our error handler.

@simonLeary42 simonLeary42 marked this pull request as draft December 19, 2025 21:02
@simonLeary42 simonLeary42 changed the title separate mandatory and optional query parameter getters separate mandatory and optional getPostData getQueryParameter Dec 19, 2025
@simonLeary42 simonLeary42 changed the title separate mandatory and optional getPostData getQueryParameter fully commit to getPostData, getQueryParameter Dec 19, 2025
@simonLeary42 simonLeary42 force-pushed the optional-query-param-func branch from b53f82c to c48efb5 Compare December 19, 2025 21:18
@simonLeary42 simonLeary42 force-pushed the optional-query-param-func branch from c48efb5 to a4dcdec Compare December 19, 2025 21:19
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 refactors direct $_POST and $_GET array access to use wrapper methods from the UnityHTTPD class. The change improves type safety and error handling by centralizing validation logic.

  • Removes the boolean $die_if_not_found parameter from getQueryParameter() and creates separate getOptional* methods
  • Adds new getOptionalPostData() and getOptionalQueryParameter() methods for optional parameters
  • Systematically replaces direct array access with wrapper methods across multiple files

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
resources/lib/UnityHTTPD.php Adds getOptionalPostData() and getOptionalQueryParameter() methods; modifies getQueryParameter() signature to remove optional parameter
webroot/panel/pi.php Replaces direct $_POST access with getPostData() for form handling
webroot/panel/groups.php Replaces direct $_POST access with getPostData() for form type and TOS validation
webroot/panel/account.php Replaces direct $_POST access with getPostData() for shell selection and TOS validation
webroot/admin/user-mgmt.php Replaces direct $_POST access with getPostData() for user management forms
webroot/admin/pi-mgmt.php Adds $getPIGroupFromPost helper function and replaces direct $_POST access throughout
webroot/admin/notices.php Replaces direct $_POST access with getPostData() for notice management operations
webroot/admin/content.php Replaces direct $_POST access with getPostData() for page editing
resources/templates/header.php Uses getOptionalPostData() for conditional form type checking
webroot/js/ajax/ssh_generate.php Uses getOptionalQueryParameter() for optional query parameter
webroot/api/content/index.php Uses getOptionalQueryParameter() with null coalescing operator for line wrap parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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