* 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>
* 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>
* 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>
* 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
* 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
* 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>
* 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?
* 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
* 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>
* 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>
* 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>
* 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>
* 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>
* 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.
* 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>
* 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>
* 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>
* 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`
* 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>
* 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