Skip to content

Conversation

simonLeary42
Copy link
Collaborator

@simonLeary42 simonLeary42 commented Sep 19, 2025

  • moved array getting logic from UnitySite::arrayGetOrBadRequest into general-purpose \arrayGet in a new file utils.php
  • replaced UnitySite::arrayGetOrBadRequest with getPostData
  • updated account.php to delete the uploaded SSH key file after reading into memory
  • updated account.php to check for the case when file_get_contents returns false

Copy link
Contributor

@Copilot 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 array access logic by extracting a general-purpose \arrayGet function from the existing UnitySite::arrayGetOrBadRequest method and replacing it with more specific wrapper functions. The changes improve code organization by separating generic array access from HTTP-specific error handling.

  • Extracted \arrayGet utility function with proper exception handling
  • Replaced UnitySite::arrayGetOrBadRequest with specific getPostData and getUploadedFileContents methods
  • Added automatic cleanup of uploaded temporary files after reading

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
webroot/panel/account.php Updated to use new specific accessor methods instead of generic array accessor
test/unit/UtilsTest.php Added comprehensive test coverage for the new \arrayGet function
test/unit/UnitySiteTest.php Removed obsolete tests for the old arrayGetOrBadRequest method
test/phpunit-bootstrap.php Added required includes for new utility and exception files
test/functional/SSHKeyAddTest.php Updated test to verify automatic file cleanup behavior
resources/lib/utils.php Implemented new general-purpose \arrayGet function
resources/lib/exceptions/ArrayKeyException.php Added new exception class for array access errors
resources/lib/UnitySite.php Replaced generic method with specific getPostData and getUploadedFileContents methods
resources/autoload.php Added includes for new utility and exception files

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@simonLeary42 simonLeary42 merged commit dea93a2 into main Sep 23, 2025
2 checks passed
@simonLeary42 simonLeary42 deleted the array-get branch September 23, 2025 12:24
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