Commit Graph
64 Commits
Author SHA1 Message Date
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
Adam Daleyandcubic-dev-ai[bot] 60ef50108d Fix duplicate domain activation from stale order object during checkout (#3948)
* Fix duplicate domain activation caused by stale order object

Cart checkout can activate an order that was already activated
synchronously via an invoice paid with account credit, since the
in-memory order held by the checkout loop is never refreshed after
the credit-payment path activates it through its own freshly-loaded
copy. activateOrder() now re-fetches the order before checking its
status, closing the gap that let EPP domain registration run twice
and fail with "Domain is not available: In use".

* Treat already-active orders as a no-op in activateOrder

The reload alone turned the stale-order race into a thrown exception
for orders that were already correctly activated by another code
path in the same request. Cart::checkoutCart()'s catch block then
tried to record an 'error' order status, which isn't a valid status
and threw a second exception that broke the whole checkout. An
already-active order (without force) should just be a no-op success.

* Update src/modules/Order/Service.php

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

---------

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2026-07-09 16:13:13 +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 Daley c207e12313 Skip renewals for pending paid invoice items (#3905)
* Skip renewals with pending paid invoice items

* Add index for pending renewal invoice items

* Adjust invoice_item renewal index definition
2026-07-06 18:13:59 +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 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 DaleyandCopilot Autofix powered by AI 3e933bbfd4 Enforce manage_settings in extension configuration (#3856)
* Enforce manage_settings for extension config

* 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>

* 🔒 Add settings permissions for config modules

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-06-28 10:59:44 +01:00
3b2ca2a92b Apply PHP Code Styling & Quality Changes (#3811)
* Apply PHP Code Styling & Quality Changes

* Fix docblock return type to float

---------

Co-authored-by: FOSSBilling Bot <fossbilling-bot>
Co-authored-by: Adam Daley <admdly@users.noreply.github.com>
2026-06-20 00:49:01 +01:00
Adam Daley febec281a6 Migrate product models and enhance promo redemption functionality (#3587)
* Migrate product models; add `promo_redemption`

* Add DomainPricing & ProductOrder repositories

* Use Promo entity typehints and update tests

* Use DI logger, validate order config, update tests

* Replace `error_log` with logger; use stubs in tests

* Use attachOrderConfig and tighten service checks

* Clarify domain defaults and remove deprecated doc tag

* Add missing indexes to `promo_redemption` table

* Enrich promo API arrays and add redemption filters

* Various UI/JS fixes and template cleanups

* Log invoice issues as warnings; expose form_id

* Normalize spelling in UpdatePatcher comment

* Remove checkLimits production method and clean up stale test mocks

* Use getConfig() and add promo permission

* Use container logger directly, remove helpers

* Use defaults for optional Twig settings

* Import macro_functions into admin template

* Compensate promo redemptions on checkout failure

* 🐛 Fix product category and add-on availability handling
2026-06-18 17:56:14 +01:00
Adam Daley d04256f89c Clear stale unpaid_invoice references, and update queries & tests (#3770)
Clear stale unpaid_invoice refs; update queries & tests
2026-06-14 07:07:55 +01:00
Adam Daley d312170e46 Enhance email template validation and error handling (#3720)
* Add email template validation and error tracking

* Email templates: bulk actions & batch delete

* Add email template syntax checker

* Add last_error to template API; remove error styling

* Add error fields to email_template

* Render templates during validation with vars

* Update crypt mock expectation in Email test
2026-06-04 19:35:48 +01:00
Adam Daley dd3dcbfd52 Enhance type safety, authentication checks, and testing framework (#3701)
* Improve type safety, auth checks and PHPStan fixes (#3250)

* Improve type safety, auth checks and PHPStan fixes

* Remove @phpstan-ignore annotations

* Improve type safety, auth checks and PHPStan fixes

* Remove @phpstan-ignore annotations

* Remove redundant @phpstan-ignore comment

* Improve code robustness and reliability (#3248)

* Harden code against null/undefined values

* Update dependency lockfiles

* Sanitize ticket input and use IDs in email list

* Restructure tests and add test utilities

* Move E2E tests to `Library\E2E` namespace

* Update `php-build` action ref in workflows

* Switch tests to Pest and add test scaffolding

* Refactor E2E tests to Pest-style tests

m

Skip E2E tests when env not configured

* Refactor Unit tests and update test config

Add test datasets and refine test helpers

* Add DEBUG guard, fix API JSON decode, update tests

* Refactor tests: add types and Mockery expectations

* Adjust tests, phpstan config, and composer script

* Instantiate test APIs locally, remove beforeEach

* Refactor runtime checks, types & logging

* Apply PHP Code Styling Changes

m

* Add PHPStan ignores, test renames & small fixes

* Enable Pest tests in CI workflow

* Remove legacy tests; add new unit tests/config

* Avoid undefined index in fingerprint comparison

* Ignore properties absent in both fingerprints

* Remove public_ticket_create API method

* Add Fingerprint unit tests

* Remove em dash from fingerprint test name

* Switch to Pest; assorted bug fixes & refactors

* Prefer getDi() and guard DEBUG define

* Refactor tests: DBAL, Antispam rename, helpers

* Refactor email tests to use Doctrine entities

* Update tests, use DBAL mocks & improve Formbuilder admin

* Validate plan_id and update unit tests

* Replace error_log with DI logger and update tests

* Expect db->store in Invoice Service test

* Use DI logger instead of error_log; fix tests

* Fix typo in Hook Service test

* Fix Staff test spelling fixture

* Complete Pest test migration

* Fix Product test spelling fixtures

* Fix Product test spelling fixtures

* Run live tests with Pest and load helpers

* Migrate tests to ApiClient; remove legacy APIHelper

* Fix Email test spelling

* Remove unused PHPUnit bridge

* Organize Cypress end-to-end tests

* Document Pest test directory root

* Remove noisy Pest comments
2026-06-02 07:43:01 +01:00
Yağızhan Burak YakarandAdam Daley 2d9fb39e4c Add PSR-3 styled logger method names to Box_Log (#3691)
* Add PSR-3 styled logger method names to Box_Log

* Switch to using PSR-3 style method names in logger callers

* Handle writer failures centrally and harden masking behavior

* Fix wrong context format used

---------

Co-authored-by: Adam Daley <admdly@users.noreply.github.com>
2026-06-02 01:58:26 +01:00
a7ef873368 Revamp admin UI and improve dashboard layout and functionality (#3596)
* Adjust admin alerts and installer warning

* Make dashboard cards full-height and align badges

* Split dashboard cards into partials and add AJAX

* Replace status badges with ribbon elements

* Revamp activity panel layout and responsiveness

* Adjust dashboard card spacing and styles

* Style dashboard links and adjust chart heights

* Back-to-top: update classes and styles

* Fix client admin UI labels and flags

* Improve API response parsing and errors

* Mark action columns no-sort, add table-hover

* Update table classes for hover and wrapping

* Refactor admin templates to card-header layout

* Update admin templates layout and semantics

* Tidy admin templates; remove tabs, update notice

* Standardize admin alert styles and messages

* Handle null/empty status in status_name macro

* Validate resolved renewal price before invoicing

* Keep IP actions inline in activity table

* Right-align activity pagination controls

* Align pagination and export buttons in admin lists

* Improve admin pagination & per-page defaults

* Extract record selector into partial

* Add tab deep-linking and URL hash persistence

* Refactor search controls & capitalize 'One Time'

* Refactor client search filters and toggle state

* Refactor activity filters UI and tomselect styling

* Redesign admin filters; capitalize 'On Hold'

* Revamp admin filter panels (Invoice & Support)

* Group search clause in Massmailer query

* Add filters and expanded search for pages/gateways

* Add filter panels, refine search logic, tests

* Add advanced search filters for activity modules

* Add structured filters, date/ip search & tests

* Add Email queue filters and admin tab

* Add collapsible filter panel to Staff settings

* Refactor badges to use shared macros

* Add massmailer statuses & boolean badges

* Add search icon and refine search input layout

* Update admin templates layout and markup

* Use modals for creating clients/groups

* Centralize tab header action buttons

* Centralize toolbar actions; add Order modal

* Bump Composer dependencies (lockfile)

* Capitalize 'One Time' payment label

* Return raw API body; use button for search

* Wrap search button in input-group-text

* Make search max width configurable

* Fix malformed aria-label Twig expression in layout_default.html.twig

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/c8db6ba9-bda4-413a-989f-e4777e06bd12

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Fix XSS risk in updateExternalIP: append IP via createTextNode instead of innerHTML concat

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/0c435e52-1784-4466-a8dc-c41e12443a6f

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Refactor New Client modal layout and styles

* Limit and style phone country code field

* Use `country_names` helper and `country_name` filter

* Use Symfony Intl for currencies & locales

* Use Symfony Intl for currencies; drop built-in country lists

* Refactor Currency module API, entity and service

* Remove system checkLimits usages from modules and tests

* Remove `currency.title` column and update APIs

* Add inputmode and maxlength to cspell dictionary

* Fix dropdown toggle accessibility: use button instead of anchor

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/b7f9474b-1988-4c08-aec0-f8991edfea71

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Improve multi-currency handling and installer

* Log currency code when changing cart currency

* Use removeCurrency in Admin API and update tests

* Use Intl currency symbols and fraction digits

* Use currency filters in templates

* Rename currency title to name and update schema

* Remove deprecated Service::getLanguages

* Capitalize system permission labels and fix messages

* Use Symfony Countries and remove phone codes list

* Validate country codes; use country select

* Set fb_locale cookie and fix admin locale display

* Validate locales and add default locale selector

* Use Locales::getNames; tweak language selector CSS

* Tweak header spacing and make nav links icon-only

* Localize client login texts

* Add phone country-code attrs and styles

* Center .modal-dialog in two themes

* Add phone_codes API to list calling codes

* Make form the modal-content wrapper

* Move create forms to Bootstrap modals

* Convert new-item tabs to modals in admin UI

* Revamp admin UI, embed snippets & modal

* Revamp admin settings UI and templates

* Revamp Formbuilder & Redirect admin UIs

* Add 'Segoe' and 'minmax' to cspell dictionary

* Rename warning() to warn() in test logger

* Refactor admin templates to card-based layout

* Expose initAvatars globally and scoped init

* Add 'view' permissions and enforce checks

* Refactor Servicehosting admin UI and scripts

* Add staff permission checks and module permissions

* Refactor admin templates layout and forms

* Add staff permission checks and module perms

* Add staff permission checks and module perms

* Refactor admin Twig templates and UI

* Refactor client admin UI to use summary/form cards

* Refactor admin invoice/subscription/transaction templates

* Refactor Order admin UI; fix country labels

* Refactor admin templates and add IP country filter

* Add 'view' permissions and checks to admin APIs

* Use detail/related partials in admin templates

* Refactor admin product templates to use partials

* Add endembed to cspell ignoreWords to fix spellcheck CI failure

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/e8973bef-7364-4b30-8dd8-13701ca15c5d

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Refactor admin templates to use common partials

* Validate order status, add permission checks

* Center form buttons and add horizontal padding

* Introduce createAdminApi and BBTestCaseContainer

* Refactor admin UI templates and forms

* Run intl compression after composer install

* Disable provenance in buildx outputs

* Revamp admin templates for UI and previews

* Refactor admin templates, pricing UI & styles

* Refactor admin invoice sidebar and SEO settings UI

* Use minor currency units, country list & API fixes

* Rename language selector class to locale-selector

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>
2026-05-24 23:10:28 +01:00
FOSSBilling Bot c421efba3a Apply PHP Code Styling & Quality Changes (#3527) 2026-05-13 00:44:26 +01:00
b49ccb9df8 Sanitize invoice handling, enhance security, and improve API responses (#3524)
* Sanitize invoice hash and secure asset paths

* Guard against missing client session

* Serialize invoice items into indexed inputs

* Validate URL field input type before checking

* Block legacy paid support hooks on ticket create

* Harden CSRF token validation in API client

* Add 'Paidsupport' to cspell word list

* Use Stripe metadata to link client and invoice

* Remove legacy Paidsupport hooks handling

* Add paidsupport to cspell word list

* Use config debug flag; always warn if install exists

* Revert "Use config debug flag; always warn if install exists"

This reverts commit fda6fcc0b05758d897a837d125ce1c0a35be0226.

* Fix for pull request finding

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

* Fix for pull request finding

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

* Fix Stripe getClientFromTransaction and simplify UpdatePatcher cache invalidation

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/49a72bff-61f2-4a3e-9107-08aec7b255d2

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Fix for pull request finding

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

* Restrict Dompdf logo remote URLs to http/https schemes only

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/58c16027-cc36-4c11-a039-0bfcaf5a45f5

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Enable Buildx cache and add release archive

* Restrict `claimForProcessing` SQL and update tests

* Add HTML sanitizer and sandboxed Twig rendering

* Update test expected HTML in ServiceTest

* Add `RequestFactory` and trusted proxy support

* Use HttpFoundation Responses & Request everywhere

* Return HTTP Response objects for exports/downloads

* Refactor request routing, auth errors and CSV export

* Remove RequestFactory wrapper and minor cleanups

* Specify Response union return types

* Parenthesize response constructions before send

* Clean up PHPStan ignore rules

* Relax HTML test to accept optional tbody/br

* fix(theme): call getUploadedAssets without arguments

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/ce04bff6-ccde-4a10-8a68-f6278b1b550e

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>
2026-05-12 00:10:49 +01:00
deda7c6194 Refactor admin "mark as paid" Invoice functionality to be more robust (#3505)
* Remove order-level invoice paid shortcut

* Add admin 'mark invoice paid' flow for orders

* Fix for pull request finding

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

* Trim admin custom gateway transaction ID before storing

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/b1ec86d8-1fae-4a33-b704-15f9cc3d6baa

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Fix test gateway ID and correct create() docblock return type

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/b63acd4a-b280-4e35-934a-29c15bf78e8c

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Fix for pull request finding

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

* Prevent duplicate transactions for already-paid invoices and fix API docblock

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/bf20ed38-ab95-4e4f-9a60-3624ca688d59

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Use strict comparison for invoice status check

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/bf20ed38-ab95-4e4f-9a60-3624ca688d59

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Wrap order creation in transaction

* Add DB transaction helper and update Order service

* Fix for pull request finding

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

* Fix for pull request finding

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

* Fix boolean normalization security issues in mark_invoice_paid flow

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/15c7eb69-841d-408c-94be-a22dc07c67f4

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Import Tools and use it in Invoice Service

* Move invoice approve/mark-paid outside transaction to prevent side effect inconsistencies

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/58dcd4cb-ec49-4d31-ba25-224f1d742199

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Fix syncMarkInvoicePaidControls() initialization for AJAX-rendered contexts

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/58dcd4cb-ec49-4d31-ba25-224f1d742199

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Improve code clarity with better comments for transaction safety

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/58dcd4cb-ec49-4d31-ba25-224f1d742199

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Handle invoice follow-up errors and use model

* 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 <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>
2026-05-11 19:45:54 +01:00
Adam DaleyandCopilot Autofix powered by AI 38aa818aa1 Reject non-scalar select/radio config values (#3504)
* fix(order): reject non-scalar select/radio config values

* 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 <175728472+Copilot@users.noreply.github.com>
2026-05-10 15:31:22 +01:00
Yağızhan Burak Yakar 236e6a8572 Added type casting to more places (#3496) 2026-05-08 06:00:58 +01:00
b2f4cb8ffa Enhance API rate limiting, validation, and subscription features (#3459)
* Validate redirect paths and targets

* Sanitize guest client data and misc cleanups

* Implement API rate limiting and pruning

* Bump `last_patch` setting to 54

* Add tests for `shouldUseTokenLogin` logic

Add tests to cover logic added in #3451.

* Add order/renewal line config for domain pricing

Resolves #2793.

* Add PayPalEmail adapter subscription test

* Add width/height styling for textarea fields

Resolves #2448.

* Send invoice-created email on approve

Resolves #3012.

* Enforce cumulative cart stock and stockSale

Resolves #3130.

* Centralize subscription period retrieval

Resolves #1035.

* Support wildcard staff permissions (default.all)

Resolves #2376.

* Enable quantity selection and enforce stock max

Resolves #2573.

* Extend order expiry on first paid invoice

Resolves #2864.

* Rate-limit request prefix; invoice & promo fixes

* Update src/modules/Redirect/templates/admin/mod_redirect_settings.html.twig

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

* Update src/modules/Api/Service.php

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

* Update src/modules/Client/Controller/Client.php

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

* Update src/modules/Cron/Service.php

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

* Fix quantity not passed to getOrderLineConfig in createOrder

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/669f845c-50c4-4f7e-95cd-f44de162ad72

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Simplify quantity injection into getOrderLineConfig call

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/669f845c-50c4-4f7e-95cd-f44de162ad72

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Fix rate limit prefix isolation, whitelist headers, and staff controller prefix

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/11f3fd58-bb44-46a5-a6cf-0992b038f4a7

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Enforce promo usage limit and add test

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>
2026-04-28 22:11:39 +01:00
Adam Daley 435944defa Refactor pagination and API with strict types and validation (#3391)
* Add strict types; refactor pagination, tools & API

* Replace `Box_Paginator` with FOSSBilling `Paginator`

* Clarify paginator comment wording

* Validate JSON response and include HTTP code

* Cast language params to bool and add JSON preview
2026-04-06 22:06:13 +01:00
9c2a4d521c Add file-backed email templates (#3372)
* Add `is_custom` and file-backed email templates

* Detect and handle missing default email templates

* Standardize capitalization in email templates

* Group OR conditions with parentheses in queries

* Add `is_custom` and file-backed email templates

* Detect and handle missing default email templates

* Standardize capitalization in email templates

* Group OR conditions with parentheses in queries

* Fix test expectations to match updated OR condition SQL format

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>
Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/932b3ffe-6478-4ed4-b74d-a1af2681ff0d

* Update src/modules/Email/templates/admin/mod_email_template.html.twig

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

* Wrap order status OR conditions in parentheses

* Add tests to preserve client scope in searches

* Optimize `getTemplateList`: DB-level filtering/pagination, remove per-request batch sync (#3373)

* Optimize getTemplateList: DB-level filtering, pagination, remove templateBatchGenerate from list

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>
Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/fab0e6c0-51ef-4501-98f8-f5ab823816ab

* Fix test: remove stale decrypt expectation now that list uses deep=false

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>
Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/6a891d33-a7dc-436d-9bd2-4a48923d91d7

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Add test for resetting custom email template

* Add `is_overridden` flag for email templates

* Improve detection of overridden email templates

* Update src/modules/Email/Service.php

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

* Detect template overrides by comparing defaults

* Migrate Email module to Doctrine

* Ignore whitespace when comparing email templates

* Use Doctrine `EmailTemplate` repo; update tests

* Avoid re-enabling templates; handle rows

* Add email template schema check and row mapping

* Add Type and Status columns to email templates

* Limit run-patcher & remove email schema migration

* Update tests-legacy/modules/Email/Api/Api_AdminTest.php

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

* Update src/library/FOSSBilling/UpdatePatcher.php

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

* Update src/modules/Email/Service.php

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

* Update src/modules/Email/Service.php

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

* Update tests-legacy/modules/Email/ServiceTest.php

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

* Fix getTemplateList skipping EmailTemplate entities from pagination result (#3379)

* Initial plan

* Fix getTemplateList to handle EmailTemplate entities from pagination result

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/5567a644-4032-40aa-a6af-8eda8cbcea36

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-28 03:38:20 +00:00
Adam Daley 717953f1f3 Fix manual order form_id, add invoice product selector, and improve tab & URL parameter support (#3172)
* Fix multiple issues: #2902, #2831, #2774, #2794

- Fix #2902: Save form_id when admin creates order manually
- Fix #2831: Add product dropdown when preparing invoice
- Fix #2774: Support ?tab URL parameter to pre-select tabs
- Fix #2794: Support URL parameters for pre-selecting order form values

For issue #2902:
When admins create orders manually, the form_id field was not being saved,
preventing form builder fields from appearing in "Edit order config" tab.
Now saves form_id from product to maintain compatibility.

For issue #2831:
Added product selector to invoice preparation form that allows admins to
select products from existing catalog instead of manually typing
product names and prices. Selected products are added as invoice items.

For issue #2774:
Added URL parameter parsing to pre-select tabs when page loads.
Supports ?tab=tabname parameter in URLs, useful for pagination and
direct links to specific tabs.

For issue #2794:
Added URL parameter support for pre-filling order form values:
- period: Pre-select billing cycle (e.g., ?period=1Y)
- name: Pre-fill domain name (for domain orders)
- tld: Pre-select TLD (for domain orders)

* Fix JavaScript syntax error - remove duplicate DOMContentLoaded event listener

* Enhance invoice product selection and admin JS

* Clarify client selector placeholder text

* Pre-fill domain form via URL params
2026-03-24 01:17:46 +00:00
e18fe0062d Set form_id from product when admin creates order (#3365)
* Set `order form_id` and validate config

* Update src/modules/Order/Service.php

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

* [WIP] [WIP] Address feedback on setting form_id in order creation PR (#3366)

Initial plan

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* fix(Order): Render formbuilder fields in Edit order config tab

When an order has a form_id, the Edit order config tab now renders all
formbuilder fields with proper input types (text, select, checkbox,
radio, textarea) instead of just showing existing config keys.

This completes the fix for admin-created orders not showing formbuilder
fields in the order config editor.

Fixes #2902

* Add unit tests for `updateOrderConfig()` form validation paths (#3367)

* Initial plan

* Add unit tests for updateOrderConfig() validation (required field, select/radio/checkbox options)

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>
Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/3fe9a767-5075-4d33-9e2c-cee02f03c7f1

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>
2026-03-24 00:07:54 +00:00
Adam Daley 27b1d927d4 Improve file handling, safety, and default values (#3353) 2026-03-19 19:30:19 +00:00
FOSSBilling BotandFOSSBilling Bot 1f292eaa8a Apply PHP Code Styling & Quality Changes (#3257)
Co-authored-by: FOSSBilling Bot <fossbilling-bot>
2026-02-19 13:53:24 -08:00
Adam DaleyandCopilot be32531432 Add Client Dashboard API endpoint (#3142)
* Add Client Dashboard API endpoint

Add new consolidated API endpoint for the client dashboard that reduces the number of individual API calls needed to render the dashboard.

* Apply suggestions from code review

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

* Add batch API methods for orders and tickets

Introduces `getBatchForApi` methods in Order and Support services to efficiently fetch multiple orders or tickets for API responses. Refactors Index Service to use these batch methods for recent orders and tickets on the client dashboard, improving performance and reducing database queries.

* Refactor DB queries and total calculation logic

Updated `Index/Service.php` to use getAll and array_column for fetching IDs, improving clarity and consistency. Refactored `Order/Service.php` to centralise total calculation in a new private method, ensuring type safety and reducing code duplication.

* Remove unused parameter from `get_dashboard` method

The get_dashboard method in Client no longer requires the $data parameter, simplifying its signature.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-07 04:01:21 +00:00
Belle Aerni 0a156f4161 Fix CS automation (#3209)
* Restore needed gitignore

* Ran the fixes since they are far behind

* Fix for rector causing a problem. Re-ran.

* Update ServiceTest.php
2026-01-26 11:18:35 -08:00
Adam DaleyandCopilot 0c44c7f624 Replace PDO usage with Doctrine DBAL (#2964)
* Refactor database connection to use `DriverManagerFactory`

* Add Doctrine DBAL connection to DI container

Revert "Add Doctrine DBAL connection to DI container"

This reverts commit bc2f9f4901d8baee4b12cd2795b0ef76156849cf.

Reapply "Add Doctrine DBAL connection to DI container"

This reverts commit 48debb74bbfa6c8cebf27ee20c222c911d508ccb.

* Refactor database access to use Doctrine DBAL

* Refactor DB config to use 'driver' instead of 'type'

* Refactor database connection to use `DriverManagerFactory`

* Add Doctrine DBAL connection to DI container

Revert "Add Doctrine DBAL connection to DI container"

This reverts commit bc2f9f4901d8baee4b12cd2795b0ef76156849cf.

Reapply "Add Doctrine DBAL connection to DI container"

This reverts commit 48debb74bbfa6c8cebf27ee20c222c911d508ccb.

* Refactor database access to use Doctrine DBAL

* Refactor DB config to use 'driver' instead of 'type'

* Refactor tests to use `dbal` mocks

* Replace `getQueryBuilder` with `createQueryBuilder

* Fix handling of empty query results and cleanup exception comment

* Update Composer lock file

* Refactor PDO initialization in DI container

Updated the DI definition for 'pdo' to directly use the PDO instance returned by Doctrine's DriverManagerFactory, removing unnecessary object casting. Also added missing import for DriverManagerFactory. Updated PHPStan config to remove a redundant ctype_alnum rule.

* Refactor query execution and result fetching logic

Updated database query handling in Extension and System Service classes to separate query building from execution and fetching. This improves code clarity and ensures consistent use of fetchOne for single-value results.

* Fix SQL where clause syntax in Service.php

Corrects the syntax of the where clause in several queries by changing 'where('param', ':param')' to 'where('param = :param')' for proper parameter binding and query execution.

* Refactor Stats module to use Doctrine DBAL

* Refactor Custompages Service to use dbal instead of pdo

Replaced all direct PDO usage with dbal methods for database operations in the Custompages Service. This improves consistency, leverages dbal's abstraction, and prepares the codebase for better maintainability and future enhancements.

* Refactor DBAL usage and update test mocks

Refactored DBAL service definitions and query builder usage to improve clarity and consistency. Updated tests to use anonymous classes for DBAL and query builder mocks instead of PHPUnit mock objects, simplifying test setup and improving maintainability.

Co-Authored-By: Copilot <175728472+Copilot@users.noreply.github.com>

* Refactor DB queries to use executeQuery and executeStatement

Replaced manual PDO prepare/execute calls with Doctrine DBAL's executeQuery and executeStatement methods in UpdatePatcher and ApiRequestTable. This improves code consistency and leverages DBAL features for query execution and result fetching.

* Add input validation for DB charset, table, and column names

Introduces strict validation for supported database charsets in DriverManagerFactory, allowed column names in Custompages Service, and allowed table names in Stats Service to prevent invalid or unsafe input. Also updates UpdatePatcher with default values for new config keys and adjusts a Stats Service test to use a valid table name.

* Add 'CHARSETS' to cspell custom words list

* Refactor query execution in patcher and product domain

Updated query builder usage in UpdatePatcher and ProductDomainTable to separate query building from execution, aligning with best practices. Removed unused fetchOne stubs from ServiceTest to reflect these changes.

Co-Authored-By: Copilot <175728472+Copilot@users.noreply.github.com>

* Refactor `getProductSummary` to use Doctrine DBAL

* Fix parameter binding for category and hash in UpdatePatcher

Updated the insert statement in UpdatePatcher to bind the 'category' and 'hash' parameters explicitly, ensuring correct handling of null values during database insertion.

* Update MySQL charset handling in PDO setup

Removes redundant charset initialization statements for MySQL connections, relying on DBAL to handle connection charset via DSN. Now only sets the server default charset and session timeouts.

* Set default DB driver to `pdo_mysql` in `UpdatePatcher`

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-25 13:02:23 +00:00
01612b9146 Dropped Paidsupport and Servicemembership (#3066)
* Dropped the "Paidsupport" module

* Patch to migrate existing orders and products to "custom"

* Dropped the "Servicemembership" module

* Update src/library/FOSSBilling/UpdatePatcher.php

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

* Update src/library/FOSSBilling/UpdatePatcher.php

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

* Improve PHPStan compatibility and static analysis

Added a PHPStan ignore pattern for polyfilled ctype function parameter count errors. Updated Extension Service to explicitly check variable type before calling ctype_alnum, aiding static analysis tools like PHPStan.

* Remove polyfill-php72 and update dependencies

Removed 'symfony/polyfill-php72' from composer.json replace section. Updated composer.lock with new versions of league/csv, php-debugbar/php-debugbar, phpunit/php-code-coverage, and rector/rector.

* Update `last_patch` setting to version 47

Incremented the 'last_patch' value in the settings table from 46 to 47 to reflect the latest patch version.

---------

Co-authored-by: Adam Daley <admdly@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-27 22:42:37 +00:00
b41aad26ce Migrated the Currency module to Doctrine (#2963)
* Migrated the Currency module to Doctrine

* Caching and other improvements

* Types, error handling and other improvements

* Don't return false but throw an exception

* Types

* Refactor currency model usage to new Currency entity

* Remove Fastnetmon submodule

Deleted the Fastnetmon submodule from src/modules. This change may be part of a cleanup or migration away from using Fastnetmon as a submodule.

* Refactor currency API admin get test

* Fix failing Currency-related tests after Doctrine migration

Updated test files to work with the new Doctrine-based Currency implementation.

* Refactor currency retrieval to use repository

* Refactor Currency database handling in several services and tests

* Replace anonymous class mocks with standard PHPUnit mocks in Invoice tests (#3037)

* Refactor currency retrieval and currency service

* Apply suggestions from code review

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

* Confirm updateCurrencyRates() method signature alignment (#3034)

* Add null check for currency in Cart::toApiArray to prevent fatal error (#3035)

* Initial plan

* Add null check for currency in toApiArray method

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Initial plan

* Replace anonymous class mocks with standard PHPUnit mocks for consistency

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

---------

Co-authored-by: Adam Daley <admdly@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Fix incorrect getRateByCode call in Order service (#3039)

* Initial plan

* Fix getRateByCode call and add null check with proper exception

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Fix silent failure in Currency::getBaseCurrencyRate when currency not found (#3040)

* Initial plan

* Throw exception when currency not found in getBaseCurrencyRate

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Use FOSSBilling\Exception for currency conversion rate failures (#3041)

Use FOSSBilling\Exception for conversion rate fetch failures

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Remove problematic reflection usage in Cart service tests (#3042)

Remove problematic reflection usage in Cart test

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Update tests-legacy/modules/Cart/Api/GuestTest.php

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

* Update src/modules/Currency/Service.php

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

* Update src/modules/Currency/Entity/Currency.php

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

* Use FOSSBilling\Exception for null currency check in Cart service (#3058)

* Initial plan

* Use FOSSBilling\Exception for null currency check in Cart service

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Use consistent error message for default currency not found

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Remove silent fallback in CurrencyRepository::findDefault() (#3057)

* Add logging for default currency fallback behavior

- Log warning when no default currency is found and falling back to ID 1
- Log critical error when neither default currency nor ID 1 exists
- Clarify return type documentation
- Cache result even if null to avoid repeated warnings

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Remove silent fallback to currency ID 1 in findDefault()

Instead of silently falling back to currency ID 1 when no default
is found, the method now returns null and lets callers handle it.

This addresses the feedback about the silent fallback hiding
configuration issues. All existing callers already properly handle
null by throwing exceptions, so this change makes the error
visible rather than hidden.

Benefits:
- No silent failures hiding misconfiguration
- Cleaner separation of concerns (repositories for data access only)
- Better adherence to Doctrine repository pattern
- All callers already handle null appropriately

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Remove redundant documentation in findDefault()

Simplified @return annotation to avoid redundancy with the description.

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Fix Currency entity getId() to handle uninitialized state (#3059)

Make Currency::getId() return nullable int to prevent runtime errors

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Remove static cache from CurrencyRepository to fix long-running process issues (#3061)

* Initial plan

* Remove static cache from CurrencyRepository to fix long-running process issues

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Fix inconsistent null handling in CurrencyRepository::getRateByCode callers (#3062)

* Fix null handling in Invoice/Service.php getRateByCode call

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Fix Invoice test to mock getRateByCode with valid return value

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Refactor Qwen `settings.json` structure and update version

* Verify null handling consistency in CurrencyRepository::getRateByCode (#3073)

Initial plan

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Update src/modules/Order/Service.php

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

* Update src/modules/Currency/Service.php

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

* Update src/modules/Currency/Repository/CurrencyRepository.php

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

* Update src/modules/Currency/Service.php

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

* Update src/modules/Currency/Service.php

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

* Improve return type annotation for Currency Admin API get_pairs method (#3075)

* Initial plan

* Improve return type annotation for get_pairs method in Currency Admin API

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Fix return type description to accurately reflect the return format

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Fix nullable type inconsistency in Currency entity setCode/getCode methods (#3074)

* Initial plan

* Fix nullable type in Currency entity setCode and getCode methods

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Fix PHPUnit test failures by updating mock return values for getCode

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Restore deleted Cart API Guest tests for Doctrine Currency migration (#3076)

* Initial plan

* Restore deleted Cart API Guest tests and update for Doctrine Currency migration

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Fix testAddItemSingle mock to return boolean instead of cart object

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Refactor currency handling in `Cart` and `Invoice` services

Updated `Cart` and `Invoice` services to consistently use `CurrencyRepository` for retrieving currency entities and default currency. Improved error handling for missing currencies and updated related tests to mock new repository methods. Also fixed minor typos and improved code clarity in tests.

* Refactor currency handling in `Cart` Service

Replaced direct property access of currency code and conversion rate with getter methods in `Cart` Service. This improves encapsulation and consistency when handling currency-related operations.

* Update src/modules/Cart/Service.php

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

* Update tests-legacy/modules/Order/ServiceTest.php

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

* Update src/modules/Currency/Service.php

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

* Update src/modules/Currency/Entity/Currency.php

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

* Fix exception signature and type hint in `Currency` service

Updated the exception thrown in `validateCurrencyForma`t to include a null second parameter for compatibility. Also added a return type to the closure in `Cart` `ServiceTest` for better type safety.

* Refactor currency selection logic in `Cart` Service

Improves clarity by separating client currency retrieval and default currency fallback. Ensures that the default currency is only checked and exception thrown if both client and default currencies are unavailable.

* Add precision handling and caching for Currency conversionRate property (#3082)

* Add documentation and caching for conversionRate precision handling

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Use sprintf for float-to-string conversion to avoid scientific notation

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Fix Doctrine identity map caching issue when changing default currency (#3081)

* Fix Doctrine identity map caching issue in setAsDefault method

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Store currency code before clearing identity map to avoid detached entity access

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Fix PHPUnit test for setAsDefault method by mocking findOneByCode and clear

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Refactor currency test mocks for static data providers

Replaces direct mock object creation in static data providers with string flags or placeholders, enabling proper mock instantiation within test methods. Updates test signatures and logic to handle these flags, improving test maintainability and compatibility with PHPUnit static context constraints.

---------

Co-authored-by: Adam Daley <admdly@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>
2025-12-24 02:28:57 +00:00
Adam Daley a9b903c222 Codebase modernisation, configuration cleanup, and improved type safety (#2957)
* Refactor tests to replace depreciated functions

* Update Rector config and dependencies

* Rector: Add explicit string casting for stricter type safety

* Rector: Add return type hints to methods across codebase

* Rector: Increase dead code level and refactor invoice item logic

* Remove unnecessary `willReturn` from test mocks

Eliminate redundant `willReturn(null)` and similar calls from PHPUnit mock setups in legacy module tests, leaving only method expectations. Also update some test values to use floats for consistency.

* Refactor API controller and email adapter return values

* Update formatting and guidelines in `AGENTS.md`
2025-10-11 23:39:44 +01:00
Belle Aerni 996ff15a3e Partial revert of added strict types (#2881) 2025-08-29 15:06:49 -07:00
Adam DaleyandCopilot 315f9f3944 Refactor Filesystem and Path handling (#2836)
* Removed legacy files

* Refactor Filesystem and Path handling

* Removed `FOSSBilling\Tools` legacy functions

* Update live-tests to include file check for `php_error.log`

* Update Extension module tables to fix wrapping issue

* Apply suggestions from @Copilot

Co-Authored-By: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Extension module icon URL handling

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-08-09 21:50:11 +01:00
Belle Aerni 1c7b15e700 Fix a bunch of exception logging (#2850) 2025-08-07 13:06:56 -07:00
5da80c043a Fix renewal date extension issue when marking first invoice as paid. (#2750)
* Incorrect renewal date extension

* Update src/modules/Order/Service.php

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

* Fix Order Service Test

* Add PHPDoc for `findPaidInvoicesForOrder`

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

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Adam Daley <admdly@users.noreply.github.com>
2025-05-31 03:08:36 +01:00
Belle Aerni 368f8cd6ad Bump the year (#2581) 2025-01-23 15:11:53 -08:00
Belle Aerni 549b05af3e Slight cleanup of the library folder (#2260)
* Slight cleanup of the library folder

* Test fixes

* More fixes for the tests
2024-05-01 15:36:59 -07:00
Belle Aerni 303f4cfa2d Code styling & rector config improvements (#2254)
* Bumped the Rector deadcode level

* Added the instanceof setlist

* Increasded type coverage and updated tests config too

* Bumped type coverage & ran PHP-cs-fixer
2024-04-23 10:38:18 -07:00
Belle Aerni 96dcfce0c6 Some UI & usability improvements (#2215) 2024-04-03 12:31:56 -07:00
Belle Aerni f7de859af0 Allow admins to force deletion of orders (#2207)
* Allow admins to bypass deletion errors for orders

* Code styling
2024-03-26 08:50:38 -07:00
Belle Aerni 9f7daf82eb Very minor fixes (#2199)
* Resolve various errors

* Fix a copy & paste error
2024-03-21 22:04:30 -07:00
Belle AerniandJohn @ S4 037acce702 Bulk fix of many grammar / phraseology mistakes (#2166)
* Bulk fix of many grammar / phraseology mistakes

* Small fixes after self-review

* Corrections

* Update mod_currency_settings.html.twig

* Update mod_currency_settings.html.twig

* Update mod_formbuilder_field.html.twig

---------

Co-authored-by: John @ S4 <64874788+John-S4@users.noreply.github.com>
2024-02-27 03:01:07 -08:00
Belle Aerni d771457efc Bump the year (#2167)
* Bump the year

* And fix the spelling
2024-02-25 02:45:38 -08:00
Belle Aerni 50043e6211 Run Rector against our tests (#1761)
* Update rector config to include tests

* Run Rector against the tests

* Delete test-results

* Update .gitignore

* Correctly set the PHP min to 8.1, split the configs

* Corrected PHPDoc

* Deleted tests we can't really get to pass

PHPunit is hard-coded to fail when a class has a return type of `never`, which is the correct return type of our redirect function (and rightfully so).

No way to disable the exception as far as we can tell
2023-11-11 18:41:09 +00:00
Belle Aerni 602b537996 Opt-in error reporting via Sentry.io (#1732)
* Began implementing Sentry.io support

* Added to the installer

* Added the ID to the bug report template and UI

* Hook it into our error handler, added the ability to filter by error code

* Attempting to add the DSN via GH actions

* Spelling and making PHPstan happy

* Skip exceptions for various incomplete configurations

Also brings in some of the category suggestions made by @Anuril in #195

* Update tests to account for changes

* Added & renamed exception classes

* Fix tests

* Change a bunch of items to be InformationExceptions

* Use a lighter HTTP client, fixed API error reporting

* I guess that's not needed now?

Arighty then

* Improvements, additional info added

* Update SentryHelper.php

* Improved error logging, added instance ID to error page

Also made it so that errors are correctly sent to Sentry rather than exclusively exceptions

* Make the tests happy

* Added the link, improved wording

Also removed the "performance" part of the reporting as it needs to be added to the front-end and I'm not currently implementing that

* Began implementing UI alerts and info

* Added the ability to toggle, fixed tests, use path constants

* Added some useful info & links to the page

* These should be InformationException

* Fix the automated Sentry DSN entry

* Fix the install number text

* Minor cleanup, converted more to InformationException

* Replaced some direct config references with constants

We have the BB_DEBUG constant to indicate if we have debug mode enabled or not, so we shouldn't be directly referencing it in the config file unless we actually need to do so.

Using the constant means there's less locations to update the reference if the config structure is changed

* Bugfix

* Consistency & fixed a PHPDoc

* Corrections

* We actually do want exceptions thrown here

* Change how we get the instance ID

* Stability improvements

Having support for translatable error pages was proving to be problematic, so I had to remove it.

I also had to update the exception class to handle cases where the trans function wasn't setup yet (needed for the /run-patcher page if an error occurs)

* Missed this change on git

* Also fix the variable names...

* Re-added new deps after rebase

* This should also accept "Error" types

* Added more info to the bug report and removed a dug line

* This wasn't supposed to get renamed

* Updated some missed references to Box_Exception
2023-10-28 18:40:39 -07:00
FOSSBilling Bot 1970b320e1 Apply PHP Code Styling & Quality Changes (#1617) 2023-09-19 17:22:00 +03:00
fefbcd21b0 Apply PHP Code Styling & Quality Changes (#1498)
* Apply PHP Code Styling & Quality Changes

* Delete these

* Update .gitignore

* Fixes for PHPStan

* Ignore spelling in the gitnore

* Allow null for that type

Honestly doing so makes ZERO sense, but it matches the current behavior.

---------

Co-authored-by: FOSSBilling Bot <fossbilling-bot>
Co-authored-by: Belle Aerni <belleaerni@gmail.com>
2023-07-30 08:57:44 -07:00
Yağızhanandfossbilling-bot fd872ac941 Implement PHP-CS-Fixer as an automated workflow (#1240)
* Implement PHP-CS-Fixer as an automated workflow

* Apply PHP-CS-Fixer changes

---------

Co-authored-by: fossbilling-bot <121974958+fossbilling-bot@users.noreply.github.com>
2023-07-30 06:49:11 -07:00
Yağızhan d909d77f7e -Unnecessary whitespace in the class headers (#1219) 2023-05-07 13:24:29 -07:00