Skip to content

Refactor Xtense payload handling into modules - #64

Open
darknoon29 wants to merge 3 commits into
masterfrom
feature/xtense-handler-modules
Open

darknoon29 wants to merge 3 commits into
masterfrom
feature/xtense-handler-modules

Conversation

@darknoon29

Copy link
Copy Markdown
Member

Summary

  • Reduce xtense.php from 1,887 lines to a request/bootstrap/auth/dispatch/response entrypoint.
  • Move all 11 payload types into dedicated handler classes under Handler/; group message subtypes in MessageHandler.
  • Preserve shared callback and response lifecycle, with direct tests for handlers and message subtypes.

Validation

  • php vendor/bin/phpunit --display-warnings passed: 110 tests, 385 assertions, no skips or warnings.
  • PHP syntax checks passed for the endpoint, handlers, and modified/new tests.
  • git diff --check passed.
  • composer test uses Unix shell environment syntax and cannot run directly in PowerShell; PHPUnit was run directly instead.

Database and upgrade impact

  • No schema or migration impact.

Dependencies and security

  • No dependency changes.

Copilot AI balanced review requested due to automatic review settings October 29, 2026 10:46
@gitar-bot

gitar-bot Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Gitar is working

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

Gitar

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Missing alliance points can overwrite existing scores with zero, while non-array spy sections can leave updates incomplete and ranking callbacks lose the existing ally_name field.

3 open issues
What changed in this PR

This PR modularizes Xtense’s game-data ingestion, replacing the large endpoint switch with dedicated payload handlers while keeping request handling and the shared callback/response lifecycle in xtense.php.

Changes:

  • Extracts 11 payload handlers, with message subtypes grouped in MessageHandler.
  • Uses AbstractHandler helpers for permissions, callbacks, logging, and responses.
  • Adds handler tests and updates combat-report assertions and database test doubles.
File Description
xtense.php Replaces inline payload processing with handler dispatch.
tests/​unit/​SpyDatabase.php Adds row-count and combat-object lookup responses.
tests/​unit/​SimplePayloadHandlersTest.php Tests defense, fleet, and alliance-list handlers.
tests/​unit/​MessageSubtypeHandlerTest.php Tests message subtypes and report persistence.
tests/​unit/​MessageHandlerTest.php Tests personal messages, response overrides, and unknown types.
tests/​unit/​CombatReportHandlerTest.php Targets main report inserts in SQL assertions.
tests/​bootstrap.php Adds report table constants and a booster stub.
Handler/​SystemHandler.php Encapsulates solar-system imports.
Handler/​ResourceSettingsHandler.php Encapsulates resource-setting updates.
Handler/​ResearchsHandler.php Encapsulates research updates.
Handler/​RankingHandler.php Handles player and alliance rankings with batched writes.
Handler/​OverviewHandler.php Handles player, universe, and planet overview updates.
Handler/​MessageHandler.php Groups message callbacks and report persistence.
Handler/​FleetHandler.php Handles fleet and production-unit updates.
Handler/​DefenseHandler.php Handles defense updates and callbacks.
Handler/​CombatReportHandler.php Separates combat-report, round, and fleet processing.
Handler/​BuildingsHandler.php Encapsulates building updates.
Handler/​AllyListHandler.php Builds alliance-list callbacks and responses.

Review effort: Balanced

Comment thread Handler/RankingHandler.php
Comment thread Handler/MessageHandler.php
Comment thread Handler/RankingHandler.php Outdated
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
73.8% Coverage on New Code (required ≥ 80%)
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up PHP with Xdebug
uses: shivammathur/setup-php@v2

This branch has not been deployed

No deployments
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.

3 participants