* Introduce some simple phone number validation
* Expanded client creation tests to include phone numbers
* Update Admin.php
* Addressed the review
* Ran CS fixes
* Fixed
* 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>
* 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`
* Re-enable the network interface tests
I am pretty sure a Symfomy HTTP client bug was causing the issue we saw. Some time ago they published fixes related to the BIND_TO option with IPv6
* We actually should expect the result to be empty here
* Refactor initial application loading
Refactor `load.php` to simplify loading, clarify loading, and to use available Symfony components. Additionally, update `index.php` as appropriate.
Add Symfony HttpFoundation as supporting dependency and for future functionality.
* Remove or disable problematic and unused functions
* Restore required FOSSBilling\Event function
* Remove / disable problematic unused functions
* Restore required FOSSBilling\Event function
* Refactor initial application loading
Refactor `load.php` to simplify loading, clarify loading, and to use available Symfony components. Additionally, update `index.php` as appropriate.
Add Symfony HttpFoundation as supporting dependency and for future functionality.
* Remove or disable problematic and unused functions
* Restore required FOSSBilling\Event function
* Remove / disable problematic unused functions
* Restore required FOSSBilling\Event function
* Update CI for PHP 8.4
* Update composer deps for PHP 8.4
* Updates
* This is the default mode and this constant causes test failutes
* Explicily install the PDO extensions
* Temporarily downgrade the live tests to PHP 8.3
It would seem that there is some kind of problem with PHP 8.4 in regards to these tests. I believe it is outside of our control however as it installs fine for me with PHP 8.4 under DirectAdmin
* Update to address deprecations
* Make that nullable
* Fixed my typo
* Bump PHPunit to v11
* Also take care of two minor things
* Formatting fix
* Refactor `getExternalIP()` to use `RetryableHttpClient`
Refactor `FOSSBilling\Tools` `getExternalIP()` function to use `RetryableHttpClient`.
* Fix incorrect parameter names and add cURL timeout
* Disable Network Interface live-tests
* Removed the hardcoded currencies list
Also streamlined the process of adding new currencies by allowing the title & exchange rate to automatically be determined.
* Use an existing translatable string
* Update the test workflows
* Dropped the legacy test, wrote two new ones
* Fixed a typo in my assert
* Whooooops
I made a mistake when I setup the random password generation for the live tests and forgot that `bin2hex(random_bytes(6));` wasn't guaranteed to actually generate something with a number, this change fixes that to ensure one will be set.
* Slight structure change to the testcases
* Fix
* Ported some random low-level tests
* Spelling
* Ported over some other low-level tests
* Fixes
* And now other fixes
* Another one
* Wrote a few more tests, improvements
* Ran Rector & PHP-CS-Fixer
* Append a capital letter to the test client passwords
* Minor tweaks
* Display more info after the tests run
* Oops, I forgot to set the dir
* Fix cron behavior for test env, dropped legacy tests
* Rename the empty test suite so PHPUnit ignores it
* Update cspell.json
* Minor tweaks to the tests
* Fixes
* Feat: allow selection of the default network interface
* Update cspell.json
* Wrote some tests, moved the setting to the config file
* Cleanup, fixes, include Sentry in the bind setting
* Use JS to update the IP rather than reload, minor tweaks
* UI tweaks
* Removed leftover incomplete sentence, mention interface names
* Implemented a new class for config management
* Run Rector & PHP-CS-Fixer
* Spelling
* Pointed a bunch of code to the new class
* Fix tests, removed 2 broken ones that did nothing
* Quick run of PHP-CS-Fixer
* Fixed issues noticed in self review
* Updated remaining old methods. Fixed minor error page issue
* Very minor code tweak
* Fixes, added a related test
* Check for OPCache functions being defined
* I don't think this timeout is needed
* Rename tests to tests-legacy
* Groundwork for live tests
* Somewhat working tests on a live instance
* Hmmmmmm
* Fix
* Fixed the other bug
* Added a handful of various tests
* Typos, all these are admin endpoints
* Bypass this check for testing envs
* Disable it for now
* Mini cleanup
* Cleanup from debugging, ran PHP-CS-Fixer
* Implement `passwordlength` field for service hosting generated accounts
Fix testing DirectAdmin connections (it previously did nothing)
* Revert unintended change from the previous PR
* Fix changes not saving to db
* Fix `passwordlength` not showing everywhere
* Remove stray debug line
* Fix: passwords being incorrectly set to 7 asterisks when an order is uncancelled
* Requested changes + typo fix
* Include `passwordlength` as ignored term
* Fix typo change oversight
* Minor code clarity improvements
* Type safety for the `passwordlength` and `port` fields
* Fallback to the original model value
* Remove default value for new servers, to show the placeholder
* Improve customer UI
Increase padding for service hosting management tabs
Include missing badge styling for `canceled` orders
* More consistent button colours for orders
* Rename `passwordlength` to `passwordLength`
Remove `activate` and `uncancel` tests for now as they don't really work
* Remove spelling ignore for `passwordlength`
* Restore missing `$httpClient` variable
* Resolve comments
* More thorough port validation
* Fix errors caused by fixing the previous merge conflicts through the GH web interface
* Added the rector cache to the action
* Enabled PHP-CS fixer for the tests & library folder
* Use the PHP-CS-Fixer Cache
* Fix the tests
* Ensure the Sentry placeholder isn't messed up from CS changes
* Typo..
* Restructure the login after redirect functionality
* Initialize the session in the start of the app
* Fix the test
* That 100% needs to come after the fallback patcher
* Begin reworking permission management
* Tests
* This.. tested functionality that didn't exist in the app
* Fixes
* Added permission checks for the system module
* Implemented extension settings permission
The "extension" settings page will now check for permission before allowing a staff member to even visit the settings page for a client.
FOSSBilling will also check for permission before saving a new config so the API can't be used to bypass this limitation.
I also removed a test as it was checking a function which only ever had one possible return value, no point in updating it to work with this PR
* This should fix the test
* I got a little mixed up with that, but this should work
* Fixed the tests
* Implemented give all & revoke all buttons
* Implemented more, enhancements, & bugfix
* Rename function
* Fix tests
* Optimize, address comment
* Now let's make the tests happy again
* Deduplicate code, cleanup a bit
* Bugfix
* Added selectbox support to the front-end
* Quick bugfix
* Fix issue PHPStan detected
* Bug fix
* Improved page layout & styling
* Implemented more checks
* Fix the tests
* Update error.html.twig
* Cleanup
* Fix the tests
* Updated the design to be more space efficient
* Don't list module access when always given
* Updated the exception type
* setMethod -> onlyMethods
* I donno how that got goofed up
* Fix the test, email module should always be accessible
* Removed the broken test
It's.. not really checking anything anyways. Just that the `extension` module is in a hardcoded array.
* Update rector config to include tests
* Run Rector against the tests
* Delete test-results
* Update .gitignore
* Correctly set the PHP min to 8.1, split the configs
* Corrected PHPDoc
* Deleted tests we can't really get to pass
PHPunit is hard-coded to fail when a class has a return type of `never`, which is the correct return type of our redirect function (and rightfully so).
No way to disable the exception as far as we can tell
* Update PHPUnit to version 10
Update composer and CI version of PHPUnit to 10, and migrate XML config to updated schema.
* Update tests for PHPUnit 10
Update tests to replace depreciated functions in PHPUnit 10. Also, remove risky tests which don't assert anything.
* Remove the Queue module and update massmailer
Queue module was only used by the massmailer module & it duplicated the functionality of the email service, resulting in added complexity for no real benefit.
This commit removes the Queue module outright and points the massmailer to the email service instead, which already implements queing, retires, and time limits.
* Added the ability to view the email queue
* Minor front-end improvements, added removal patch
* Cleanly handle a client being removed
* Fix PATH_DATA constant to use config
Update `PATH_DATA` constant to use the `path_data` config option.
* Replace direct config references with constants
Replace direct references to `config.php` file and specific config options in favour of global constants, where available.
* Drop BB prefix on global constants
Rename global constants to drop `BB_` prefix, where appropriate.
* Merge Kb and Support modules
Merge the Kb and Support modules as they contain related functionality.
* General improvements to Support module UI
Update Support module copy and navigation to be more consistent, and other general improvements.
* This was missed.. and now it's not 😉
---------
Co-authored-by: Belle Aerni <belleaerni@gmail.com>
* Began implementing Sentry.io support
* Added to the installer
* Added the ID to the bug report template and UI
* Hook it into our error handler, added the ability to filter by error code
* Attempting to add the DSN via GH actions
* Spelling and making PHPstan happy
* Skip exceptions for various incomplete configurations
Also brings in some of the category suggestions made by @Anuril in #195
* Update tests to account for changes
* Added & renamed exception classes
* Fix tests
* Change a bunch of items to be InformationExceptions
* Use a lighter HTTP client, fixed API error reporting
* I guess that's not needed now?
Arighty then
* Improvements, additional info added
* Update SentryHelper.php
* Improved error logging, added instance ID to error page
Also made it so that errors are correctly sent to Sentry rather than exclusively exceptions
* Make the tests happy
* Added the link, improved wording
Also removed the "performance" part of the reporting as it needs to be added to the front-end and I'm not currently implementing that
* Began implementing UI alerts and info
* Added the ability to toggle, fixed tests, use path constants
* Added some useful info & links to the page
* These should be InformationException
* Fix the automated Sentry DSN entry
* Fix the install number text
* Minor cleanup, converted more to InformationException
* Replaced some direct config references with constants
We have the BB_DEBUG constant to indicate if we have debug mode enabled or not, so we shouldn't be directly referencing it in the config file unless we actually need to do so.
Using the constant means there's less locations to update the reference if the config structure is changed
* Bugfix
* Consistency & fixed a PHPDoc
* Corrections
* We actually do want exceptions thrown here
* Change how we get the instance ID
* Stability improvements
Having support for translatable error pages was proving to be problematic, so I had to remove it.
I also had to update the exception class to handle cases where the trans function wasn't setup yet (needed for the /run-patcher page if an error occurs)
* Missed this change on git
* Also fix the variable names...
* Re-added new deps after rebase
* This should also accept "Error" types
* Added more info to the bug report and removed a dug line
* This wasn't supposed to get renamed
* Updated some missed references to Box_Exception