Commit Graph
120 Commits
Author SHA1 Message Date
89b9102787 Enforce active status checks and validate staff permissions (#3591)
* Enforce order active status checks

* Default missing form field flags to 0

* Validate and enforce staff permission updates

* Use `createStub` in Staff tests

* Enforce permission checks for bank params

* Allow client profile/logout pages w/o validation

* Set order status to active in Api_ClientTest

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

* Add testServiceNotActiveException for non-active order status guard

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/2a58a630-cf21-4358-804d-9a9d8be70d21

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

* Use FOSSBilling\InformationException in Admin API

---------

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-20 00:14:54 +01:00
fc619fabc0 Enhance payment UI, add locale settings, and improve email templates (#3575)
* Add `auto_detect_locale` setting, API, UI and tests

* Add public tickets toggle and templates

* Add meta descriptions and OG/canonical tags

* Render invoice gateways as logo buttons

Replace plain radio labels for invoice gateways with a styled button-like radio group: add helper text, wrap gateways in a flex container, generate unique input IDs (`order-gateway-<id>`), use `btn-check` inputs with `.btn` labels showing gateway logos (or title fallback), include tooltip and `aria-label`, and retain the original currency filtering and first-item checked behavior. This updates markup/CSS classes for improved UX and visual clarity without altering payment selection logic.

* Remove plaintext password exposure

* Client welcome email, password reset & tests

* Refactor admin system messages to alerts

* Fix password reset audit IP source

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/d307ec12-1c92-4e31-9369-9d74d3be7a04

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

* Use Tools::normalizeBoolean for localization settings

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/8329021b-ded8-4906-9615-fb48472ac4b4

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>
2026-05-17 03:03:03 +01:00
Adam DaleyandCopilot Autofix powered by AI b2be307766 Enhance session management and image output configurations (#3558)
* Add session regeneration with grace period

* Enable push and canonical name for image outputs

* Remove redundant Docker Hub login scope

* Clear runtime cache around patching

* Add `default_currency` global to Twig

* Make default currency nullable

* 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-16 08:19:12 +01:00
4a9d44ff06 Refactor currency formatting and enhance admin UI features (#3539)
* Remove currency format fields & refactor formatting

* Handle missing currency and remove bold

* Adjust column widths in redirect settings form

* Add unified filter panel & request globals

* Normalize admin path and revamp activity UI

* Fix ADMIN_PREFIX check and ignore search filter

* Point docs links to docs.fossbilling.org

* ci: make live installer step retry before phpunit-live

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/3c14643b-8b1c-441d-8592-c3ba09df048f

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

* ci: avoid duplicate install attempt in live test retries

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/3c14643b-8b1c-441d-8592-c3ba09df048f

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

* Remove currency_format and simplify request handling

* Ensure request exists in DI for Twig tests

---------

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-14 18:55:36 +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
8808e70547 Added new widget spots to the client area (#3519)
* Added new widget spots to the client area

* 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 for pull request finding

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

---------

Co-authored-by: Adam Daley <admdly@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-11 23:48:03 +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
Adam Daley 53eb4f2fca Refactor Twig environments and extensions (#2752)
* Replace Custom Twig components

Replace custom Twig components with native Twig components, remove unused custom Twig components, and move functionality to macros where appropriate.

m

Update partial_extensions.html.twig

* Update Twig components and migrate to FOSSBilling namespace

* Update Currency module...

* Refactor Twig environment config and loading

* Switch CSRF to cookie-based double-submit

* Add Api Twig extension and restore widget/svg helpers

* Cast language flags; improve JSON parsing

* Add markdown DI service and use in Admin API

* Refactor Twig extensions and markdown, simplify APIs

* Add sandboxed email Twig env, update render APIs

* Fix pagination URL usage and menu class

* Fix HTML markup in email templates

* Use macro for avatars and status badges

* Fix Twig spacing and pagination URL filter order

* Replace Custom Twig components

Replace custom Twig components with native Twig components, remove unused custom Twig components, and move functionality to macros where appropriate.

m

Update partial_extensions.html.twig

* Update Twig components and migrate to FOSSBilling namespace

* Refactor Twig environment config and loading

* Add Api Twig extension and restore widget/svg helpers

* Cast language flags; improve JSON parsing

* Add markdown DI service and use in Admin API

* Refactor Twig extensions and markdown, simplify APIs

* Fix pagination URL usage and menu class

* Fix Twig spacing and pagination URL filter order

* Use `current_theme` global and refactor `period_title`

* Allow markdown and date in email Twig sandbox

* Update email template examples

* Fix Twig URLs, quoting, and logo alt text

* Fix Twig templates: URLs, i18n, search params

* Use `templates/*` directories for module templates

* Tighten Twig sandbox and add tests

* Add Twig environment and template docs to `AGENTS.md`

* Use Symfony Filesystem/Finder and assorted fixes

* Fix ticket reply link fragment concatenation

* Close missing divs in dashboard template

* Use detailed `toApiArray` for client

* Fix module name resolution for email templates

* Regenerate `composer.lock`

* Use `markdown_to_html` filter in admin macro

* Handle null price/quantity and rename test method

* Use `Tools::isHTTPS()` for HTTPS checks

* Add 'area' param to `url` filter and update templates

* Use client area URLs in admin templates

* Use client area and guest API URLs in templates

* Remove client-side invoice delete feature

* Create Twig env via `TwigFactory` for PDF rendering

* Add embedded orderbutton JS and update render

* Add 'srclink' to cspell allowlist

* Use `renderEmailTplString` for email rendering

* Bump twig/markdown-extra to v3.24

* Use `markdown_to_html` for privacy policy

* Escape API JSON, handle null IP, client URLs

* Remove initial admin creation flow

* Handle HTTP failures and make tests robust

* Use `api_url` helper in admin templates

* Use `url` filter for footer link 5

* Add patch53 to remove legacy html templates

* Bump setting last_patch to 53

* Add patch54 to restore legacy email templates

* Use renderEmailTplString for email templating

* Remove redundant else/endif in order template

* Add file-hash cache buster for asset URLs

* Remove raw Twig filter and handle missing modules dir

* Return '-' for future timestamps

* Register and reuse TwigFactory and add CSRF cookie

* Adjust API URL helper and add Twig error handling

* Update composer.lock and package-lock.json

* Add twig_factory to ServiceTest DI

* Use url filter for link_page in template

* Composer - update deps and add markdown-extra

* Remove docblocks and inline comments in `TwigFactory`

* Add patches 53-55 and update `last_patch`

* Add `has_permission` Twig function; exclude `href`

* Remove duplicate network interface form

* Guard removal of legacy dirs; add network input

* Handle null category descriptions in template

* Add Twig adapter env and sandbox policy

* Add 'striptags' to cspell word list

* Update composer.lock (deps updated/removed)

* Sanitize custom payment adapter templates

* Remove redundant legacy API tests

* Bump `last_patch` setting to 56

* Coalesce null before `markdown_to_html`

* Move update patcher to system CLI command

* Remove stray `endif` from recaptcha macro

* Update composer.lock

* Fix extra closing brace in Api ServiceTest

* Fix test errors from main merge

- Remove testGetRequestCount tests (method moved to RateLimiter)
- Remove testGetDi from Staff and System GuestTest (protected method)
- Fix IP error message in testLoginCheckIpException
- Add rate_limiter mock to Staff GuestTest tests that need it

* Fix remaining Staff GuestTest issues

- Add extension service mock for captcha check
- Fix error message from 'User not found' to 'Admin not found'

* Fix Staff GuestTest: update query and add logger mock

* Fix Staff GuestTest: set admin status to active for password reset flow

* Fix stale API calls and inverted required condition

- Notification: replace removed system_string_render with direct output
- Antispam settings: replace |alink/|link with |url/|api_url filters
- build_form macro: fix inverted required condition for non-textarea inputs

* Sanitize JS/data URIs and disable buttons by permission

* Use client login/profile links in support emails

* Encode fb-api JSON and tighten URL sanitization

* Prefer session auth for API key methods

* Remove stray endif and fix template formatting

* Add CSRF token to CSV exports; fix template

* Remove stray endif in currency template

* Make invoice PDF generation return Response

* Fix Twig filters, templates, and form handling

* Remove readonly from anonymous class in test

* Inline DebugBar CSS/JS in renderHead

* Add Bootstrap Tab to global bootstrap

* Capitalize template UI strings

* Use CKEditor API for reply quotes

* Remove WYSIWYG module and move CKEditor to themes

* Bump `last_patch` in install SQL to 59

* Remove Spamchecker module

* Run domain management script only for active orders

* Standardize UI text capitalization & minor fixes

* Remove Spamchecker legacy tests; fix period test

* Rename Spamchecker tests to Antispam

* Restore antispam config in tests; remove fixture

* Refactor Antispam Guest tests for config checks

* Update theme build docs; remove Wysiwyg module

* Remove spamchecker from cspell and tweak comment

* Add spamchecker to cspell word list

* Capitalize 'Update Graphs' button label
2026-05-06 21:02:16 +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
FOSSBilling BotandFOSSBilling Bot ae4ed4410c Apply PHP Code Styling & Quality Changes (#3454)
Co-authored-by: FOSSBilling Bot <fossbilling-bot>
2026-04-28 15:33:40 +01:00
Yağızhan Burak Yakar b4b984509d Pass API data to pagination methods (#3449)
* Pass API data to pagination methods

* Fixed phpStan finding

* Added filtering for data parameters

* Simplify the pagination class by extracting pagination options into a class

* Updated imports

* Move SQL validation before the getAll()

* Moved constants to PaginationOptions and put a sane per_page cap

* Removed `Pagination::getDefaultPerPage()`

* Add focused tests
2026-04-28 06:36:04 +01:00
52081d284a Improved type casting and removed unnecessary parameters (#3431)
* Cast ticket ID to integer

* Added type casting and removed unnecessary $per_page params

* Fixed tests

* Updated ddev PHP and nginx config

* Support ticket validation and upgrade checks

* Add order mock and constants in ServiceTest

* Require active status for API auth and clear tokens

* Validate client/admin sessions against DB

* Invalidate sessions on user status deactivation

* Check locale availability before toggling

* Escape database name properly

* Validate and cast rel_id to int in ticketCreateForClient to prevent TypeError

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/ce700346-2168-43cc-8309-fc6baee7cc82

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

* Improve rel_id validation error message to include the invalid value

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/ce700346-2168-43cc-8309-fc6baee7cc82

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

* Fix Notification AdminTest mock expectation to match actual paginateDoctrineQuery call

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/2fb587cf-6312-4b98-89e5-10f074646eaa

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

* Validate interface and custom interface inputs

* Tighten custom interface hostname validation

* Accept `per_page` in paginated API responses

* Validate HTTP interfaces and normalize upgrades

* Enforce active status and secure config export

* Cast rel_type/rel_task/rel_status to string in SupportTicketValidator to prevent TypeError

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/1ecf2bb3-1139-420f-8421-41ae8f6d1d5f

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

* Use FILTER_VALIDATE_INT instead of is_numeric for rel_id validation in Service.php

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/7bacd505-ba15-42da-8f52-7621afa1d634

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

* Validate rel_new_value as a positive integer before using as Product ID in upgrade tickets

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/842c7e1c-255b-4f09-8235-f34681e0392b

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

* Tighten `sValidHttpInterface` validation

* Add page parameter to pager calls

---------

Co-authored-by: Adam Daley <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>
2026-04-26 20:30:22 +01:00
Adam DaleyandCopilot Autofix powered by AI 5fceb5a775 Refactor API validation and enhance payment IPN handling with tests (#3432)
* Improve API validation and payment IPN security

* Validate `order_id` param before use

* Fix for PR finding

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

* Set admin transaction source; fix params/tests

* Require non-empty order_id for send_file

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-04-22 19:16:22 +01:00
Yağızhan Burak Yakar 049a1bd4d9 Use the new normalizeBoolean helper (#3406)
* Use the new normalizeBoolean helper and fix a bug

* Also normalize `$convert`
2026-04-08 18:54:53 +03:00
739af86e6d Normalize literals and add type hints (#3403)
* Normalize literals and add type hints

* Update src/modules/System/Service.php

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

* Fix isPasswordStrong to accept nullable string and handle null/empty explicitly

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/24b9e472-557d-453f-8a7a-f72e66acd17c

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

---------

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>
Co-authored-by: Yağızhan Burak Yakar <hi@yagiz.dev>
2026-04-08 13:43:27 +03:00
Yağızhan Burak Yakar f54bfbf62d Fix parameter types (#3397)
* Cast parameters before passing them to number_format

* Fix parameter type

* Fix parameter type

* Pass integer values directly as well

* Fixed unrelated bug from #3365 - cc: @admdly

"Unknown "list" filter. Did you mean "last" in "mod_order_manage.html.twig" at line 424?"

--

Removed the "list" filter. This should already be iterable by itself, what's "list" supposed to do?
2026-04-08 06:21:12 +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 3d51718d83 Capitalise titles in templates (#3374)
Capitalize titles in Twig templates
2026-03-26 07:25:50 +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
Adam Daley 691c3f7aa7 Use templates/* directories for module templates (#3347)
* Use `templates/*` directories for module templates

* Update template globs and fix icon path
2026-03-17 21:28:15 +00:00
Adam DaleyandCopilot Autofix powered by AI e89a32df81 Fixes for 2 code quality findings (#3304)
* Apply suggested fix to src/modules/Order/html_client/mod_order_product.html.twig 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/Order/html_client/mod_order_product.html.twig 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-03-10 07:21:40 +00:00
Adam DaleyandCopilot Autofix powered by AI 21de5d8d21 Fixes for 3 code quality findings (#3301)
* Apply suggested fix to src/modules/Order/html_client/mod_order_product.html.twig 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/Order/html_client/mod_order_product.html.twig 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/Order/html_client/mod_order_product.html.twig 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-03-10 07:08:16 +00:00
Adam Daley 4f6b6d02a0 Show product title in order meta and breadcrumb (#3299) 2026-03-09 05:00:28 +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 Daley addb0820e9 Simplify auth checks, cleanup types/docs (#3251) 2026-02-18 19:31:25 +00:00
Adam Daley e12fe8229f 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
2026-02-17 07:36:53 +00: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
Adam Daley 5a62b8b387 Switch CSRF to cookie-based double-submit pattern (#3233)
* Switch CSRF to cookie-based double-submit pattern

* Remove unnecessary CSRF tokens from embed templates

Embed module templates call guest APIs which don't validate CSRF tokens.
These tokens were dead code since guest endpoints skip CSRF validation.
2026-02-07 03:01:37 +00:00
2c86db883c Replace Gravatar with local avatar generation (#3208)
* Replace Gravatar with local avatar generation

Removed Gravatar integration and implemented local avatar generation using DiceBear Identicon for user avatars. Updated Twig templates to use a new `.db-avatar` element and added supporting JavaScript for avatar rendering.

* Replace Gravatar with local avatar generation

Removed Gravatar integration and implemented local avatar generation using DiceBear Identicon for user avatars. Updated Twig templates to use a new `.db-avatar` element and added supporting JavaScript for avatar rendering.

* Add avatar SVG caching and simplify encoding

Introduced a cache for generated avatar SVGs to improve performance by avoiding redundant computations. Also simplified SVG encoding by removing unnecessary character replacements.

* Update src/themes/huraga/assets/js/avatar.js

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

* Update src/themes/admin_default/assets/js/avatar.js

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

* Update src/themes/huraga/html/layout_default.html.twig

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

* Update src/themes/huraga/html/mobile_menu.html.twig

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

* Improve avatar background rendering in themes

Added backgroundSize, backgroundPosition, and backgroundRepeat styles to avatar containers in both admin_default and huraga themes to ensure SVG avatars are properly scaled and centered without repeating.

* Downgrade @dicebear/core and identicon to v9.0.0

* Update live-tests.yml

* Update live-tests.yml

* Update package-lock.json dependencies

Marked several dependencies as peer, removed unused dev dependencies (balanced-match, brace-expansion, concat-map, minimatch), and added sass-embedded-darwin-x64. This cleans up the dependency tree and improves package management.

* Refactor avatar generation to use hashed seed

Replaces email-based avatar generation with a hashed seed using a new Twig filter. Updates all avatar-related HTML and JS to use `data-avatar-seed` and `data-avatar-size` attributes, improving privacy and consistency across admin and client themes.

* Update src/library/Box/TwigExtensions.php

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

* Update src/library/Box/TwigExtensions.php

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

* Update src/modules/Staff/html_admin/mod_staff_index.html.twig

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

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Belle Aerni <belleaerni@gmail.com>
2026-01-29 12:40:36 +03: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
Adam Daley 08a3919d96 Refactor Javascript and related API functions (#2725)
* chore: Remove jQuery dependencies and update build system

- Remove jQuery from theme dependencies
- Simplify build configuration
- Update documentation to reflect jQuery removal
- Apply PSR-12 code style formatting
- Replace jQuery with vanilla JS in ClientBalance adapter

* refactor: Complete JavaScript API rewrite with modern architecture

- Rewrite API.js with improved URL handling and CSRF management
- Add reusable utility functions in utils.js
- Remove deprecated jQuery-based bb object
- Update Tom Select integration

* feat: Add Twig API functions for declarative API interaction

- Add fb_api(), fb_api_form(), fb_api_link() Twig functions
- Add asset deduplication to prevent duplicate script/style loading

Note: Dashboard/Index module moved to separate refactor/index PR

* refactor: Integrate new API into theme layouts and core templates

- Update theme layouts to use new API functions
- Convert theme partials and macros
- Update core admin module templates (System, Theme, Wysiwyg, Staff)

* refactor: Update module templates to use new API functions

- Replace data-api-* attributes with fb_api_*() Twig functions
- Remove manual CSRF token handling
- Update all module templates for consistency

Note: Index module excluded (moved to refactor/index PR)

* Remove custom ignore rule from phpstan.neon

Deleted a specific ignore rule for ctype_alnum argument count in src/modules/Extension/Service.php, likely because it is no longer needed or the underlying issue has been resolved.
2026-01-14 19:10:24 +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
03c26e5972 Introduce RequiredParams attribute (#2965)
* Introduce RequiredParams attribute

* Use the new RequiredParams attribute instead

* Make sure we are always passing an array

* Fixed tests

* Fixed tests

* Fixed tests

* Fix validation attribute test failures

Added back manual parameter validation to API methods that use
RequiredParams attributes. The attribute validation only works when
methods are called through Api_Handler, but tests call methods directly.

Changes:
- Added checkRequiredParamsForArray calls to methods with RequiredParams
- Updated tests to include validators in DI containers
- Fixed HTTPS URL expectation in Invoice test
- Ensured all 1673 tests pass

This maintains both attribute-based validation (for Handler calls) and
inline validation (for direct calls and tests).

* Fix RequiredParams attribute validation in tests

- Made Api_Handler::validateRequiredParams() public to enable testing
- Added validateRequiredParams() helper method to BBTestCase for test validation
- Updated all failing tests to call validation before API methods
- Added RequiredParams attribute to Servicedomain update() method
- Fixed test expectation message to match actual error message
- All 1673 tests now pass successfully

This completes the RequiredParams attribute implementation by ensuring
tests properly validate required parameters through the attribute system
rather than relying on manual validation calls.

* Remove duplicate manual validation from API methods

Removed checkRequiredParamsForArray calls that were duplicating the
RequiredParams attribute validation. These manual calls are no longer
needed since the Api_Handler now processes the attributes automatically.

Files updated:
- Client/Api/Admin.php: Removed duplicate 'id' validation in update()
- Currency/Api/Admin.php: Removed duplicate 'code' validation in delete()
- Profile/Api/Admin.php: Removed duplicate password field validation in change_password()
- Staff/Api/Guest.php: Removed duplicate email/password validation in login()
- Support/Api/Admin.php: Removed duplicate 'id' validation in kb_category_* methods

All methods now rely solely on the RequiredParams attribute for validation.

* Introduce RequiredParams attribute

* Use the new RequiredParams attribute instead

* Make sure we are always passing an array

* Fixed tests

* Fixed tests

* Fixed tests

* Fix validation attribute test failures

Added back manual parameter validation to API methods that use
RequiredParams attributes. The attribute validation only works when
methods are called through Api_Handler, but tests call methods directly.

Changes:
- Added checkRequiredParamsForArray calls to methods with RequiredParams
- Updated tests to include validators in DI containers
- Fixed HTTPS URL expectation in Invoice test
- Ensured all 1673 tests pass

This maintains both attribute-based validation (for Handler calls) and
inline validation (for direct calls and tests).

* Fix RequiredParams attribute validation in tests

- Made Api_Handler::validateRequiredParams() public to enable testing
- Added validateRequiredParams() helper method to BBTestCase for test validation
- Updated all failing tests to call validation before API methods
- Added RequiredParams attribute to Servicedomain update() method
- Fixed test expectation message to match actual error message
- All 1673 tests now pass successfully

This completes the RequiredParams attribute implementation by ensuring
tests properly validate required parameters through the attribute system
rather than relying on manual validation calls.

* Remove duplicate manual validation from API methods

Removed checkRequiredParamsForArray calls that were duplicating the
RequiredParams attribute validation. These manual calls are no longer
needed since the Api_Handler now processes the attributes automatically.

Files updated:
- Client/Api/Admin.php: Removed duplicate 'id' validation in update()
- Currency/Api/Admin.php: Removed duplicate 'code' validation in delete()
- Profile/Api/Admin.php: Removed duplicate password field validation in change_password()
- Staff/Api/Guest.php: Removed duplicate email/password validation in login()
- Support/Api/Admin.php: Removed duplicate 'id' validation in kb_category_* methods

All methods now rely solely on the RequiredParams attribute for validation.

* Fix RequiredParams validation in tests

- Updated 10 tests to call validateRequiredParams() before API methods
- Fixed error message expectation in Client::update test
- Changed Staff login mock expectations from atLeastOnce to never
  (validation throws before validateAndSanitizeEmail is reached)
- Added missing validator to DI containers in Currency and Support tests
- Fixed http to https in Invoice callback URL test

All RequiredParams validation tests now properly test the attribute system.

* Fix kbHitView mock return type errors

The kbHitView method has a void return type, so mocks should not
specify a return value. Removed willReturn() calls from all kbHitView
mock setups.

Reduced errors from 70 to 64.

* Add location/ directory to gitignore

* Fix all void return type mock errors

Removed willReturn(null) from checkRequiredParamsForArray mocks and other
void methods. These methods have void return types and should not specify
return values in mocks.

Result: All 1673 tests now pass with 0 failures and 0 errors!
Only 30 PHPUnit deprecation warnings remain (not errors).

* chore: stabilize legacy tests after merge from main

- Fix PHPUnit 11 attribute compatibility issues (DataProvider, Group).
- Fix DI container issues in legacy tests by ensuring 'validator' and 'tools' are always available.
- Resolve 'IncompatibleReturnValueException' in mocks due to updated method return types (void, bool, int).
- Fix broken class/namespace references in mocks using 'getMockBuilder' and 'createMock'.
- Restore missing 'deleteLoginHistory' method in Staff Service.
- Remove obsolete Branding module legacy tests.

* chore: fully resolve legacy test failures and restore passing state

- Fixed 'testUninstall' in Extension module by allowing Filesystem injection.
- Restored missing 'deleteLoginHistory' in Staff Service.
- Updated all mocks for 'checkRequiredParamsForArray' to be optional (any()) as it's now handled by attributes.
- Corrected numerous assertions from assertIsArray/assertIsInt to assertTrue for methods whose return type changed to bool.
- Fixed relative class references and namespaces in several legacy tests.

* chore: eliminate all PHPUnit deprecations and resolve final test failures

- Replaced deprecated 'new ServiceTest()' manual instantiation in data providers with string identifiers.
- Updated 'onConsecutiveCalls' usage to use the newer 'willReturn' syntax for multiple values.
- Fixed numerous 'TypeError' and dynamic expectation call issues introduced during refactoring.
- Improved 'Email Service' by moving salt retrieval from static Config to DI container for better testability.
- Resolved all remaining legacy test failures and deprecations.

* Remove unused asset file

Deleted the file at location/Of/Assets/file as it is no longer needed.

* Restore Branding module with service, icon, and manifest

Introduces a new Branding module including the service class, SVG icon, and manifest file. This module allows voluntary display of FOSSBilling references and includes basic module permissions and uninstall functionality.

* Update .gitignore and add .gitkeep for cache directory

Modified .gitignore to properly ignore cache files while allowing the .gitkeep file to be tracked. Added src/data/cache/.gitkeep to ensure the cache directory is present in the repository.

* These were removed in #3026 and seem to be accidentally reintroduced.

* No need to use it here

* Also removed with #3026.

* Also removed with #3026.

* Update dependencies in composer.lock

Bump nette/utils from v4.1.0 to v4.1.1 and react/child-process from v0.6.6 to v0.6.7 in composer.lock to include latest bug fixes and improvements.

* Update service test mocks and improve test setup

Refactored Extension ServiceTest to properly mock getExtensionPath and filesystem exists, ensuring temp directories are created and cleaned up within the test. Updated Invoice ServiceTest to include 'toApiArray' in the list of mocked methods for relevant tests.

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Adam Daley <admdly@users.noreply.github.com>
2025-12-24 01:54:13 +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
Yağızhan d9c7fc7053 tomselect: Automatically grab the CSRF token from the API wrapper (#2899)
* Automatically grab the CSRF token from the API wrapper

* Removed data-csrf fields
2025-09-13 01:08:20 +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
Belle Aerni 1e449e20eb Handful of small fixes (#2838) 2025-08-01 13:41:38 +01:00
Belle Aerni d00da48af1 WYSIWYG fixes for client area (#2805) 2025-06-28 02:37:21 -07:00
b772526ae3 Replace outdated Twig features with recommended equivalents (#2780)
* Replace Twig `include` tag with function

* Replace Twig `attribute` function with dot operator

* Fix spelling issues in mod_order_manage.html.twig

---------

Co-authored-by: John P <64874788+j-a-pope@users.noreply.github.com>
Co-authored-by: Yağızhan <yagizhan49@protonmail.com>
2025-06-07 11:40:06 +03:00
Yağızhan 00b3b97f66 Make more messages translatable (#2778)
* Make static messages translatable

* Typo

* Second batch

* Make static messages translatable

* Typo

* Second batch

* Applying suggested fixes

* Applying suggested fixes

* Missed this one

* Make documentation section titles untranslatable

* Use double quotes instead of escaping single quotes
2025-06-07 11:34:24 +03:00