620 Commits
Author SHA1 Message Date
Adam Daley 1db804d740 Harden Stripe webhooks and server manager input (#3962)
* Harden Stripe webhooks and server manager input

* Add `whsec` to cspell dictionary

Updates `cspell.json` to include `whsec` in the custom words list, preventing it from being flagged as a spelling error.

* Require Stripe webhook secret by mode
2026-07-11 17:12:01 +01:00
FOSSBilling BotandFOSSBilling Bot 6f50f133c8 Apply PHP Code Styling & Quality Changes (#3961)
Co-authored-by: FOSSBilling Bot <fossbilling-bot>
2026-07-11 16:37:02 +01:00
137a10dbf3 Apply autofixes and update CODEOWNERS for code quality (#3959)
* Apply suggested fix to tests/Unit/FOSSBilling/RateLimiterTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to tests/Unit/FOSSBilling/RateLimiterTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to src/library/Server/Manager/Directadmin.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to tests/Unit/FOSSBilling/Api/AbstractApiTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Remove tests path from CODEOWNERS

* Apply suggested fix to src/modules/Order/Service.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Fix uncancel emails and zero-credit payments

* Preserve orders when invoice generation fails

* Fix RateLimiterTest CI failures from prior autofix commits

- Add a public RateLimiter::getStatus() so tests can read the token
  limit for a policy without hardcoding it (getRateLimitState() now
  reuses it).
- Fix consumeOrThrow test's toThrow() call: Pest expects the assertion
  closure as the first argument (with the exception type-hinted), not
  as a second argument alongside the class string.

* Fix DirectAdmin apostrophe entity decoding to avoid trailing semicolon

str_replace('&#39', "'", $data) also matched the fully-terminated
&#39; entity, replacing just the &#39 part and leaving the semicolon
behind (e.g. "O&#39;Brien" became "O';Brien"). Replace the terminated
form first, then the legacy unterminated form, so both decode to a
plain apostrophe.

* Fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-07-11 16:20:59 +01:00
Adam Daley 268473ae5a Refine PayPal IPN callback handling (#3957) 2026-07-11 14:40:18 +01:00
Adam Daleyandcoderabbitai[bot] 4035563b72 Simplify API Resolution and Product Accessors Across Modules (#3954)
* Simplify service implementation

* Inject test API containers explicitly

* Update src/modules/Staff/tests/Unit/Api/GuestTest.php

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-07-11 13:17:03 +01:00
Adam Daley 3f0e8bf5db Enhance IP-based rate limit management UI and API (#3953)
* Add IP-based rate limit management UI & API

* Add pagination to rate limit counters

* Only track and show rate-limited IP counters

* Clarify rate limits UI text and simplify table

* Update rate limits admin request handling

* Gate rate limit reset UI by permission

* Refactor security rate limit listing

* Lock rate limit IP index updates
2026-07-11 12:21:46 +01:00
Adam Daley ca3625202a Add shared price validation for orders (#3952)
* Add shared price validation for orders

* Fix quantity validation and item update behavior
2026-07-11 11:37:38 +01:00
0eb6610f5a Apply PHP Code Styling & Quality Changes (#3940)
* Apply PHP Code Styling & Quality Changes

* Fix fingerprint PHPStan error

---------

Co-authored-by: FOSSBilling Bot <fossbilling-bot>
Co-authored-by: Adam Daley <admdly@users.noreply.github.com>
2026-07-09 05:44:18 +01:00
Adam DaleyandCopilot Autofix powered by AI bf607e3baf Fixes for 2 code quality findings in i18n tests (#3939)
* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-07-07 09:27:44 +01:00
Adam DaleyandCopilot Autofix powered by AI 2d0e476ee2 Fix for 1 code quality finding in i18n tests (#3935)
Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-07-07 07:20:20 +01:00
Adam Daley fe7d293df4 Refactor to use Request object for locale and cookie handling (#3934)
* Use Request object instead of superglobals

* Use Request in locale resolution

* Queue cookies and remove direct header writes

* Fix flaky i18nTest: de_DE locale isn't installed in CI

CI builds with INSTALL_TRANSLATIONS=false, so only en_US exists on
disk and getLocales() never considers de_DE "enabled". Use en_US as
the cookie value (always installed) against a different config
default to still prove the cookie takes precedence.
2026-07-07 07:01:45 +01:00
Adam DaleyandCopilot Autofix powered by AI e2e9ff1125 Fixes for 2 code quality findings in RouterMatcherTest (#3930)
* Apply suggested fix to tests/Unit/FOSSBilling/RouteMatcherTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to tests/Unit/FOSSBilling/RouteMatcherTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-07-07 06:00:42 +01:00
Adam Daley 85cd7aac2a Modernize HTTP response flow (#3928)
* Modernize HTTP response flow

* Fix route matcher test spelling
2026-07-07 05:15:39 +01:00
Adam Daley eac0dd8f95 Refactor Staff entities and improve Support ticket handling (#3926)
* Refresh legacy headers and manifests

* Add Staff Doctrine entities and service fixes

Introduces Doctrine-backed Staff entities/repositories for `admin` and `admin_password_reset`, including lifecycle timestamps and typed lookup helpers. Staff service list retrieval now uses DBAL `fetchAllKeyValue`.

Also refactors Support ticket creation to pass `clientId` instead of loading `Model_Client`, and uses an order lookup by client/order IDs for related ticket data. Product promo failure compensation was tightened to be idempotent by returning early when no redemptions remain and decrementing promo usage by the actual number of removed redemptions. Includes minor import/whitespace/docblock cleanup.

* Fix AdminRepository return type annotation
2026-07-07 03:46:20 +01:00
Adam DaleyandCopilot Autofix powered by AI 0ed3c50036 Fixes for 2 code quality findings in FOSSBilling i18n tests (#3925)
* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-07-07 03:02:16 +01:00
Adam DaleyandCopilot Autofix powered by AI 1be5a8e72d Fixes for 2 code quality findings in i18n tests (#3923)
* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Fix failing timezone alias test to match actual validateTimezone behavior

US/Eastern is a legacy tzdata backward-compatibility alias excluded from
DateTimeZone::listIdentifiers(), so validateTimezone() correctly rejects
it. The test asserted the opposite and failed CI.

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-07-07 01:58:59 +01:00
Adam DaleyandCopilot Autofix powered by AI 0ad2ad1f41 Fix for 1 code quality finding in i18n tests (#3921)
Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-07-07 01:25:01 +01:00
Adam DaleyandCopilot Autofix powered by AI 62d235e130 Fixes for 2 code quality findings in i18n tests (#3920)
* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-07-07 01:11:16 +01:00
Adam DaleyandCopilot Autofix powered by AI 0e64aed45f Fix for 1 code quality finding in i18n tests (#3919)
Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-07-07 00:51:00 +01:00
Adam DaleyandCopilot Autofix powered by AI 9ab5256a33 Fixes for 2 code quality findings in Twig EdgeCaseRenderer tests (#3917)
* Apply suggested fix to tests/Unit/FOSSBilling/Twig/EdgeCaseRenderingTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to tests/Unit/FOSSBilling/Twig/EdgeCaseRenderingTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Fix incorrect assertion flip in admin ticket edited-message test

The prior "code quality" pass flipped the editMessage2 assertion to
not->toContain, but the admin ticket template renders an edit link for
every admin-authored message regardless of whether it was edited, so
the assertion should remain toContain.

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-07-07 00:23:15 +01:00
Adam DaleyandCopilot Autofix powered by AI ddb7875cf8 Fixes for 2 code quality findings in i18n tests (#3915)
* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-07-06 23:52:19 +01:00
Adam DaleyandCopilot Autofix powered by AI c4c648c2a6 Fixes for 2 code quality findings in Twig EdgeCaseRendering tests (#3916)
* Apply suggested fix to tests/Unit/FOSSBilling/Twig/EdgeCaseRenderingTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to tests/Unit/FOSSBilling/Twig/EdgeCaseRenderingTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-07-06 23:44:59 +01:00
Adam Daley d144dfdc07 Attach PDF invoices to invoice emails (#3913)
* Attach PDF invoices to invoice emails (#1724)

Adds generic file-attachment support to the email pipeline (Mail, QueuedEmail,
Email\Service) and wires it into invoice notifications via a new
"Attach PDF Copy to Invoice Emails" setting, so clients who pay by bank
transfer can view the invoice without logging in.

Also carries the same attachment into the sent-email activity log so a
later "resend" (client or admin) reattaches the PDF instead of dropping it.

* Address PR review: avoid blob hydration in email history list, fix checkbox uncheck

- ActivityClientEmailRepository::getSearchQueryBuilder() now selects a partial
  entity that excludes attachment_content, so the paginated admin/client email
  history list no longer hydrates every PDF into memory just to render
  has_attachment. Verified against a real Doctrine EntityManager that the DQL
  parses, the generated SQL excludes the blob column, and toApiArray() still
  works correctly on the partial entity.
- mod_invoice_settings.html.twig: add the hidden-input-before-checkbox pattern
  already used elsewhere in this codebase (e.g. mod_client_new_form.html.twig),
  so unchecking "Attach PDF Copy to Invoice Emails" actually persists as
  disabled instead of being silently dropped from the form submission.
2026-07-06 23:32:12 +01:00
Adam Daley c8cd721e49 Fix cron settings defaults (#3911) 2026-07-06 22:08:46 +01:00
Adam Daley 800a7456d8 Stop mapping timers before debugbar collection (#3907)
* Stop mapping timers before debugbar collection

* Fix DebugBar timing PHPStan type

* Refactor timing measure stop checks in Box_App
2026-07-06 19:55:33 +01:00
Adam Daley 9ea2095ce1 Allow admins to edit ticket replies, with edit history (#3906)
* Allow admins to edit ticket replies, with edit history (#2317)

Admins previously had no way to fix a typo or correct a reply without
editing the database directly. Adds an Edit action to admin-authored
messages in the admin ticket view; client-authored messages remain
uneditable so an admin can never alter a client's own words.

Every edit snapshots the message's prior content into a new
support_ticket_message_history table before overwriting it, so the
original wording sent to a client is never silently lost. Admins can
view a message's revision history via a lazy-loaded modal.

Also fixes ticket_message_update, which existed but was never wired
into any UI and skipped the markdown sanitization that ticket_reply
already applies.

* Bump fresh-install last_patch to 83

Fresh installs seed last_patch from content.sql so the patcher doesn't
try to reapply migrations already baked into structure.sql. Missed
bumping this when patch83 (support_ticket_message_history) was added.

* Fix message history modal getting stuck on Loading... after a failed fetch

dataset.loaded was set before the API call resolved, so a failed
request left the modal permanently stuck on "Loading..." with no way
to retry short of a page reload. Move the flag to the success
callback and add an error handler that shows a retryable message.

* Make support_ticket_message_history.support_ticket_message_id required

A history row is meaningless without the message it snapshots; allowing
NULL let orphaned rows exist. Tightened the column in patch84,
structure.sql, and the entity's JoinColumn to NOT NULL.

* Delete message edit history when a ticket is removed

Service::rm() explicitly removes a ticket's notes and messages rather
than relying on the entity mapping's onDelete: CASCADE, because this
schema has no real FK constraints anywhere (referential integrity is
handled at the application layer throughout this codebase). History
rows were missed by that pattern and were left orphaned after a ticket
delete. Now removed alongside their message, following the same
explicit-cleanup convention as notes/messages.

Also cache SupportTicketMessageHistoryRepository via setDi(), matching
every other repository on this service, and add direct coverage for
getMessageHistory().
2026-07-06 19:01:45 +01:00
Adam DaleyandCopilot Autofix powered by AI 3763246051 Fixes for 2 code quality findings in Twig FOSSBillingExtension tests (#3904)
* Apply suggested fix to tests/Unit/FOSSBilling/Twig/Extension/FOSSBillingExtensionTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to tests/Unit/FOSSBilling/Twig/Extension/FOSSBillingExtensionTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-07-06 17:33:35 +01:00
Adam DaleyandCopilot Autofix powered by AI d90ff52052 Fix for 1 code quality finding in i18n tests (#3903)
Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-07-06 17:25:16 +01:00
Adam DaleyandCopilot Autofix powered by AI 114dc23714 Fixes for 2 code quality findings in i18n tests (#3901)
* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-07-05 04:29:38 +01:00
Adam Daley 85fa3dc1b2 Refactor HTTP helpers and inject Filesystem via DI (#3900)
* Remove redundant HTTP helper wrappers

* Inject Filesystem via DI across services

* Fix constructor and Theme DI wiring
2026-07-05 04:07:54 +01:00
Adam Daley c3d91257d4 Restrict staff notification emails by staff group (#3899)
Previously an email template's "enabled" flag was the only way to control
whether a staff notification (new order, ticket, signup, etc.) went out, and
when enabled it always went to every active staff member. This adds a
per-template staff-group allow-list so notifications can be scoped to the
teams that should actually receive them.

- New email_template_group join table/entity linking templates to admin
  groups, with admin API endpoints and a UI card on the template page
  mirroring the existing staff-member group management UI.
- Email\Service resolves to_staff recipients from the template's assigned
  groups; a template with no groups assigned sends to nobody.
- Existing and newly-created built-in staff templates are auto-linked to
  every current staff group (via an UpdatePatcher migration and
  createBuiltinTemplateRecord) so upgrades and fresh installs keep today's
  "notify everyone" behavior by default.
- Staff\Service::deleteGroup() now blocks removing a group that's still
  restricting an email template.

Closes #1247
2026-07-05 03:37:20 +01:00
Adam DaleyandCopilot Autofix powered by AI d96d6646e7 Fix for 1 code quality finding in i18n tests (#3898)
Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-07-05 03:07:55 +01:00
Adam DaleyandCopilot Autofix powered by AI 8d0c068b8b Fixes for 2 code quality findings in i18n tests (#3897)
* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-07-05 02:54:28 +01:00
Adam Daley fcae50dbc5 Add per-user timezone support across the app (#3895)
* Add per-user timezone support across app

* Bump install DB last_patch to 81

* Address timezone review findings

* Fix uninitialized variable warnings in Email

* Consolidate validation and fix PHPStan variable init

- Hoist the template parse above the recipient dispatch so
  $subject/$content are always defined before use (CI PHPStan
  caught them as potentially undefined in the elseif branches).
- Address timezone review feedback
2026-07-05 02:42:38 +01:00
Adam DaleyandCopilot Autofix powered by AI 9b35d576d7 Apply suggested fixes from Copilot Autofix across multiple files (#3896)
* Apply suggested fix to src/modules/Invoice/tests/Unit/ServiceTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to src/modules/Invoice/tests/Unit/ServiceTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to src/modules/Massmailer/Service.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to src/modules/Staff/tests/Unit/Api/AdminTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to tests/Unit/FOSSBilling/ResponseFactoryTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Fix file/download response content disposition

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-07-05 02:32:47 +01:00
Adam Daley 102e97bd61 Modernize HTTP routing and response handling (#3892)
* Modernize Box app HTTP routing

* Use response factory for module redirects

* Clean up IPN response handling
2026-07-05 00:54:07 +01:00
Yağızhan Burak YakarandAdam Daley 03a6079418 Rework admin groups and permissions (#3821)
* Redo and migrate the Admin Group structure

* Update permisison checks to use groups

* Migrate admin group CRUD to Doctrine

* Remove legacy permission and group membership logic

* Replace legacy role logic

* Drop the admin.permissions column

* Only allow super admins to create/edit/delete groups, better guards

* Remove the redundant `admin.protected` column

* Clean group memberships when an admin is deleted

* Make the "Exclude cron user" filter work

* Improve labels

* Addressed code review comments

* Require an initial group

* Improved logger messages

* Replace role subtitle with email

* Bypass permission checks during update finalization to make sure it's accessible

* More sensible default groups

* Update seed content timestamps

* Fixed tests

* Cron login guard

* Addressed code review comments

* Change permission column type to JSON

* Addressed code review comments

* Migrate regular staff to a temporary group and disallow groupless staff management

* Look for Super Administrator or legacy `admin` role

* Fixed tests

* Changed test name to make cspell happy

* Grant required permissions to the groups

---------

Co-authored-by: Adam Daley <admdly@users.noreply.github.com>
2026-07-04 20:51:49 +01:00
Adam Daley 5ee72a234a Migrate Email, Extension and Support modules to Doctrine (#3863)
* Migrate Email, Extension, Support modules to Doctrine ORM

* Add 'initialises' to cspell.json custom words

* Add patch76 and fix extension deactivation event

* Bump database patch version to 76

* Refactor Support APIs to mapped Doctrine flows

* Handle legacy email queue and ticket filters

* Migrate Support module to Doctrine ORM

* Refactor services to use typed repositories

* Route order ticket count and ticket messages through repositories

Drops the last two thin Support\Service wrappers, calling the
SupportTicketRepository and SupportTicketMessageRepository directly
from the cross-module callers.

* Rename email queue table and add patch

* Preserve unlimited email queue processing

* Preserve unlimited email queue processing
2026-07-03 10:07:01 +03:00
Adam Daley d7f0ed20a5 Refactor HTTP helpers and centralize response handling (#3877)
* Refactor API request/response HTTP helpers

* Centralize exception and response handling

* Use ResponseEmitter in installer entrypoints

* Add HTTP ResponseFactory and refactor Box_App

* Extract route matching into HTTP matcher

* Fix route param parsing and remove UrlHelper

* Fix exception status code crash and clean up refactor leftovers

ApiResponseFactory::getStatusCode() required an int code, but
Throwable::getCode() can return a string (e.g. PDOException's SQLSTATE),
so any non-FOSSBilling exception with a non-integer code crashed API
error handling with a TypeError instead of returning a JSON error.
Numeric-string codes are normalized to int to preserve prior loose-
comparison behavior; non-numeric codes fall back to the default status.

Also removes now-dead ErrorPage::generatePage(), redundant manual
requires of ResponseEmitter (already covered by composer's classmap
autoload), and duplicate emitResponse() calls in exceptionHandler().
2026-07-02 22:20:10 +01:00
Adam Daley 1efffee98b Handle Twig render failures as 500 errors (#3874)
* Handle Twig render failures as 500 errors

* Fix nested Twig loader error handling

* Fix AppClient missing page test stub
2026-07-02 11:48:08 +01:00
FOSSBilling BotandFOSSBilling Bot ff38258781 Apply PHP Code Styling & Quality Changes (#3858)
Co-authored-by: FOSSBilling Bot <fossbilling-bot>
2026-06-28 20:36:07 +01:00
Adam Daley 719d002005 Handle Stripe invoice paid webhook and normalize currencies (#3857)
* Handle Stripe invoice.paid webhook and normalize currencies

* Handle Stripe webhooks asynchronously

* Update cspell.json

* Handle all Stripe webhook event types

* Handle Stripe invoice subscription changes

* Handle Stripe subscription race conditions

* Filter Stripe webhook noise

* Handle Stripe subscription races safely

* Improve Stripe subscription creation

* Add 4/5-year periods and new tx statuses

* Harden Stripe dedup for redirect/webhook races

* Address code review findings in Stripe webhook and IPN handler

- Fix: handlePaymentIntentFailedWebhook and handleSetupIntentFailedWebhook
  now return true so error transactions are kept rather than written and
  immediately deleted; processWebhookEvent guards against overwriting an
  existing STATUS_ERROR with STATUS_PROCESSED
- Fix: processInitialSubscriptionPayment reloads the invoice from the DB
  before the already-paid guard, consistent with applyOneTimePayment and
  narrowing the TOCTOU race window
- Fix: handleInvoicePaymentSucceeded merges two sequential findOne queries
  for the same invoice into one, using the result for both the already-paid
  check and the billing_reason fallback
- Fix: ipn.php extracts $isJsonWebhook at first evaluation, removing the
  duplicate str_contains() expression inside the try block
- Fix: handleSubscriptionCreated casts invoice_id to int, matching all
  other handlers; test assertion updated from string '5' to int 5

* Fix double-processing and over-broad exception catch in Stripe adapter

- handleInvoicePaymentSucceeded: set txn_id to the Stripe invoice ID and
  check for an existing PROCESSING/PROCESSED transaction with that key so
  that when Stripe fires both invoice.payment_succeeded and invoice.paid
  for the same payment, the second event is silently skipped rather than
  double-crediting the client balance or generating a duplicate renewal
  invoice
- processSetupIntent, handleSetupIntentSucceededWebhook: narrow the
  ApiErrorException catch to idempotency_key_in_use only; rethrow all
  other failures (card declined, auth errors, network issues) so they are
  not silently swallowed and processed against an unrelated subscription

* Fix missing Transaction findOne mock in StripeTest fallback test

The handleInvoicePaymentSucceeded dedup check now queries for an
existing Transaction by Stripe invoice ID before processing. The
'falls back to treating unpaid original invoice as initial payment'
test only mocked the Invoice findOne, so the new Transaction query
had no handler and threw NoMatchingExpectationException in CI.

* Fix spellcheck: replace 'Dedup' with 'Duplicate-event' in comment
2026-06-28 20:01:05 +01:00
Adam DaleyandCopilot Autofix powered by AI c5a6c56d4b Fix for 1 code quality finding in Twig tests (#3855)
Apply suggested fix to tests/Unit/FOSSBilling/Twig/StrictVariablesTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-06-28 09:56:01 +01:00
Adam DaleyandCopilot Autofix powered by AI e01b33ccfe Fixes for 5 code quality findings in Servicehosting (#3854)
* Apply suggested fix to src/modules/Servicehosting/tests/Unit/ServiceTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to src/modules/Servicehosting/tests/Unit/ServiceTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to src/modules/Servicehosting/tests/Unit/ServiceTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to src/modules/Servicehosting/tests/Unit/ServiceTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to src/modules/Servicehosting/tests/Unit/ServiceTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Fix hosting service creation test

* Simplify strict variable test assertions

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-06-28 09:33:05 +01:00
Adam DaleyandCopilot Autofix powered by AI 15b04cb91c Fix for 1 code quality finding in E2E tests (#3846)
Apply suggested fix to tests/E2E/Cypress/support/e2e.js from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-06-28 07:38:18 +01:00
Adam Daley 1e958fc3b9 Migrate document fields to custom client fields (#3839)
* Migrate document fields to custom client fields

* Add 'unmigrated' to cspell dictionary

* Bump last_patch version to 75
2026-06-26 21:35:45 +01:00
Yağızhan Burak Yakar d189ee468e Knowledge base, canned responses and helpdesk enhancements (#3808)
* Migrate the knowledge base to Doctrine

* Addressed code review comments

* Move incrementViews to the repo

* Knowledge base suggestions in support forms

* Improve the UI and make search actually search

* Make the knowledge base enabled on new installs by default

* Redid the kb index to list articles alongside categories

* Display articles in admin manage category

* Redirect authenticated users from guest ticket page to client ticket page

* Address code review comments

* Addressed code review comments

* Improved search accuracy by tokenizing queries

* Updated article layout and added CTAs

* Added a setting to toggle view count's visibility

* Removed contact button from the sidebar

* Migrate canned responses to Doctrine and improve admin UI

* Improved support settings canned dropdowns

* Added a flag to hide view count when serializing

* Improved search query matching

* Migrate SupportHelpdesk to Doctrine

* Fixed tests

* Update copyright headers

* Implemented suggestions (credit @admdly)

* Remove dead test
2026-06-25 23:35:28 +03:00
Adam DaleyandClaude Sonnet 4.6 aefaa01db6 Preserve < and > in ticket/KB messages by using Markdown-safe sanitization (#3830)
* fix(support): preserve < and > in ticket/KB messages by using Markdown-safe sanitization

The WYSIWYG editor (CKEditor) uses the Markdown plugin, so ticket replies
and KB article bodies are stored as Markdown, not HTML. Calling the Symfony
HTML Sanitizer on Markdown content silently corrupts it: when a user types
text containing an unknown tag-like string such as `<World>`, the sanitizer
treats it as an unknown HTML element, drops it, and—because there is no
closing tag—also drops everything that follows, causing the rest of the
message to disappear.

Fix by introducing `Tools::sanitizeMarkdownContent()`, which only strips
null bytes and trims whitespace. XSS protection is already provided at
render time by the `|markdown_to_html` Twig filter, whose underlying
CommonMark converter is configured with `html_input: escape`—any raw HTML
inside the stored Markdown is therefore escaped before it reaches the
browser.

Affected endpoints (all now use the new helper):
- Admin: ticket_reply, ticket_create, kb_article_create, kb_article_update
- Client: ticket_create, ticket_reply
- Guest: ticket_create, ticket_reply

Fixes #3827

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LBnxaZxj968uFFbgoSocLZ

* fix(spellcheck): use American English spelling "unrecognized"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LBnxaZxj968uFFbgoSocLZ

* fix(support): apply markdown-body styling to admin ticket and client KB article views

The admin ticket conversation and client KB article content were rendered
with |markdown_to_html but without the markdown.css stylesheet or the
markdown-body CSS class required by github-markdown-css.  This caused
inline code, fenced code blocks, and other Markdown elements to appear
unstyled (admin) or miscontainerised in a list-group div (client KB).

- Admin ticket: load markdown.css in <head> and wrap message content in
  <article class="markdown-body bg-transparent text-reset">
- Client KB article: load markdown.css in <head> and replace the
  list-group wrapper with <article class="markdown-body bg-transparent
  text-reset">

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LBnxaZxj968uFFbgoSocLZ

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-06-23 19:22:41 +02:00
Yağızhan Burak Yakar ce696d1871 Added a country code selector and number formatter (#3812)
* Added a country code selector and number formatter

* Added parantheses

* Fixed Cypress tests

* Fixed Cypress tests
2026-06-20 18:52:12 +02:00
Yağızhan Burak YakarandAdam Daley 7ade5bbdf3 Unify public tickets with client tickets (#3799)
* Merge public ticket logic into regular client tickets

* Unified email templates

* Unified events and listeners

* Remove passthrough service methods

* Corrected phpDocs

* Create a combined `author` array to replace `client`, `client_id`, `author_name`, `author_email`

* Switch to using "Author" instead of "Requester"

* Switch to using a single endpoint and single template for client and guest tickets

Also left a redirect behind to make sure previously sent emails still have a working link

* Add author_role parameter to onBeforeClientOpenTicket

* Adjusted rate limit ordering

* Update Twig templates and the update patcher

* "Public ticket" -> "Guest ticket"

* Addressed code review comments

* Address code review comments

* Also purge old pticket email templates

* Fix email sending

* Support: enforce auth, fix guest email links

* Migrate mod_support config key name

---------

Co-authored-by: Adam Daley <admdly@users.noreply.github.com>
2026-06-19 19:01:52 +01:00