From 602b5379969b6b76c3d6b4620efe4e57e8a8f1cd Mon Sep 17 00:00:00 2001 From: Belle Aerni Date: Sat, 28 Oct 2023 18:40:39 -0700 Subject: [PATCH] Opt-in error reporting via Sentry.io (#1732) * Began implementing Sentry.io support * Added to the installer * Added the ID to the bug report template and UI * Hook it into our error handler, added the ability to filter by error code * Attempting to add the DSN via GH actions * Spelling and making PHPstan happy * Skip exceptions for various incomplete configurations Also brings in some of the category suggestions made by @Anuril in #195 * Update tests to account for changes * Added & renamed exception classes * Fix tests * Change a bunch of items to be InformationExceptions * Use a lighter HTTP client, fixed API error reporting * I guess that's not needed now? Arighty then * Improvements, additional info added * Update SentryHelper.php * Improved error logging, added instance ID to error page Also made it so that errors are correctly sent to Sentry rather than exclusively exceptions * Make the tests happy * Added the link, improved wording Also removed the "performance" part of the reporting as it needs to be added to the front-end and I'm not currently implementing that * Began implementing UI alerts and info * Added the ability to toggle, fixed tests, use path constants * Added some useful info & links to the page * These should be InformationException * Fix the automated Sentry DSN entry * Fix the install number text * Minor cleanup, converted more to InformationException * Replaced some direct config references with constants We have the BB_DEBUG constant to indicate if we have debug mode enabled or not, so we shouldn't be directly referencing it in the config file unless we actually need to do so. Using the constant means there's less locations to update the reference if the config structure is changed * Bugfix * Consistency & fixed a PHPDoc * Corrections * We actually do want exceptions thrown here * Change how we get the instance ID * Stability improvements Having support for translatable error pages was proving to be problematic, so I had to remove it. I also had to update the exception class to handle cases where the trans function wasn't setup yet (needed for the /run-patcher page if an error occurs) * Missed this change on git * Also fix the variable names... * Re-added new deps after rebase * This should also accept "Error" types * Added more info to the bug report and removed a dug line * This wasn't supposed to get renamed * Updated some missed references to Box_Exception --- .github/ISSUE_TEMPLATE/BUG-REPORT.yml | 31 +- .github/workflows/preview.yml | 9 + composer.json | 6 +- composer.lock | 1341 +++++++++++++++-- cspell.json | 4 +- src/config-sample.php | 58 +- src/di.php | 4 +- src/index.php | 4 +- src/install/assets/install.html.twig | 78 +- src/install/assets/js/modal.js | 94 ++ src/install/assets/layout.html.twig | 1 + src/install/install.php | 22 +- src/library/Api/Abstract.php | 2 +- src/library/Api/Handler.php | 12 +- src/library/Box/App.php | 4 +- src/library/Box/AppClient.php | 4 +- src/library/Box/Crypt.php | 4 +- src/library/Box/Database.php | 4 +- src/library/Box/Exception.php | 65 +- src/library/Box/Log.php | 12 +- src/library/Box/Mod.php | 14 +- src/library/Box/Pagination.php | 8 +- src/library/Box/Period.php | 12 +- src/library/Box/TwigLoader.php | 6 +- src/library/FOSSBilling/CentralAlerts.php | 12 +- src/library/FOSSBilling/ErrorPage.php | 153 +- src/library/FOSSBilling/Exception.php | 92 ++ src/library/FOSSBilling/ExtensionManager.php | 26 +- .../FOSSBilling/InformationException.php | 29 + src/library/FOSSBilling/Mail.php | 20 +- src/library/FOSSBilling/SentryHelper.php | 208 +++ src/library/FOSSBilling/Session.php | 4 +- src/library/FOSSBilling/Tools.php | 6 +- src/library/FOSSBilling/Update.php | 18 +- src/library/FOSSBilling/UpdatePatcher.php | 28 +- src/library/FOSSBilling/Validate.php | 21 +- src/library/FOSSBilling/i18n.php | 4 +- src/library/Model/ProductDomainTable.php | 6 +- src/library/Model/ProductTable.php | 10 +- src/library/Payment/Adapter/PayPalEmail.php | 2 +- src/library/Payment/Adapter/Stripe.php | 12 +- src/library/Payment/Exception.php | 4 +- src/library/Registrar/Adapter/Email.php | 2 +- src/library/Registrar/Adapter/Internetbs.php | 4 +- src/library/Registrar/Adapter/Namecheap.php | 6 +- src/library/Registrar/Adapter/Netearthone.php | 4 +- src/library/Registrar/Adapter/Resellbiz.php | 4 +- .../Registrar/Adapter/Resellerclub.php | 4 +- src/library/Registrar/Adapter/Resellerid.php | 4 +- src/library/Registrar/Exception.php | 4 +- src/library/Server/Exception.php | 4 +- src/library/Server/Manager/CWP.php | 6 +- src/library/Server/Manager/Directadmin.php | 6 +- src/library/Server/Manager/Whm.php | 6 +- src/load.php | 53 +- src/modules/Api/Controller/Client.php | 28 +- src/modules/Cart/Api/Guest.php | 12 +- src/modules/Cart/Service.php | 22 +- src/modules/Client/Api/Admin.php | 10 +- src/modules/Client/Api/Guest.php | 18 +- src/modules/Client/Service.php | 30 +- src/modules/Client/ServiceBalance.php | 6 +- src/modules/Cookieconsent/Api/Guest.php | 2 +- src/modules/Currency/Api/Admin.php | 18 +- src/modules/Currency/Api/Guest.php | 2 +- src/modules/Currency/Service.php | 18 +- src/modules/Email/Api/Admin.php | 20 +- src/modules/Email/Api/Client.php | 12 +- src/modules/Email/Service.php | 14 +- src/modules/Extension/Api/Admin.php | 16 +- src/modules/Extension/Api/Guest.php | 4 +- src/modules/Extension/Service.php | 24 +- src/modules/Formbuilder/Api/Admin.php | 42 +- src/modules/Formbuilder/Api/Guest.php | 2 +- src/modules/Formbuilder/Service.php | 12 +- src/modules/Hook/Api/Admin.php | 2 +- src/modules/Hook/Service.php | 2 +- src/modules/Invoice/Api/Admin.php | 26 +- src/modules/Invoice/Api/Client.php | 22 +- src/modules/Invoice/Api/Guest.php | 18 +- src/modules/Invoice/Service.php | 32 +- src/modules/Invoice/ServiceInvoiceItem.php | 4 +- src/modules/Invoice/ServicePayGateway.php | 8 +- src/modules/Invoice/ServiceTransaction.php | 50 +- src/modules/Kb/Api/Admin.php | 10 +- src/modules/Kb/Api/Guest.php | 8 +- src/modules/Kb/Service.php | 4 +- src/modules/Massmailer/Api/Admin.php | 6 +- src/modules/Massmailer/Service.php | 4 +- src/modules/News/Api/Admin.php | 4 +- src/modules/News/Api/Guest.php | 4 +- src/modules/Notification/Api/Admin.php | 10 +- src/modules/Order/Api/Admin.php | 6 +- src/modules/Order/Api/Client.php | 4 +- src/modules/Order/Service.php | 18 +- src/modules/Paidsupport/Service.php | 2 +- src/modules/Product/Api/Admin.php | 38 +- src/modules/Product/Api/Guest.php | 6 +- src/modules/Product/Service.php | 8 +- src/modules/Profile/Api/Admin.php | 8 +- src/modules/Profile/Api/Client.php | 8 +- src/modules/Profile/Service.php | 10 +- src/modules/Queue/Api/Admin.php | 2 +- src/modules/Redirect/Api/Admin.php | 2 +- src/modules/Serviceapikey/Service.php | 28 +- src/modules/Servicecustom/Api/Admin.php | 8 +- src/modules/Servicecustom/Api/Client.php | 6 +- src/modules/Servicecustom/Service.php | 18 +- src/modules/Servicedomain/Api/Admin.php | 28 +- src/modules/Servicedomain/Api/Client.php | 6 +- src/modules/Servicedomain/Api/Guest.php | 12 +- src/modules/Servicedomain/Service.php | 54 +- src/modules/Servicedownloadable/Api/Admin.php | 4 +- .../Servicedownloadable/Api/Client.php | 6 +- src/modules/Servicedownloadable/Service.php | 10 +- src/modules/Servicehosting/Api/Admin.php | 26 +- src/modules/Servicehosting/Api/Client.php | 6 +- src/modules/Servicehosting/Api/Guest.php | 4 +- src/modules/Servicehosting/Service.php | 34 +- src/modules/Servicelicense/Api/Admin.php | 4 +- src/modules/Servicelicense/Api/Client.php | 4 +- src/modules/Servicelicense/Service.php | 10 +- src/modules/Spamchecker/Service.php | 16 +- src/modules/Staff/Api/Admin.php | 20 +- src/modules/Staff/Api/Guest.php | 16 +- src/modules/Staff/Controller/Admin.php | 6 +- src/modules/Staff/Service.php | 10 +- src/modules/Support/Api/Admin.php | 42 +- src/modules/Support/Api/Client.php | 4 +- src/modules/Support/Api/Guest.php | 2 +- src/modules/Support/Service.php | 18 +- src/modules/System/Api/Admin.php | 56 +- src/modules/System/Service.php | 54 +- .../html_admin/mod_system_settings.html.twig | 46 +- src/modules/Theme/Controller/Admin.php | 2 +- src/modules/Theme/Model/Theme.php | 2 +- src/modules/Theme/Service.php | 4 +- .../bb-library/Api/HandlerTest.php | 6 +- .../bb-modules/mod_activity/Api_AdminTest.php | 4 +- .../bb-modules/mod_cart/Api_ClientTest.php | 2 +- .../bb-modules/mod_cart/Api_GuestTest.php | 8 +- .../bb-modules/mod_client/Api_GuestTest.php | 4 +- .../mod_paidsupport/ServiceTest.php | 2 +- .../bb-modules/mod_product/Api_AdminTest.php | 2 +- .../Api_ClientTest.php | 6 +- .../ServiceTest.php | 6 +- .../Api_ClientTest.php | 2 +- .../bb-modules/mod_staff/Api_AdminTest.php | 2 +- .../bb-modules/mod_support/Api_ClientTest.php | 2 +- .../bb-modules/mod_theme/ApiAdminTest.php | 2 +- tests/library/Box/Box_PeriodTest.php | 4 +- tests/library/Box/Box_ValidateTest.php | 16 +- .../Registrar_Adapter_ResellerclubTest.php | 4 +- tests/modules/Cart/Api/GuestTest.php | 8 +- tests/modules/Cart/ServiceTest.php | 16 +- tests/modules/Client/Api/AdminTest.php | 8 +- tests/modules/Client/Api/GuestTest.php | 8 +- tests/modules/Client/ServiceBalanceTest.php | 4 +- tests/modules/Client/ServiceTest.php | 20 +- tests/modules/Currency/Api/Api_AdminTest.php | 18 +- tests/modules/Currency/Api/Api_GuestTest.php | 4 +- tests/modules/Currency/ServiceTest.php | 24 +- tests/modules/Email/Api/Api_AdminTest.php | 8 +- tests/modules/Email/Api/Api_ClientTest.php | 6 +- tests/modules/Email/ServiceTest.php | 4 +- tests/modules/Extension/Api/AdminTest.php | 2 +- tests/modules/Extension/Api/GuestTest.php | 2 +- tests/modules/Extension/ServiceTest.php | 8 +- tests/modules/Formbuilder/Api/AdminTest.php | 14 +- tests/modules/Formbuilder/ServiceTest.php | 8 +- tests/modules/Hook/Api/AdminTest.php | 2 +- tests/modules/Invoice/Api/AdminTest.php | 4 +- tests/modules/Invoice/Api/ClientTest.php | 10 +- tests/modules/Invoice/Api/GuestTest.php | 10 +- .../Invoice/ServiceInvoiceItemTest.php | 2 +- .../modules/Invoice/ServicePayGatewayTest.php | 8 +- tests/modules/Invoice/ServiceTest.php | 18 +- .../Invoice/ServiceTransactionTest.php | 8 +- tests/modules/Kb/Api/Api_AdminTest.php | 22 +- tests/modules/Kb/Api/Api_GuestTest.php | 12 +- tests/modules/Kb/ServiceTest.php | 4 +- tests/modules/Order/Api/Api_AdminTest.php | 6 +- tests/modules/Order/Api/Api_ClientTest.php | 4 +- tests/modules/Order/ServiceTest.php | 12 +- tests/modules/Paidsupport/ServiceTest.php | 2 +- tests/modules/Product/Api/AdminTest.php | 8 +- tests/modules/Product/Api/GuestTest.php | 4 +- tests/modules/Product/ServiceTest.php | 6 +- tests/modules/Profile/Api/AdminTest.php | 2 +- tests/modules/Profile/ServiceTest.php | 4 +- .../Servicedomain/Api/Api_AdminTest.php | 34 +- .../Servicedomain/Api/Api_ClientTest.php | 6 +- .../Servicedomain/Api/Api_GuestTest.php | 12 +- tests/modules/Servicedomain/ServiceTest.php | 36 +- .../Servicedownloadable/Api/AdminTest.php | 4 +- .../Servicedownloadable/Api/ClientTest.php | 6 +- .../Servicedownloadable/ServiceTest.php | 6 +- .../modules/Servicehosting/Api/AdminTest.php | 8 +- .../modules/Servicehosting/Api/ClientTest.php | 6 +- .../modules/Servicehosting/Api/GuestTest.php | 2 +- tests/modules/Servicehosting/ServiceTest.php | 22 +- .../modules/Servicelicense/Api/AdminTest.php | 2 +- .../modules/Servicelicense/Api/ClientTest.php | 2 +- tests/modules/Servicelicense/ServiceTest.php | 10 +- tests/modules/Spamchecker/ServiceTest.php | 2 +- tests/modules/Staff/Api/AdminTest.php | 2 +- tests/modules/Staff/Api/GuestTest.php | 12 +- tests/modules/Staff/ServiceTest.php | 10 +- tests/modules/Support/Api/Api_ClientTest.php | 2 +- tests/modules/Support/Api/Api_GuestTest.php | 2 +- tests/modules/Support/ServiceTest.php | 12 +- tests/modules/System/ServiceTest.php | 2 +- tests/modules/Theme/Model/ThemeTest.php | 2 +- 213 files changed, 3065 insertions(+), 1284 deletions(-) create mode 100644 src/install/assets/js/modal.js create mode 100644 src/library/FOSSBilling/Exception.php create mode 100644 src/library/FOSSBilling/InformationException.php create mode 100644 src/library/FOSSBilling/SentryHelper.php diff --git a/.github/ISSUE_TEMPLATE/BUG-REPORT.yml b/.github/ISSUE_TEMPLATE/BUG-REPORT.yml index 6457b7d78..12114054c 100644 --- a/.github/ISSUE_TEMPLATE/BUG-REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG-REPORT.yml @@ -1,13 +1,31 @@ name: Bug report description: Create a report to help us improve FOSSBilling -title: "[Bug]" +title: "[Bug] Enter a short title of the issue you are having here" labels: [bug] body: - type: markdown attributes: value: | - Please ensure that there is no existing issue for your bug, and fill out the title before continuing. - **Important: DO NOT include any private/sensitive information such as email addresses, passwords, IP addresses, or hostnames.** + # Bug reporting + + - Please ensure that there is no existing issue for your bug, and fill out the title before continuing. + - **Important: DO NOT include any private/sensitive information such as email addresses, passwords, IP addresses, or hostnames.** + - You may find the error log for your installation under the `/data/log` folder. For the most part, we specifically want for the `error.log` file. + - Before attaching the error log, please validate that it does not contain any private or sensitive information. + + ## Instance ID and error reporting + + This guide will ask you for your instance ID. If you do not have error reporting enabled, you may skip this step. + If you have error reporting enabled and do not know how to find the instance ID, please refer to the [documentation](https://fossbilling.org/docs/faq/error-reporting#what-is-the-instance-id-and-where-do-i-find-it). + + ### What not to send when using error reporting + + If you have error reporting enabled and have provided us with the instance ID, please **do not** attach the `error.log` file to this ticket. + We have access to an error log that includes more information than the one you have and may gain acceess to it using the instance ID you provide. + By not attaching the `error.log` file, you are helping us keep your information private and secure. + + If we require more information that wasn't already collected via error reporting, we will will specifically ask for you to share it with us. + Thanks! - type: textarea id: describe @@ -57,6 +75,13 @@ body: validations: required: true + - type: input + id: ID + attributes: + label: FOSSBilling instance ID + description: If you have opted in to error reporting, providing your instance ID below allows us to provide better technical support for you. + placeholder: XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX + - type: input id: module attributes: diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index c3ad781e8..f360401df 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -86,6 +86,15 @@ jobs: mv Version2.php Version.php working-directory: ./build/source/library/FOSSBilling + - name: Add in the Sentry DSN + if: ${{ vars.SENTRY_DSN }} + run: | + d=$'\03' + sed -i "s${d}--replace--this--during--release--process--${d}$SENTRY_DSN$d" SentryHelper.php + working-directory: ./build/source/library/FOSSBilling + env: + SENTRY_DSN: ${{ vars.SENTRY_DSN }} + - name: Upload the Final Artifact to GitHub uses: actions/upload-artifact@v3 with: diff --git a/composer.json b/composer.json index 511c71aa9..2be27e160 100644 --- a/composer.json +++ b/composer.json @@ -32,10 +32,13 @@ "league/csv": "^9.8", "monolog/monolog": "^2.9", "nelexa/zip": "^4.0.2", + "nyholm/psr7": "^1.8", "phpmyadmin/motranslator": "^5.3.0", "pimple/pimple": "^3.3", "plesk/api-php-lib": "^2.0.0", "psr/log": "^3.0.0", + "ramsey/uuid": "^4.7", + "sentry/sentry": "^3.22", "stripe/stripe-php": "^13.0.0", "symfony/cache": "^6.0", "symfony/filesystem": "^6.0", @@ -67,7 +70,8 @@ "config": { "sort-packages": true, "allow-plugins": { - "phpstan/extension-installer": true + "phpstan/extension-installer": true, + "php-http/discovery": true }, "vendor-dir": "src/vendor" } diff --git a/composer.lock b/composer.lock index 7a2cce0bd..7c057970a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "311de1e0d07e8c5c7280f9a202eb4938", + "content-hash": "044d14773ba454259337bba123511342", "packages": [ { "name": "antcms/antloader", @@ -52,17 +52,138 @@ "time": "2023-10-03T13:13:17+00:00" }, { - "name": "composer/ca-bundle", - "version": "1.3.5", + "name": "brick/math", + "version": "0.11.0", "source": { "type": "git", - "url": "https://github.com/composer/ca-bundle.git", - "reference": "74780ccf8c19d6acb8d65c5f39cd72110e132bbd" + "url": "https://github.com/brick/math.git", + "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/74780ccf8c19d6acb8d65c5f39cd72110e132bbd", - "reference": "74780ccf8c19d6acb8d65c5f39cd72110e132bbd", + "url": "https://api.github.com/repos/brick/math/zipball/0ad82ce168c82ba30d1c01ec86116ab52f589478", + "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478", + "shasum": "" + }, + "require": { + "php": "^8.0" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.2", + "phpunit/phpunit": "^9.0", + "vimeo/psalm": "5.0.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Brick\\Math\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Arbitrary-precision arithmetic library", + "keywords": [ + "Arbitrary-precision", + "BigInteger", + "BigRational", + "arithmetic", + "bigdecimal", + "bignum", + "brick", + "math" + ], + "support": { + "issues": "https://github.com/brick/math/issues", + "source": "https://github.com/brick/math/tree/0.11.0" + }, + "funding": [ + { + "url": "https://github.com/BenMorel", + "type": "github" + } + ], + "time": "2023-01-15T23:15:59+00:00" + }, + { + "name": "clue/stream-filter", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/clue/stream-filter.git", + "reference": "d6169430c7731d8509da7aecd0af756a5747b78e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/clue/stream-filter/zipball/d6169430c7731d8509da7aecd0af756a5747b78e", + "reference": "d6169430c7731d8509da7aecd0af756a5747b78e", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.36" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "Clue\\StreamFilter\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering" + } + ], + "description": "A simple and modern approach to stream filtering in PHP", + "homepage": "https://github.com/clue/php-stream-filter", + "keywords": [ + "bucket brigade", + "callback", + "filter", + "php_user_filter", + "stream", + "stream_filter_append", + "stream_filter_register" + ], + "support": { + "issues": "https://github.com/clue/stream-filter/issues", + "source": "https://github.com/clue/stream-filter/tree/v1.6.0" + }, + "funding": [ + { + "url": "https://clue.engineering/support", + "type": "custom" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2022-02-21T13:15:14+00:00" + }, + { + "name": "composer/ca-bundle", + "version": "1.3.7", + "source": { + "type": "git", + "url": "https://github.com/composer/ca-bundle.git", + "reference": "76e46335014860eec1aa5a724799a00a2e47cc85" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/76e46335014860eec1aa5a724799a00a2e47cc85", + "reference": "76e46335014860eec1aa5a724799a00a2e47cc85", "shasum": "" }, "require": { @@ -109,7 +230,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/ca-bundle/issues", - "source": "https://github.com/composer/ca-bundle/tree/1.3.5" + "source": "https://github.com/composer/ca-bundle/tree/1.3.7" }, "funding": [ { @@ -125,26 +246,26 @@ "type": "tidelift" } ], - "time": "2023-01-11T08:27:00+00:00" + "time": "2023-08-30T09:31:38+00:00" }, { "name": "composer/class-map-generator", - "version": "1.0.0", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/composer/class-map-generator.git", - "reference": "1e1cb2b791facb2dfe32932a7718cf2571187513" + "reference": "953cc4ea32e0c31f2185549c7d216d7921f03da9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/class-map-generator/zipball/1e1cb2b791facb2dfe32932a7718cf2571187513", - "reference": "1e1cb2b791facb2dfe32932a7718cf2571187513", + "url": "https://api.github.com/repos/composer/class-map-generator/zipball/953cc4ea32e0c31f2185549c7d216d7921f03da9", + "reference": "953cc4ea32e0c31f2185549c7d216d7921f03da9", "shasum": "" }, "require": { - "composer/pcre": "^2 || ^3", + "composer/pcre": "^2.1 || ^3.1", "php": "^7.2 || ^8.0", - "symfony/finder": "^4.4 || ^5.3 || ^6" + "symfony/finder": "^4.4 || ^5.3 || ^6 || ^7" }, "require-dev": { "phpstan/phpstan": "^1.6", @@ -182,7 +303,7 @@ ], "support": { "issues": "https://github.com/composer/class-map-generator/issues", - "source": "https://github.com/composer/class-map-generator/tree/1.0.0" + "source": "https://github.com/composer/class-map-generator/tree/1.1.0" }, "funding": [ { @@ -198,7 +319,7 @@ "type": "tidelift" } ], - "time": "2022-06-19T11:31:27+00:00" + "time": "2023-06-30T13:58:57+00:00" }, { "name": "composer/pcre", @@ -348,16 +469,16 @@ }, { "name": "doctrine/deprecations", - "version": "v1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3" + "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", - "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/4f2d4f2836e7ec4e7a8625e75c6aa916004db931", + "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931", "shasum": "" }, "require": { @@ -389,9 +510,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/v1.1.1" + "source": "https://github.com/doctrine/deprecations/tree/1.1.2" }, - "time": "2023-06-03T09:27:29+00:00" + "time": "2023-09-27T20:04:15+00:00" }, { "name": "doctrine/lexer", @@ -535,16 +656,16 @@ }, { "name": "egulias/email-validator", - "version": "3.2.5", + "version": "3.2.6", "source": { "type": "git", "url": "https://github.com/egulias/EmailValidator.git", - "reference": "b531a2311709443320c786feb4519cfaf94af796" + "reference": "e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/b531a2311709443320c786feb4519cfaf94af796", - "reference": "b531a2311709443320c786feb4519cfaf94af796", + "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7", + "reference": "e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7", "shasum": "" }, "require": { @@ -590,7 +711,7 @@ ], "support": { "issues": "https://github.com/egulias/EmailValidator/issues", - "source": "https://github.com/egulias/EmailValidator/tree/3.2.5" + "source": "https://github.com/egulias/EmailValidator/tree/3.2.6" }, "funding": [ { @@ -598,7 +719,7 @@ "type": "github" } ], - "time": "2023-01-02T17:26:14+00:00" + "time": "2023-06-01T07:04:22+00:00" }, { "name": "filp/whoops", @@ -770,6 +891,89 @@ ], "time": "2022-08-05T20:32:58+00:00" }, + { + "name": "guzzlehttp/promises", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "111166291a0f8130081195ac4556a5587d7f1b5d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/111166291a0f8130081195ac4556a5587d7f1b5d", + "reference": "111166291a0f8130081195ac4556a5587d7f1b5d", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.1", + "phpunit/phpunit": "^8.5.29 || ^9.5.23" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/2.0.1" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], + "time": "2023-08-03T15:11:55+00:00" + }, { "name": "io-developer/php-whois", "version": "4.1.10", @@ -832,6 +1036,65 @@ }, "time": "2023-01-25T14:42:45+00:00" }, + { + "name": "jean85/pretty-package-versions", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://github.com/Jean85/pretty-package-versions.git", + "reference": "ae547e455a3d8babd07b96966b17d7fd21d9c6af" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/ae547e455a3d8babd07b96966b17d7fd21d9c6af", + "reference": "ae547e455a3d8babd07b96966b17d7fd21d9c6af", + "shasum": "" + }, + "require": { + "composer-runtime-api": "^2.0.0", + "php": "^7.1|^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.17", + "jean85/composer-provided-replaced-stub-package": "^1.0", + "phpstan/phpstan": "^0.12.66", + "phpunit/phpunit": "^7.5|^8.5|^9.4", + "vimeo/psalm": "^4.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Jean85\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alessandro Lai", + "email": "alessandro.lai85@gmail.com" + } + ], + "description": "A library to get pretty versions strings of installed dependencies", + "keywords": [ + "composer", + "package", + "release", + "versions" + ], + "support": { + "issues": "https://github.com/Jean85/pretty-package-versions/issues", + "source": "https://github.com/Jean85/pretty-package-versions/tree/2.0.5" + }, + "time": "2021-10-08T21:21:46+00:00" + }, { "name": "lcharette/webpack-encore-twig", "version": "1.1.0", @@ -1166,16 +1429,16 @@ }, { "name": "masterminds/html5", - "version": "2.8.0", + "version": "2.8.1", "source": { "type": "git", "url": "https://github.com/Masterminds/html5-php.git", - "reference": "3c5d5a56d56f48a1ca08a0670f0f80c1dad368f3" + "reference": "f47dcf3c70c584de14f21143c55d9939631bc6cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/3c5d5a56d56f48a1ca08a0670f0f80c1dad368f3", - "reference": "3c5d5a56d56f48a1ca08a0670f0f80c1dad368f3", + "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/f47dcf3c70c584de14f21143c55d9939631bc6cf", + "reference": "f47dcf3c70c584de14f21143c55d9939631bc6cf", "shasum": "" }, "require": { @@ -1227,9 +1490,9 @@ ], "support": { "issues": "https://github.com/Masterminds/html5-php/issues", - "source": "https://github.com/Masterminds/html5-php/tree/2.8.0" + "source": "https://github.com/Masterminds/html5-php/tree/2.8.1" }, - "time": "2023-04-26T07:27:39+00:00" + "time": "2023-05-10T11:58:31+00:00" }, { "name": "maxmind-db/reader", @@ -1524,16 +1787,16 @@ }, { "name": "nette/schema", - "version": "v1.2.4", + "version": "v1.2.5", "source": { "type": "git", "url": "https://github.com/nette/schema.git", - "reference": "c9ff517a53903b3d4e29ec547fb20feecb05b8ab" + "reference": "0462f0166e823aad657c9224d0f849ecac1ba10a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/schema/zipball/c9ff517a53903b3d4e29ec547fb20feecb05b8ab", - "reference": "c9ff517a53903b3d4e29ec547fb20feecb05b8ab", + "url": "https://api.github.com/repos/nette/schema/zipball/0462f0166e823aad657c9224d0f849ecac1ba10a", + "reference": "0462f0166e823aad657c9224d0f849ecac1ba10a", "shasum": "" }, "require": { @@ -1580,22 +1843,22 @@ ], "support": { "issues": "https://github.com/nette/schema/issues", - "source": "https://github.com/nette/schema/tree/v1.2.4" + "source": "https://github.com/nette/schema/tree/v1.2.5" }, - "time": "2023-08-05T18:56:25+00:00" + "time": "2023-10-05T20:37:59+00:00" }, { "name": "nette/utils", - "version": "v4.0.1", + "version": "v4.0.2", "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "9124157137da01b1f5a5a22d6486cb975f26db7e" + "reference": "cead6637226456b35e1175cc53797dd585d85545" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/9124157137da01b1f5a5a22d6486cb975f26db7e", - "reference": "9124157137da01b1f5a5a22d6486cb975f26db7e", + "url": "https://api.github.com/repos/nette/utils/zipball/cead6637226456b35e1175cc53797dd585d85545", + "reference": "cead6637226456b35e1175cc53797dd585d85545", "shasum": "" }, "require": { @@ -1617,8 +1880,7 @@ "ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()", "ext-json": "to use Nette\\Utils\\Json", "ext-mbstring": "to use Strings::lower() etc...", - "ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()", - "ext-xml": "to use Strings::length() etc. when mbstring is not available" + "ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()" }, "type": "library", "extra": { @@ -1667,9 +1929,87 @@ ], "support": { "issues": "https://github.com/nette/utils/issues", - "source": "https://github.com/nette/utils/tree/v4.0.1" + "source": "https://github.com/nette/utils/tree/v4.0.2" }, - "time": "2023-07-30T15:42:21+00:00" + "time": "2023-09-19T11:58:07+00:00" + }, + { + "name": "nyholm/psr7", + "version": "1.8.0", + "source": { + "type": "git", + "url": "https://github.com/Nyholm/psr7.git", + "reference": "3cb4d163b58589e47b35103e8e5e6a6a475b47be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Nyholm/psr7/zipball/3cb4d163b58589e47b35103e8e5e6a6a475b47be", + "reference": "3cb4d163b58589e47b35103e8e5e6a6a475b47be", + "shasum": "" + }, + "require": { + "php": ">=7.2", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0" + }, + "provide": { + "php-http/message-factory-implementation": "1.0", + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "http-interop/http-factory-tests": "^0.9", + "php-http/message-factory": "^1.0", + "php-http/psr7-integration-tests": "^1.0", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.4", + "symfony/error-handler": "^4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8-dev" + } + }, + "autoload": { + "psr-4": { + "Nyholm\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com" + }, + { + "name": "Martijn van der Ven", + "email": "martijn@vanderven.se" + } + ], + "description": "A fast PHP7 implementation of PSR-7", + "homepage": "https://tnyholm.se", + "keywords": [ + "psr-17", + "psr-7" + ], + "support": { + "issues": "https://github.com/Nyholm/psr7/issues", + "source": "https://github.com/Nyholm/psr7/tree/1.8.0" + }, + "funding": [ + { + "url": "https://github.com/Zegnat", + "type": "github" + }, + { + "url": "https://github.com/nyholm", + "type": "github" + } + ], + "time": "2023-05-02T11:26:24+00:00" }, { "name": "phenx/php-font-lib", @@ -1761,6 +2101,386 @@ }, "time": "2022-09-06T12:16:56+00:00" }, + { + "name": "php-http/client-common", + "version": "2.7.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/client-common.git", + "reference": "880509727a447474d2a71b7d7fa5d268ddd3db4b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/client-common/zipball/880509727a447474d2a71b7d7fa5d268ddd3db4b", + "reference": "880509727a447474d2a71b7d7fa5d268ddd3db4b", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "php-http/httplug": "^2.0", + "php-http/message": "^1.6", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0 || ^2.0", + "symfony/options-resolver": "~4.0.15 || ~4.1.9 || ^4.2.1 || ^5.0 || ^6.0", + "symfony/polyfill-php80": "^1.17" + }, + "require-dev": { + "doctrine/instantiator": "^1.1", + "guzzlehttp/psr7": "^1.4", + "nyholm/psr7": "^1.2", + "phpspec/phpspec": "^5.1 || ^6.3 || ^7.1", + "phpspec/prophecy": "^1.10.2", + "phpunit/phpunit": "^7.5.20 || ^8.5.33 || ^9.6.7" + }, + "suggest": { + "ext-json": "To detect JSON responses with the ContentTypePlugin", + "ext-libxml": "To detect XML responses with the ContentTypePlugin", + "php-http/cache-plugin": "PSR-6 Cache plugin", + "php-http/logger-plugin": "PSR-3 Logger plugin", + "php-http/stopwatch-plugin": "Symfony Stopwatch plugin" + }, + "type": "library", + "autoload": { + "psr-4": { + "Http\\Client\\Common\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Common HTTP Client implementations and tools for HTTPlug", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "common", + "http", + "httplug" + ], + "support": { + "issues": "https://github.com/php-http/client-common/issues", + "source": "https://github.com/php-http/client-common/tree/2.7.0" + }, + "time": "2023-05-17T06:46:59+00:00" + }, + { + "name": "php-http/discovery", + "version": "1.19.1", + "source": { + "type": "git", + "url": "https://github.com/php-http/discovery.git", + "reference": "57f3de01d32085fea20865f9b16fb0e69347c39e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/discovery/zipball/57f3de01d32085fea20865f9b16fb0e69347c39e", + "reference": "57f3de01d32085fea20865f9b16fb0e69347c39e", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0|^2.0", + "php": "^7.1 || ^8.0" + }, + "conflict": { + "nyholm/psr7": "<1.0", + "zendframework/zend-diactoros": "*" + }, + "provide": { + "php-http/async-client-implementation": "*", + "php-http/client-implementation": "*", + "psr/http-client-implementation": "*", + "psr/http-factory-implementation": "*", + "psr/http-message-implementation": "*" + }, + "require-dev": { + "composer/composer": "^1.0.2|^2.0", + "graham-campbell/phpspec-skip-example-extension": "^5.0", + "php-http/httplug": "^1.0 || ^2.0", + "php-http/message-factory": "^1.0", + "phpspec/phpspec": "^5.1 || ^6.1 || ^7.3", + "symfony/phpunit-bridge": "^6.2" + }, + "type": "composer-plugin", + "extra": { + "class": "Http\\Discovery\\Composer\\Plugin", + "plugin-optional": true + }, + "autoload": { + "psr-4": { + "Http\\Discovery\\": "src/" + }, + "exclude-from-classmap": [ + "src/Composer/Plugin.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations", + "homepage": "http://php-http.org", + "keywords": [ + "adapter", + "client", + "discovery", + "factory", + "http", + "message", + "psr17", + "psr7" + ], + "support": { + "issues": "https://github.com/php-http/discovery/issues", + "source": "https://github.com/php-http/discovery/tree/1.19.1" + }, + "time": "2023-07-11T07:02:26+00:00" + }, + { + "name": "php-http/httplug", + "version": "2.4.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/httplug.git", + "reference": "625ad742c360c8ac580fcc647a1541d29e257f67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/httplug/zipball/625ad742c360c8ac580fcc647a1541d29e257f67", + "reference": "625ad742c360c8ac580fcc647a1541d29e257f67", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "php-http/promise": "^1.1", + "psr/http-client": "^1.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "require-dev": { + "friends-of-phpspec/phpspec-code-coverage": "^4.1 || ^5.0 || ^6.0", + "phpspec/phpspec": "^5.1 || ^6.0 || ^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eric GELOEN", + "email": "geloen.eric@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "HTTPlug, the HTTP client abstraction for PHP", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "http" + ], + "support": { + "issues": "https://github.com/php-http/httplug/issues", + "source": "https://github.com/php-http/httplug/tree/2.4.0" + }, + "time": "2023-04-14T15:10:03+00:00" + }, + { + "name": "php-http/message", + "version": "1.16.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/message.git", + "reference": "47a14338bf4ebd67d317bf1144253d7db4ab55fd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/message/zipball/47a14338bf4ebd67d317bf1144253d7db4ab55fd", + "reference": "47a14338bf4ebd67d317bf1144253d7db4ab55fd", + "shasum": "" + }, + "require": { + "clue/stream-filter": "^1.5", + "php": "^7.2 || ^8.0", + "psr/http-message": "^1.1 || ^2.0" + }, + "provide": { + "php-http/message-factory-implementation": "1.0" + }, + "require-dev": { + "ergebnis/composer-normalize": "^2.6", + "ext-zlib": "*", + "guzzlehttp/psr7": "^1.0 || ^2.0", + "laminas/laminas-diactoros": "^2.0 || ^3.0", + "php-http/message-factory": "^1.0.2", + "phpspec/phpspec": "^5.1 || ^6.3 || ^7.1", + "slim/slim": "^3.0" + }, + "suggest": { + "ext-zlib": "Used with compressor/decompressor streams", + "guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories", + "laminas/laminas-diactoros": "Used with Diactoros Factories", + "slim/slim": "Used with Slim Framework PSR-7 implementation" + }, + "type": "library", + "autoload": { + "files": [ + "src/filters.php" + ], + "psr-4": { + "Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "HTTP Message related tools", + "homepage": "http://php-http.org", + "keywords": [ + "http", + "message", + "psr-7" + ], + "support": { + "issues": "https://github.com/php-http/message/issues", + "source": "https://github.com/php-http/message/tree/1.16.0" + }, + "time": "2023-05-17T06:43:38+00:00" + }, + { + "name": "php-http/message-factory", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/message-factory.git", + "reference": "4d8778e1c7d405cbb471574821c1ff5b68cc8f57" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/message-factory/zipball/4d8778e1c7d405cbb471574821c1ff5b68cc8f57", + "reference": "4d8778e1c7d405cbb471574821c1ff5b68cc8f57", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Factory interfaces for PSR-7 HTTP Message", + "homepage": "http://php-http.org", + "keywords": [ + "factory", + "http", + "message", + "stream", + "uri" + ], + "support": { + "issues": "https://github.com/php-http/message-factory/issues", + "source": "https://github.com/php-http/message-factory/tree/1.1.0" + }, + "abandoned": "psr/http-factory", + "time": "2023-04-14T14:16:17+00:00" + }, + { + "name": "php-http/promise", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/promise.git", + "reference": "ef4905bfb492ff389eb7f12e26925a0f20073050" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/promise/zipball/ef4905bfb492ff389eb7f12e26925a0f20073050", + "reference": "ef4905bfb492ff389eb7f12e26925a0f20073050", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "friends-of-phpspec/phpspec-code-coverage": "^4.3.2 || ^6.3", + "phpspec/phpspec": "^5.1.2 || ^6.2 || ^7.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Http\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Joel Wurtz", + "email": "joel.wurtz@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Promise used for asynchronous HTTP requests", + "homepage": "http://httplug.io", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/php-http/promise/issues", + "source": "https://github.com/php-http/promise/tree/1.2.0" + }, + "time": "2023-10-24T09:20:26+00:00" + }, { "name": "phpmyadmin/motranslator", "version": "5.3.1", @@ -2082,6 +2802,113 @@ }, "time": "2019-01-08T18:20:26+00:00" }, + { + "name": "psr/http-client", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client" + }, + "time": "2023-09-23T14:17:50+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "e616d01114759c4c489f93b099585439f795fe35" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/e616d01114759c4c489f93b099585439f795fe35", + "reference": "e616d01114759c4c489f93b099585439f795fe35", + "shasum": "" + }, + "require": { + "php": ">=7.0.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory/tree/1.0.2" + }, + "time": "2023-04-10T20:10:41+00:00" + }, { "name": "psr/http-message", "version": "2.0", @@ -2185,6 +3012,188 @@ }, "time": "2021-07-14T16:46:02+00:00" }, + { + "name": "ramsey/collection", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/ramsey/collection.git", + "reference": "ad7475d1c9e70b190ecffc58f2d989416af339b4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ramsey/collection/zipball/ad7475d1c9e70b190ecffc58f2d989416af339b4", + "reference": "ad7475d1c9e70b190ecffc58f2d989416af339b4", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "symfony/polyfill-php81": "^1.23" + }, + "require-dev": { + "captainhook/plugin-composer": "^5.3", + "ergebnis/composer-normalize": "^2.28.3", + "fakerphp/faker": "^1.21", + "hamcrest/hamcrest-php": "^2.0", + "jangregor/phpstan-prophecy": "^1.0", + "mockery/mockery": "^1.5", + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.3", + "phpcsstandards/phpcsutils": "^1.0.0-rc1", + "phpspec/prophecy-phpunit": "^2.0", + "phpstan/extension-installer": "^1.2", + "phpstan/phpstan": "^1.9", + "phpstan/phpstan-mockery": "^1.1", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^9.5", + "psalm/plugin-mockery": "^1.1", + "psalm/plugin-phpunit": "^0.18.4", + "ramsey/coding-standard": "^2.0.3", + "ramsey/conventional-commits": "^1.3", + "vimeo/psalm": "^5.4" + }, + "type": "library", + "extra": { + "captainhook": { + "force-install": true + }, + "ramsey/conventional-commits": { + "configFile": "conventional-commits.json" + } + }, + "autoload": { + "psr-4": { + "Ramsey\\Collection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ben Ramsey", + "email": "ben@benramsey.com", + "homepage": "https://benramsey.com" + } + ], + "description": "A PHP library for representing and manipulating collections.", + "keywords": [ + "array", + "collection", + "hash", + "map", + "queue", + "set" + ], + "support": { + "issues": "https://github.com/ramsey/collection/issues", + "source": "https://github.com/ramsey/collection/tree/1.3.0" + }, + "funding": [ + { + "url": "https://github.com/ramsey", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/ramsey/collection", + "type": "tidelift" + } + ], + "time": "2022-12-27T19:12:24+00:00" + }, + { + "name": "ramsey/uuid", + "version": "4.7.4", + "source": { + "type": "git", + "url": "https://github.com/ramsey/uuid.git", + "reference": "60a4c63ab724854332900504274f6150ff26d286" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/60a4c63ab724854332900504274f6150ff26d286", + "reference": "60a4c63ab724854332900504274f6150ff26d286", + "shasum": "" + }, + "require": { + "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11", + "ext-json": "*", + "php": "^8.0", + "ramsey/collection": "^1.2 || ^2.0" + }, + "replace": { + "rhumsaa/uuid": "self.version" + }, + "require-dev": { + "captainhook/captainhook": "^5.10", + "captainhook/plugin-composer": "^5.3", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", + "doctrine/annotations": "^1.8", + "ergebnis/composer-normalize": "^2.15", + "mockery/mockery": "^1.3", + "paragonie/random-lib": "^2", + "php-mock/php-mock": "^2.2", + "php-mock/php-mock-mockery": "^1.3", + "php-parallel-lint/php-parallel-lint": "^1.1", + "phpbench/phpbench": "^1.0", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-mockery": "^1.1", + "phpstan/phpstan-phpunit": "^1.1", + "phpunit/phpunit": "^8.5 || ^9", + "ramsey/composer-repl": "^1.4", + "slevomat/coding-standard": "^8.4", + "squizlabs/php_codesniffer": "^3.5", + "vimeo/psalm": "^4.9" + }, + "suggest": { + "ext-bcmath": "Enables faster math with arbitrary-precision integers using BCMath.", + "ext-gmp": "Enables faster math with arbitrary-precision integers using GMP.", + "ext-uuid": "Enables the use of PeclUuidTimeGenerator and PeclUuidRandomGenerator.", + "paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter", + "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type." + }, + "type": "library", + "extra": { + "captainhook": { + "force-install": true + } + }, + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Ramsey\\Uuid\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A PHP library for generating and working with universally unique identifiers (UUIDs).", + "keywords": [ + "guid", + "identifier", + "uuid" + ], + "support": { + "issues": "https://github.com/ramsey/uuid/issues", + "source": "https://github.com/ramsey/uuid/tree/4.7.4" + }, + "funding": [ + { + "url": "https://github.com/ramsey", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/ramsey/uuid", + "type": "tidelift" + } + ], + "time": "2023-04-15T23:01:58+00:00" + }, { "name": "sabberworm/php-css-parser", "version": "8.4.0", @@ -2238,6 +3247,106 @@ }, "time": "2021-12-11T13:40:54+00:00" }, + { + "name": "sentry/sentry", + "version": "3.22.0", + "source": { + "type": "git", + "url": "https://github.com/getsentry/sentry-php.git", + "reference": "c0e3df5a5c1d133cd9461e7672568ff07042c19d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/c0e3df5a5c1d133cd9461e7672568ff07042c19d", + "reference": "c0e3df5a5c1d133cd9461e7672568ff07042c19d", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-mbstring": "*", + "guzzlehttp/promises": "^1.5.3|^2.0", + "jean85/pretty-package-versions": "^1.5|^2.0.4", + "php": "^7.2|^8.0", + "php-http/async-client-implementation": "^1.0", + "php-http/client-common": "^1.5|^2.0", + "php-http/discovery": "^1.15", + "php-http/httplug": "^1.1|^2.0", + "php-http/message": "^1.5", + "php-http/message-factory": "^1.1", + "psr/http-factory": "^1.0", + "psr/http-factory-implementation": "^1.0", + "psr/log": "^1.0|^2.0|^3.0", + "symfony/options-resolver": "^3.4.43|^4.4.30|^5.0.11|^6.0|^7.0", + "symfony/polyfill-php80": "^1.17" + }, + "conflict": { + "php-http/client-common": "1.8.0", + "raven/raven": "*" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.19|3.4.*", + "guzzlehttp/psr7": "^1.8.4|^2.1.1", + "http-interop/http-factory-guzzle": "^1.0", + "monolog/monolog": "^1.6|^2.0|^3.0", + "nikic/php-parser": "^4.10.3", + "php-http/mock-client": "^1.3", + "phpbench/phpbench": "^1.0", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^1.3", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^8.5.14|^9.4", + "symfony/phpunit-bridge": "^5.2|^6.0", + "vimeo/psalm": "^4.17" + }, + "suggest": { + "monolog/monolog": "Allow sending log messages to Sentry by using the included Monolog handler." + }, + "type": "library", + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Sentry\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sentry", + "email": "accounts@sentry.io" + } + ], + "description": "A PHP SDK for Sentry (http://sentry.io)", + "homepage": "http://sentry.io", + "keywords": [ + "crash-reporting", + "crash-reports", + "error-handler", + "error-monitoring", + "log", + "logging", + "sentry" + ], + "support": { + "issues": "https://github.com/getsentry/sentry-php/issues", + "source": "https://github.com/getsentry/sentry-php/tree/3.22.0" + }, + "funding": [ + { + "url": "https://sentry.io/", + "type": "custom" + }, + { + "url": "https://sentry.io/pricing/", + "type": "custom" + } + ], + "time": "2023-10-23T20:34:53+00:00" + }, { "name": "stripe/stripe-php", "version": "v13.1.0", @@ -3776,6 +4885,73 @@ ], "time": "2023-01-11T11:50:03+00:00" }, + { + "name": "symfony/options-resolver", + "version": "v6.0.19", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "6a180d1c45e0d9797470ca9eb46215692de00fa3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/6a180d1c45e0d9797470ca9eb46215692de00fa3", + "reference": "6a180d1c45e0d9797470ca9eb46215692de00fa3", + "shasum": "" + }, + "require": { + "php": ">=8.0.2", + "symfony/deprecation-contracts": "^2.1|^3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an improved replacement for the array_replace PHP function", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "support": { + "source": "https://github.com/symfony/options-resolver/tree/v6.0.19" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-01-01T08:36:10+00:00" + }, { "name": "symfony/polyfill-ctype", "version": "v1.28.0", @@ -7474,73 +8650,6 @@ ], "time": "2023-01-01T08:36:10+00:00" }, - { - "name": "symfony/options-resolver", - "version": "v6.0.19", - "source": { - "type": "git", - "url": "https://github.com/symfony/options-resolver.git", - "reference": "6a180d1c45e0d9797470ca9eb46215692de00fa3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/6a180d1c45e0d9797470ca9eb46215692de00fa3", - "reference": "6a180d1c45e0d9797470ca9eb46215692de00fa3", - "shasum": "" - }, - "require": { - "php": ">=8.0.2", - "symfony/deprecation-contracts": "^2.1|^3" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\OptionsResolver\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides an improved replacement for the array_replace PHP function", - "homepage": "https://symfony.com", - "keywords": [ - "config", - "configuration", - "options" - ], - "support": { - "source": "https://github.com/symfony/options-resolver/tree/v6.0.19" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2023-01-01T08:36:10+00:00" - }, { "name": "symfony/phpunit-bridge", "version": "v6.3.6", diff --git a/cspell.json b/cspell.json index 264ad9c03..a98c50c02 100644 --- a/cspell.json +++ b/cspell.json @@ -33,7 +33,9 @@ "EMERG", "exploitability", "birthdate", - "Birthdate" + "Birthdate", + "jhurliman", + "jambroseclarke" ], "ignoreWords": [ diff --git a/src/config-sample.php b/src/config-sample.php index b65dd86b0..0227f0e0a 100644 --- a/src/config-sample.php +++ b/src/config-sample.php @@ -21,7 +21,34 @@ return [ 'session_lifespan' => 7200, ], - 'salt' => '', + 'debug_and_monitoring' => [ + /* + * Enable or disable displaying advanced debugging messages. + * You should keep this disabled unless you're making tests as it can reveal some information about your server. + */ + 'debug' => false, + /* + * Enable or disable stacktraces when an exception is thrown (also requires debug to be enabled). + */ + 'log_stacktrace' => true, + /* + * How long the stacktrace should be. + */ + 'stacktrace_length' => 25, + + /* + * Enables automated error, stability, and performance reporting. + * Private information is scrubbed from any info before being sent. + * FOSSBilling uses Sentry.io for error reporting which has a full writeup on their security and privacy practices here: https://sentry.io/security/. + * Enabling error reporting will help us proactively identify and fix bugs in FOSSBilling as well as provide better technical support. + */ + 'report_errors' => false, + ], + + 'info' => [ + 'salt' => '', + 'instance_id' => 'XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX', + ], /* * Full URL where FOSSBilling is installed with trailing slash. @@ -33,27 +60,12 @@ return [ */ 'admin_area_prefix' => '/admin', - /* - * Enable or disable displaying advanced debugging messages. - * You should keep this disabled unless you're making tests as it can reveal some information about your server. - */ - 'debug' => false, - /* * Configure the update branch for the automatic updater. * Currently acceptable options are "release" or "preview". */ 'update_branch' => 'release', - /* - * Enable or disable stacktraces when an exception is thrown (also requires debug to be enabled). - */ - 'log_stacktrace' => true, - /* - * How long the stacktrace should be. - */ - 'stacktrace_length' => 25, - 'maintenance_mode' => [ /* * Enable or disable the system maintenance mode. @@ -158,12 +170,12 @@ return [ 'rate_limit' => 1000, /** - * Note about rate-limiting login attempts: - * When the limit is reached, a default delay of 2 seconds is added to the request. - * This makes brute-forcing a password useless while not outright blocking legitimate traffic. - * When calculating, ensure the rate-limited traffic can still make enough requests to stay rate limited - * Ex: One request every 2 seconds is more than 20 times in 1 minute, so the IP will remain throttled. - */ + * Note about rate-limiting login attempts: + * When the limit is reached, a default delay of 2 seconds is added to the request. + * This makes brute-forcing a password useless while not outright blocking legitimate traffic. + * When calculating, ensure the rate-limited traffic can still make enough requests to stay rate limited + * Ex: One request every 2 seconds is more than 20 times in 1 minute, so the IP will remain throttled. + */ 'throttle_delay' => 2, // Time span login for limit in seconds @@ -171,7 +183,7 @@ return [ // How many login requests allowed per time span 'rate_limit_login' => 20, - + /* * This enables the usage of a token to protect the system from CSRF attacks. * Disabling this is highly discouraged and opens your instance to a known vulnerability. diff --git a/src/di.php b/src/di.php index f64b46796..c510b7011 100644 --- a/src/di.php +++ b/src/di.php @@ -327,7 +327,7 @@ $di['twig'] = $di->factory(function () use ($di) { if (($config['i18n']['locale'] ?? 'en_US') == 'en_US') { $dateFormatter = new \IntlDateFormatter('en', constant("\IntlDateFormatter::$date_format"), constant("\IntlDateFormatter::$time_format"), $timezone, null, $datetime_pattern); } else { - throw new \Box_Exception('It appears you are trying to use FOSSBilling without the php intl extension enabled. FOSSBilling includes a polyfill for the intl extension, however it does not support :locale. Please enable the intl extension.', [':locale' => $config['i18n']['locale']]); + throw new \FOSSBilling\InformationException('It appears you are trying to use FOSSBilling without the php intl extension enabled. FOSSBilling includes a polyfill for the intl extension, however it does not support :locale. Please enable the intl extension.', [':locale' => $config['i18n']['locale']]); } } @@ -462,7 +462,7 @@ $di['loggedin_client'] = function () use ($di) { * * @return \Model_Admin|null The existing logged-in admin model object, or null if no admin is logged in. * - * @throws \Box_Exception If the script is running in CLI or CGI mode and there is no cron admin available. + * @throws \FOSSBilling\Exception If the script is running in CLI or CGI mode and there is no cron admin available. */ $di['loggedin_admin'] = function () use ($di) { if (Environment::isCLI()) { diff --git a/src/index.php b/src/index.php index c735c5357..387ea1b2f 100644 --- a/src/index.php +++ b/src/index.php @@ -47,14 +47,14 @@ $app->setDi($di); if (!is_null($http_err_code)) { switch ($http_err_code) { case '404': - $e = new Box_Exception('Page :url not found', [':url' => $url], 404); + $e = new FOSSBilling\Exception('Page :url not found', [':url' => $url], 404); echo $app->show404($e); break; default: $http_err_code = intval($http_err_code); http_response_code($http_err_code); - $e = new Box_Exception('HTTP Error :err_code occurred while attempting to load :url', [':err_code' => $http_err_code, ':url' => $url], $http_err_code); + $e = new FOSSBilling\Exception('HTTP Error :err_code occurred while attempting to load :url', [':err_code' => $http_err_code, ':url' => $url], $http_err_code); echo $app->render('error', ['exception' => $e]); } exit; diff --git a/src/install/assets/install.html.twig b/src/install/assets/install.html.twig index 6dbcde049..50d02c5a8 100644 --- a/src/install/assets/install.html.twig +++ b/src/install/assets/install.html.twig @@ -10,17 +10,35 @@
  • Delete your database tables or recreate your database.
  • Delete config.php.
  • Refresh this page and you will see the installer.

    + {% else %}

    Thank you for choosing FOSSBilling! Our installer will have you up and running in just a few more minutes.
    Simply follow each step below and soon you'll have FOSSBilling installed.

    - -

    FOSSBilling is licensed under the Apache License, Version 2.0. Click here for full license text.


    +
    - Step 1) Check system requirements + Step 1) Agree to the FOSSBilling license and review error reporting options + + + FOSSBilling is licensed under the Apache License version 2.0. You assume responsibility to verify it's use and compliance with all local laws that may apply. + +

    + + + Learn more +
    + +
    + Step 2) Check system requirements {% if canInstall %}

    All basic requirements to install FOSSBilling are met.

    {% else %} @@ -101,9 +119,8 @@

    Meet all system requirements, then refresh the page to see the setup form.

    {% else %} - -
    - Step 2) Enter database details +
    + Step 3) Enter database details

    Enter your MySQL connection information.

    @@ -126,8 +143,8 @@
    -
    - Step 3) Configure your administrator account +
    + Step 4) Configure your administrator account

    Create your administrator login details below.

    @@ -143,8 +160,8 @@
    -
    - Step 4) Configure the default currency +
    + Step 5 Configure the default currency

    Configure your default currency and price format.

    @@ -157,11 +174,6 @@ - -
    @@ -175,7 +187,32 @@
    - + + + + +
    + + +

    Error reporting

    +

    FOSSBilling optionally includes automated error reporting which allows us to improve the software and offer better technical support.

    +

    Reports are collected using Sentry.io and data is retained securely for up to 90 days.

    +

    Automated data scrubbing and filtering is used to prevent sensitive information from being recorded.

    +

    See the FOSSBilling documentation for information on what's collected and why you should enable it.

    + +
    +
    {% endif %} {% endif %} {% endblock %} @@ -194,6 +231,7 @@ const step2 = document.getElementById("step-2"); const step3 = document.getElementById("step-3"); const step4 = document.getElementById("step-4"); + const step5 = document.getElementById("step-5"); function isStepAllowed(step) { for (let i = (step - 1); i >= 1; i--) { @@ -201,11 +239,11 @@ return false; } } - return step <= 5; + return step <= 6; } function updateStepVisibility(step) { - [step1, step2, step3, step4].forEach((stepElement, index) => { + [step1, step2, step3, step4, step5].forEach((stepElement, index) => { stepElement.open = index + 1 === step ? true : false; }); } @@ -226,7 +264,7 @@ function updateButtons() { backButton.disabled = currentStep === 1; - nextButton.disabled = currentStep === 5 || {{ canInstall ? 'false' : 'true' }}; + nextButton.disabled = currentStep === 6 || {{ canInstall ? 'false' : 'true' }}; if(currentStep === 5){ nextButton.hidden = true; @@ -287,7 +325,7 @@ } // Use event delegation for every step - [step2, step3, step4].forEach((stepElement, index) => { + [step2, step3, step4, step5].forEach((stepElement, index) => { handleStepToggle(stepElement, index + 2); }); }); diff --git a/src/install/assets/js/modal.js b/src/install/assets/js/modal.js new file mode 100644 index 000000000..93a7abc0b --- /dev/null +++ b/src/install/assets/js/modal.js @@ -0,0 +1,94 @@ +/* + * Modal + * + * Pico.css - https://picocss.com + * Copyright 2019-2023 - Licensed under MIT + */ + +// Config +const isOpenClass = "modal-is-open"; +const openingClass = "modal-is-opening"; +const closingClass = "modal-is-closing"; +const animationDuration = 250; // ms +let visibleModal = null; + +// Toggle modal +const toggleModal = (event) => { + event.preventDefault(); + const modal = document.getElementById(event.currentTarget.getAttribute("data-target")); + typeof modal != "undefined" && modal != null && isModalOpen(modal) + ? closeModal(modal) + : openModal(modal); +}; + +// Is modal open +const isModalOpen = (modal) => { + return modal.hasAttribute("open") && modal.getAttribute("open") != "false" ? true : false; +}; + +// Open modal +const openModal = (modal) => { + if (isScrollbarVisible()) { + document.documentElement.style.setProperty("--scrollbar-width", `${getScrollbarWidth()}px`); + } + document.documentElement.classList.add(isOpenClass, openingClass); + setTimeout(() => { + visibleModal = modal; + document.documentElement.classList.remove(openingClass); + }, animationDuration); + modal.setAttribute("open", true); +}; + +// Close modal +const closeModal = (modal) => { + visibleModal = null; + document.documentElement.classList.add(closingClass); + setTimeout(() => { + document.documentElement.classList.remove(closingClass, isOpenClass); + document.documentElement.style.removeProperty("--scrollbar-width"); + modal.removeAttribute("open"); + }, animationDuration); +}; + +// Close with a click outside +document.addEventListener("click", (event) => { + if (visibleModal != null) { + const modalContent = visibleModal.querySelector("article"); + const isClickInside = modalContent.contains(event.target); + !isClickInside && closeModal(visibleModal); + } +}); + +// Close with Esc key +document.addEventListener("keydown", (event) => { + if (event.key === "Escape" && visibleModal != null) { + closeModal(visibleModal); + } +}); + +// Get scrollbar width +const getScrollbarWidth = () => { + // Creating invisible container + const outer = document.createElement("div"); + outer.style.visibility = "hidden"; + outer.style.overflow = "scroll"; // forcing scrollbar to appear + outer.style.msOverflowStyle = "scrollbar"; // needed for WinJS apps + document.body.appendChild(outer); + + // Creating inner element and placing it in the container + const inner = document.createElement("div"); + outer.appendChild(inner); + + // Calculating difference between container's full width and the child width + const scrollbarWidth = outer.offsetWidth - inner.offsetWidth; + + // Removing temporary elements from the DOM + outer.parentNode.removeChild(outer); + + return scrollbarWidth; +}; + +// Is scrollbar visible +const isScrollbarVisible = () => { + return document.body.scrollHeight > screen.height; +}; diff --git a/src/install/assets/layout.html.twig b/src/install/assets/layout.html.twig index 7ab7a64d3..9aab51954 100644 --- a/src/install/assets/layout.html.twig +++ b/src/install/assets/layout.html.twig @@ -4,6 +4,7 @@ + FOSSBilling Installation

    ' . $error['title'] . '

    -

    ' . __trans('Error Code: #:number', [':number' => $code]) . '

    -

    ' . __trans('Component: :category', [':category' => $error['category']]) . '

    +
      +
    • ' . "Instance ID: $instanceID" . '
    • +
    • ' . "Error Code: #$code" . '
    • +
    • ' . 'Component: '. $error['category'] . '
    • +
    +

    ' . $error['message'] . '

    @@ -284,11 +311,11 @@ class ErrorPage if (og.style.display === "none") { og.style.display = "block"; specialized.style.display = "none"; - document.querySelector("#toggle").innerHTML = "' . __trans("Show specialized message") . '"; + document.querySelector("#toggle").innerHTML = "Show specialized message"; } else { og.style.display = "none"; specialized.style.display = "block"; - document.querySelector("#toggle").innerHTML = "' . __trans("Show original message") . '"; + document.querySelector("#toggle").innerHTML = "Show original message"; } } diff --git a/src/library/FOSSBilling/Exception.php b/src/library/FOSSBilling/Exception.php new file mode 100644 index 000000000..8ddb1c575 --- /dev/null +++ b/src/library/FOSSBilling/Exception.php @@ -0,0 +1,92 @@ +stackTrace($stackLength, $protected)); + } + + // Translate the exception + if (function_exists('__trans')) { + $message = __trans($message, $variables); + } elseif (is_array($variables)) { + $message = strtr($message, $variables); + } + + // Pass the message to the parent + parent::__construct($message, $code); + } + + + /** + * Big thank you to jhurliman and jambroseclarke on Stack Overflow for this backtrace formatter. + * We have slightly modified it for our purposes + * https://stackoverflow.com/a/32365961 + */ + private function stackTrace($Length = 25, $protected = false) + { + $stack = debug_backtrace($Length); + $output = ''; + + $stackLen = count($stack); + for ($i = 1; $i < $stackLen; $i++) { + $entry = $stack[$i]; + + $func = $entry['function'] . '('; + if (isset($entry['args'])) { + $argsLen = count($entry['args']); + for ($j = 0; $j < $argsLen; $j++) { + $my_entry = $entry['args'][$j]; + if ($protected) { + $func .= "***"; + } else if (is_string($my_entry)) { + $func .= $my_entry; + } + if ($j < $argsLen - 1) $func .= ', '; + } + } + $func .= ')'; + + $entry_file = 'NO_FILE'; + if (array_key_exists('file', $entry)) { + $entry_file = str_replace(PATH_ROOT, '', $entry['file']); + } + $entry_line = 'NO_LINE'; + if (array_key_exists('line', $entry)) { + $entry_line = $entry['line']; + } + $output .= $entry_file . ':' . $entry_line . ' - ' . $func . PHP_EOL; + } + return $output; + } +} diff --git a/src/library/FOSSBilling/ExtensionManager.php b/src/library/FOSSBilling/ExtensionManager.php index 0f3b521ee..8c66ad512 100644 --- a/src/library/FOSSBilling/ExtensionManager.php +++ b/src/library/FOSSBilling/ExtensionManager.php @@ -44,14 +44,15 @@ class ExtensionManager implements InjectionAwareInterface * * @return array The extension details * @example https://extensions.fossbilling.org/api/extension/Example An example of the API response - * @throws \Box_Exception + * + * @throws Exception */ public function getExtension(string $id): array { $manifest = $this->makeRequest('extension/' . $id); if (empty($manifest)) { - throw new \Box_Exception('Unable to fetch the extension details from the FOSSBilling extension directory.'); + throw new Exception('Unable to fetch the extension details from the FOSSBilling extension directory.'); } return $manifest; @@ -64,14 +65,15 @@ class ExtensionManager implements InjectionAwareInterface * * @return array The list of releases of the extension * @example https://extensions.fossbilling.org/api/extension/Example An example of the API response (the "releases" array) - * @throws \Box_Exception + * + * @throws Exception */ public function getExtensionReleases(string $id): array { $releases = $this->getExtension($id)['releases']; if (empty($releases) || !is_array($releases)) { - throw new \Box_Exception('Unable to fetch the releases of the extension from the FOSSBilling extension directory.'); + throw new Exception('Unable to fetch the releases of the extension from the FOSSBilling extension directory.'); } return $releases; @@ -84,7 +86,8 @@ class ExtensionManager implements InjectionAwareInterface * * @return array The latest release of the extension * @example https://extensions.fossbilling.org/api/extension/Example An example of the API response (the first element in the "releases" array) - * @throws \Box_Exception + * + * @throws Exception */ public function getLatestExtensionRelease(string $id): array { @@ -92,7 +95,7 @@ class ExtensionManager implements InjectionAwareInterface $latest = reset($releases); if (empty($latest) || !is_array($latest)) { - throw new \Box_Exception('Unable to fetch the latest release of the extension.'); + throw new Exception('Unable to fetch the latest release of the extension.'); } return $latest; @@ -129,7 +132,7 @@ class ExtensionManager implements InjectionAwareInterface $latest = $this->getLatestExtensionRelease($extension); if ($this->di['config']['update_branch'] === 'release') { - if (version_compare(\FOSSBilling\Version::VERSION, $latest['min_fossbilling_version'], '<')) { + if (version_compare(Version::VERSION, $latest['min_fossbilling_version'], '<')) { return false; } } @@ -144,7 +147,8 @@ class ExtensionManager implements InjectionAwareInterface * @param array $params The array of parameters to pass to the API endpoint * * @return array The API response - * @throws \Box_Exception + * + * @throws Exception */ public function makeRequest(string $endpoint, array $params = []): array { @@ -165,15 +169,15 @@ class ExtensionManager implements InjectionAwareInterface $json = $response->toArray(); if (is_null($json)) { - throw new \Box_Exception('Unable to connect to the FOSSBilling extension directory.', null, 1545); + throw new Exception('Unable to connect to the FOSSBilling extension directory.', null, 1545); } if (isset($json['error']) && is_array($json['error'])) { - throw new \Box_Exception($json['error']['message'], null, 746); + throw new Exception($json['error']['message'], null, 746); } if (!isset($json['result']) || !is_array($json['result'])) { - throw new \Box_Exception('Invalid response from the FOSSBilling extension directory.', null, 746); + throw new Exception('Invalid response from the FOSSBilling extension directory.', null, 746); } return $json['result']; diff --git a/src/library/FOSSBilling/InformationException.php b/src/library/FOSSBilling/InformationException.php new file mode 100644 index 000000000..e1665c95c --- /dev/null +++ b/src/library/FOSSBilling/InformationException.php @@ -0,0 +1,29 @@ += Email::PRIORITY_HIGHEST && $priority <= Email::PRIORITY_LOWEST) { $this->email->priority($priority); } else { - throw new \Box_Exception("Provided priority (:priority) is invalid. Please provide an integer between 1 and 5 or use the pre-defined symfony constants.", [':priority' => $priority]); + throw new InformationException("Provided priority (:priority) is invalid. Please provide an integer between 1 and 5 or use the pre-defined symfony constants.", [':priority' => $priority]); } } @@ -145,7 +145,7 @@ class Mail implements InjectionAwareInterface * * @param array|null $options An optional array of options specific to the chosen transport method. * - * @throws \Box_Exception If the transport method is unknown or if required options for the selected transport aren't defined + * @throws InformationException If the transport method is unknown or if required options for the selected transport aren't defined */ public function send(array|null $options = null): void { @@ -153,7 +153,7 @@ class Mail implements InjectionAwareInterface case 'sendmail': $dsn = 'sendmail://default'; if (!function_exists('proc_open')) { - throw new \Box_Exception("FOSSBilling requires the proc_open PHP function to be enabled when using the sendmail transport"); + throw new InformationException("FOSSBilling requires the proc_open PHP function to be enabled when using the sendmail transport"); } break; case 'smtp': @@ -161,18 +161,18 @@ class Mail implements InjectionAwareInterface break; case 'sendgrid': if (empty($options['sendgrid_key'])) { - throw new \Box_Exception("A Sendgrid API key is required to send emails via Sendgrid"); + throw new InformationException("A Sendgrid API key is required to send emails via Sendgrid"); } $dsn = 'sendgrid://' . $options['sendgrid_key'] . '@default'; break; case 'custom': if (empty($this->dsn)) { - throw new \Box_Exception("Unable to send email: 'Custom' transport method was selected without a custom DSN"); + throw new InformationException("Unable to send email: 'Custom' transport method was selected without a custom DSN"); } $dsn = $this->dsn; break; default: - throw new \Box_Exception('Unknown mail transport: :transport', [':transport' => $this->transport]); + throw new InformationException('Unknown mail transport: :transport', [':transport' => $this->transport]); } try { @@ -180,7 +180,7 @@ class Mail implements InjectionAwareInterface $mailer = new Mailer($transport); $mailer->send($this->email); } catch (TransportExceptionInterface $e) { - throw new \Box_Exception("Failed to send email via :transport with the exception :e", [':transport' => $this->transport, ':e' => $e]); + throw new Exception("Failed to send email via :transport with the exception :e", [':transport' => $this->transport, ':e' => $e]); } } @@ -189,14 +189,14 @@ class Mail implements InjectionAwareInterface * * @param array $options An associative array of SMTP options including 'smtp_host', 'smtp_port', 'smtp_username', and 'smtp_password'. * - * @throws \Box_Exception if the SMTP host or port is not configured. + * @throws InformationException if the SMTP host or port is not configured. * * @return string A string representing the DSN for the SMTP transport. */ private function __smtpDsn(array $options): string { if (empty($options['smtp_host']) || empty($options['smtp_port'])) { - throw new \Box_Exception('SMTP host or port is not configured'); + throw new InformationException('SMTP host or port is not configured'); } $host = urlencode(trim($options['smtp_host'])); diff --git a/src/library/FOSSBilling/SentryHelper.php b/src/library/FOSSBilling/SentryHelper.php new file mode 100644 index 000000000..34303fdcd --- /dev/null +++ b/src/library/FOSSBilling/SentryHelper.php @@ -0,0 +1,208 @@ + function (Event $event, ?EventHint $hint): ?Event { + if ($hint) { + $errorInfo = ErrorPage::getCodeInfo($hint->exception->getCode()); + + if (!$errorInfo['report']) { + return null; + } + + if ($hint->exception instanceof InformationException) { + return null; + } + } + + return $event; + }, + + 'environment' => Environment::getCurrentEnvironment(), + 'release' => Version::VERSION, + + // This option is disabled by default, but we set it to false here to be explicit & ensure it can never change unexpectedly. + 'send_default_pii' => false, + + // Stack traces are always sent for Exceptions, but if debug mode is enabled we will send them for errors too. + 'attach_stacktrace' => (bool)BB_DEBUG, + ]; + + /** + * Here we validate that the DSN is correctly set and that error reporting is enabled before passing it off to the Sentry SDK. + * It may look a bit odd, but the DSN placeholder value here is split into two strings and concatenated so we can easily perform a `sed` replacement of the placeholder without it effecting this check + */ + if ($config['debug_and_monitoring']['report_errors'] && $sentryDSN !== '--replace--this--' . 'during--release--process--' && !empty($sentryDSN)) { + // Per Sentry documentation, not setting this results in the SDK simply not sending any information. + $options['dsn'] = $sentryDSN; + } + + $options['server_name'] = INSTANCE_ID; + \Sentry\init($options); + } + + /** + * Captures an exception and sends it to Sentry, adding additional information that we'd find useful. + * + * @param \Exception|\Error $e + */ + public static function captureException(\Exception|\Error $e) + { + \Sentry\withScope(function (Scope $scope) use ($e): void { + $errorInfo = ErrorPage::getCodeInfo($e->getCode()); + $exceptionPath = $e->getFile(); + + // Tag the event with the exception's category. + $scope->setTag('exception.category', $errorInfo['category']); + + // If we can, tag the event with the module or library that threw the exception. + if (str_starts_with($exceptionPath, PATH_MODS)) { + $strippedPath = str_replace(PATH_MODS, '', $exceptionPath); + $level = 0; + $module = 'Unknown'; + + while ($level <= 10) { + if (dirname($strippedPath, ($level + 1)) === DIRECTORY_SEPARATOR) { + $module = trim(dirname($strippedPath, $level), DIRECTORY_SEPARATOR); + break; + } + $level++; + } + $scope->setTag('module.name', $module); + } else if (str_starts_with($exceptionPath, PATH_LIBRARY)) { + $scope->setTag('library.class', pathinfo($exceptionPath, PATHINFO_FILENAME)); + } + + // Finally tag the event with what is probably the webserver in use, then send the event to Sentry. + self::estimateWebServer($scope); + \Sentry\captureException($e); + }); + } + + /** + * Accepts a PHP error's number and returns what type of error it is. + */ + public static function getErrorType(int $number): string + { + switch ($number) { + case E_ERROR: + return 'Error'; + break; + case E_WARNING: + return 'Warning'; + break; + case E_PARSE: + return 'Parse error'; + break; + case E_NOTICE: + return 'Runtime notice'; + break; + case E_CORE_ERROR: + return 'Fatal PHP startup error'; + break; + case E_CORE_WARNING: + return 'PHP startup warning'; + break; + case E_COMPILE_ERROR: + return 'Zend compile error'; + break; + case E_COMPILE_WARNING: + return 'Zend compile warning'; + break; + case E_USER_ERROR: + return 'User-generated error'; + break; + case E_USER_WARNING: + return 'User-generated warning'; + break; + case E_USER_NOTICE: + return 'User-generated notice'; + break; + case E_STRICT: + return 'PHP Strict code checking'; + break; + case E_RECOVERABLE_ERROR: + return 'Recoverable error'; + break; + case E_DEPRECATED: + return 'PHP deprecation warning'; + break; + case E_USER_DEPRECATED: + return 'User-generated deprecation warning'; + break; + default: + return 'Unknown error'; + break; + } + } + + /** + * Returns the appropriate Sentry severity level for a given error type. + */ + public static function getSeverityLevel(string $type): Severity + { + if (stripos($type, 'fatal') !== false) { + return Severity::fatal(); + } + // We check for deprecation before warning because the message for them also includes 'warning' + if (stripos($type, 'deprecation') !== false) { + return Severity::info(); + } + if (stripos($type, 'warning') !== false) { + return Severity::warning(); + } + + // Default to error + return Severity::error(); + } + + /** + * Tries to guess what type of webserver is being used and tags the Sentry event with it. + */ + private static function estimateWebServer(Scope $scope): void + { + $serverSoftware = $_SERVER['SERVER_SOFTWARE'] ?? ''; + if (function_exists('apache_get_version') || (stripos(strtolower($serverSoftware), 'apache') !== false)) { + $scope->setTag('webserver.used', 'Apache'); + } else if (stripos(strtolower($serverSoftware), 'litespeed') !== false) { + $scope->setTag('webserver.used', 'Litespeed'); + } else if (stripos(strtolower($serverSoftware), 'nginx') !== false) { + $scope->setTag('webserver.used', 'NGINX'); + } + } +} diff --git a/src/library/FOSSBilling/Session.php b/src/library/FOSSBilling/Session.php index e4ca24969..1d2687e66 100644 --- a/src/library/FOSSBilling/Session.php +++ b/src/library/FOSSBilling/Session.php @@ -121,7 +121,7 @@ class Session implements \FOSSBilling\InjectionAwareInterface $sessionID = $_COOKIE['PHPSESSID']; $maxAge = time() - $this->di['config']['security']['session_lifespan']; - $fingerprint = new \FOSSBilling\Fingerprint; + $fingerprint = new Fingerprint; /** @var \RedBeanPHP\OODBBean $session */ $session = $this->di['db']->findOne('session', 'id = :id', [':id' => $sessionID]); @@ -150,7 +150,7 @@ class Session implements \FOSSBilling\InjectionAwareInterface // Fix for the installer which temporarily uses FS sessions before FOSSBilling is completely setup. if (!is_null($session)) { - $fingerprint = new \FOSSBilling\Fingerprint; + $fingerprint = new Fingerprint; $session->fingerprint = json_encode($fingerprint->fingerprint()); $this->di['db']->store($session); } diff --git a/src/library/FOSSBilling/Tools.php b/src/library/FOSSBilling/Tools.php index 5526e9159..b6c1c74e2 100644 --- a/src/library/FOSSBilling/Tools.php +++ b/src/library/FOSSBilling/Tools.php @@ -69,7 +69,7 @@ class Tools $class = 'Box_Mod_' . ucfirst($type) . '_Service'; $file = PATH_MODS . '/mod_' . $type . '/Service.php'; if (!file_exists($file)) { - throw new \Box_Exception('Service class :class was not found in :path', array(':class' => $class, ':path' => $file)); + throw new Exception('Service class :class was not found in :path', array(':class' => $class, ':path' => $file)); } require_once $file; return new $class(); @@ -246,7 +246,7 @@ class Tools $class = 'Model_' . ucfirst($type) . 'Table'; $file = PATH_LIBRARY . '/Model/' . $type . 'Table.php'; if (!file_exists($file)) { - throw new \Box_Exception('Service class :class was not found in :path', array(':class' => $class, ':path' => $file)); + throw new Exception('Service class :class was not found in :path', array(':class' => $class, ':path' => $file)); } require_once $file; return new $class(); @@ -277,7 +277,7 @@ class Tools if (!filter_var(idn_to_ascii($email), FILTER_VALIDATE_EMAIL)) { if ($throw) { $friendlyName = ucfirst(__trans('Email address')); - throw new \Box_Exception(':friendlyName: is invalid', [':friendlyName:' => $friendlyName]); + throw new Exception(':friendlyName: is invalid', [':friendlyName:' => $friendlyName]); } else { return false; } diff --git a/src/library/FOSSBilling/Update.php b/src/library/FOSSBilling/Update.php index 2fbd4a252..83e328eed 100644 --- a/src/library/FOSSBilling/Update.php +++ b/src/library/FOSSBilling/Update.php @@ -82,7 +82,7 @@ class Update implements InjectionAwareInterface * @param string $branch The branch to return the latest information for; * valid values are: 'preview' or 'release'. * - * @throws \Box_Exception if there is an error downloading the latest + * @throws Exception if there is an error downloading the latest * version information. * * @return array @@ -113,7 +113,7 @@ class Update implements InjectionAwareInterface $releaseInfo = $response->toArray(); } catch (TransportExceptionInterface | HttpExceptionInterface $e) { error_log($e->getMessage()); - throw new \Box_Exception('Failed to download the latest version information. Further details are available in the error log.'); + throw new Exception('Failed to download the latest version information. Further details are available in the error log.'); } return [ @@ -172,9 +172,9 @@ class Update implements InjectionAwareInterface /** * Perform system update. * - * @throws \Box_Exception if latest version already installed. - * @throws \Box_Exception if unable to download the update archive. - * @throws \Box_Exception if unable to extract the update archive. + * @throws InformationException if latest version already installed. + * @throws Exception if unable to download the update archive. + * @throws Exception if unable to extract the update archive. * * @return void */ @@ -182,7 +182,7 @@ class Update implements InjectionAwareInterface { $updateBranch = $this->getUpdateBranch(); if ($updateBranch !== 'preview' && !$this->isUpdateAvailable()) { - throw new \Box_Exception('You have latest version of FOSSBilling. You do not need to update.'); + throw new InformationException('You have latest version of FOSSBilling. You do not need to update.'); } error_log('Started FOSSBilling auto-update script'); @@ -204,7 +204,7 @@ class Update implements InjectionAwareInterface fclose($fileHandler); } catch (TransportExceptionInterface | HttpExceptionInterface $e) { error_log($e->getMessage()); - throw new \Box_Exception('Failed to download the update archive. Further details are available in the error log.'); + throw new Exception('Failed to download the update archive. Further details are available in the error log.'); } // @TODO - Validate downloaded file hash. @@ -217,7 +217,7 @@ class Update implements InjectionAwareInterface $zip->close(); } catch (ZipException $e) { error_log($e->getMessage()); - throw new \Box_Exception('Failed to extract file, please check file and folder permissions. Further details are available in the error log.'); + throw new Exception('Failed to extract file, please check file and folder permissions. Further details are available in the error log.'); } // Apply system patches and migrate configuration file. @@ -235,7 +235,7 @@ class Update implements InjectionAwareInterface $filesystem->mkdir(PATH_CACHE, 0777); } catch (IOException $e) { error_log($e->getMessage()); - throw new \Box_Exception("Unable to clear cache and/or remove install folder. Further details are available in the error log."); + throw new Exception("Unable to clear cache and/or remove install folder. Further details are available in the error log."); } // Log off the current user and destroy the session. diff --git a/src/library/FOSSBilling/UpdatePatcher.php b/src/library/FOSSBilling/UpdatePatcher.php index 699d7e650..e15e6bbb3 100644 --- a/src/library/FOSSBilling/UpdatePatcher.php +++ b/src/library/FOSSBilling/UpdatePatcher.php @@ -14,6 +14,7 @@ namespace FOSSBilling; use Symfony\Component\Filesystem\Exception\FileNotFoundException; use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Filesystem; +use Ramsey\Uuid\Uuid; class UpdatePatcher implements InjectionAwareInterface { @@ -45,18 +46,17 @@ class UpdatePatcher implements InjectionAwareInterface { $filesystem = new Filesystem(); - $configPath = PATH_ROOT . '/config.php'; - $currentConfig = include $configPath; + $currentConfig = include PATH_CONFIG; if (!is_array($currentConfig)) { - throw new \Box_Exception('Unable to load existing configuration'); + throw new Exception('Unable to load existing configuration'); } // Create backup of current configuration. try { - $filesystem->copy($configPath, substr($configPath, 0, -4) . '.old.php'); + $filesystem->copy(PATH_CONFIG, substr(PATH_CONFIG, 0, -4) . '.old.php'); } catch (FileNotFoundException | IOException) { - throw new \Box_Exception('Unable to create backup of configuration file'); + throw new Exception('Unable to create backup of configuration file'); } $newConfig = $currentConfig; @@ -80,9 +80,15 @@ class UpdatePatcher implements InjectionAwareInterface $newConfig['api']['rate_limit_login'] ??= 20; $newConfig['api']['CSRFPrevention'] ??= true; $newConfig['api']['rate_limit_whitelist'] ??= []; + $newConfig['debug_and_monitoring']['debug'] ??= $newConfig['debug'] ?? false; + $newConfig['debug_and_monitoring']['log_stacktrace'] ??= $newConfig['log_stacktrace'] ?? true; + $newConfig['debug_and_monitoring']['stacktrace_length'] ??= $newConfig['stacktrace_length'] ?? 25; + $newConfig['debug_and_monitoring']['report_errors'] ??= false; + $newConfig['info']['instance_id'] ??= Uuid::uuid4()->toString(); + $newConfig['info']['salt'] ??= $newConfig['salt']; // Remove depreciated config keys/subkeys. - $depreciatedConfigKeys = ['guzzle', 'locale', 'locale_date_format', 'locale_time_format', 'timezone', 'sef_urls']; + $depreciatedConfigKeys = ['guzzle', 'locale', 'locale_date_format', 'locale_time_format', 'timezone', 'sef_urls', 'salt']; $depreciatedConfigSubkeys = [ 'security' => 'cookie_lifespan' ]; @@ -96,9 +102,9 @@ class UpdatePatcher implements InjectionAwareInterface // Write updated configuration file. try { - $filesystem->dumpFile($configPath, $output); + $filesystem->dumpFile(PATH_CONFIG, $output); } catch (IOException) { - throw new \Box_Exception('Error when writing updated configuration file.'); + throw new Exception('Error when writing updated configuration file.'); } } @@ -156,8 +162,10 @@ class UpdatePatcher implements InjectionAwareInterface $statement = $this->di['pdo']->prepare($sql); try { $statement->execute(); - } catch (\Box_Exception $e) { + } catch (\Exception $e) { + // Log the error and then throw a user-friendly exception to prevent further patches from being applied. error_log($e->getMessage()); + throw new Exception('There was an error while applying database patches. Please check the error log for information on the error, correct it, and then perform the backup patching method to complete the update.'); } } @@ -302,6 +310,6 @@ class UpdatePatcher implements InjectionAwareInterface ]; ksort($patches, SORT_NATURAL); - return array_filter($patches, fn($key) => $key > $patchLevel, ARRAY_FILTER_USE_KEY); + return array_filter($patches, fn ($key) => $key > $patchLevel, ARRAY_FILTER_USE_KEY); } } diff --git a/src/library/FOSSBilling/Validate.php b/src/library/FOSSBilling/Validate.php index e7de3dcb0..de7100940 100644 --- a/src/library/FOSSBilling/Validate.php +++ b/src/library/FOSSBilling/Validate.php @@ -48,23 +48,23 @@ class Validate public function isPasswordStrong($pwd) : bool { if( strlen($pwd) < 8 ) { - throw new \Box_Exception("Minimum password length is 8 characters."); + throw new InformationException("Minimum password length is 8 characters."); } if( strlen($pwd) > 256 ) { - throw new \Box_Exception("Maximum password length is 256 characters."); + throw new InformationException("Maximum password length is 256 characters."); } if( !preg_match("#[0-9]+#", $pwd) ) { - throw new \Box_Exception("Password must include at least one number."); + throw new InformationException("Password must include at least one number."); } if( !preg_match("#[a-z]+#", $pwd) ) { - throw new \Box_Exception("Password must include at least one lowercase letter."); + throw new InformationException("Password must include at least one lowercase letter."); } if( !preg_match("#[A-Z]+#", $pwd) ) { - throw new \Box_Exception("Password must include at least one uppercase letter."); + throw new InformationException("Password must include at least one uppercase letter."); } /* @@ -80,22 +80,23 @@ class Validate * @param array $data - Array to search for keys * @param array $variables - Array of variables for message placeholders (:placeholder) * @param integer $code - Exception code - * @throws \Box_Exception + * + * @throws InformationException */ public function checkRequiredParamsForArray(array $required, array $data, array $variables = NULL, $code = 0) { foreach ($required as $key => $msg) { if(!isset($data[$key])){ - throw new \Box_Exception($msg, $variables, $code); + throw new InformationException($msg, $variables, $code); } if (is_string($data[$key]) && strlen(trim($data[$key])) === 0){ - throw new \Box_Exception($msg, $variables, $code); + throw new InformationException($msg, $variables, $code); } if (!is_numeric($data[$key]) && empty($data[$key])){ - throw new \Box_Exception($msg, $variables, $code); + throw new InformationException($msg, $variables, $code); } } } @@ -104,7 +105,7 @@ class Validate { if (strlen(trim($birthday)) > 0 && strtotime($birthday) === false) { $friendlyName = ucfirst(__trans('Birthdate')); - throw new \Box_Exception(':friendlyName: is invalid', [':friendlyName:' => $friendlyName]); + throw new Exception(':friendlyName: is invalid', [':friendlyName:' => $friendlyName]); } return true; } diff --git a/src/library/FOSSBilling/i18n.php b/src/library/FOSSBilling/i18n.php index 6705dd68d..fad8c4339 100644 --- a/src/library/FOSSBilling/i18n.php +++ b/src/library/FOSSBilling/i18n.php @@ -126,13 +126,13 @@ class i18n * * @return bool To indicate if it was successful, * - * @throws \Box_Exception + * @throws InformationException */ public static function toggleLocale(string $locale): bool { $basePath = PATH_LANGS . DIRECTORY_SEPARATOR . $locale; if (!is_dir($basePath)) { - throw new \Box_Exception('Unable to enable / disable the locale as it is not present in the locale folder.'); + throw new InformationException('Unable to enable / disable the locale as it is not present in the locale folder.'); } $disablePath = $basePath . DIRECTORY_SEPARATOR . '.disabled'; diff --git a/src/library/Model/ProductDomainTable.php b/src/library/Model/ProductDomainTable.php index 09e081752..a989bde44 100644 --- a/src/library/Model/ProductDomainTable.php +++ b/src/library/Model/ProductDomainTable.php @@ -214,7 +214,7 @@ class Model_ProductDomainTable extends Model_ProductTable $tld = ''; if (!isset($config['action'])) { - throw new \Box_Exception('Could not determine domain price. Domain action is missing', null, 498); + throw new \FOSSBilling\Exception('Could not determine domain price. Domain action is missing', null, 498); } if ($config['action'] == 'owndomain') { @@ -231,7 +231,7 @@ class Model_ProductDomainTable extends Model_ProductTable $tld = $rtable->findOneByTld($tld); if (!$tld instanceof Model_Tld) { - throw new \Box_Exception('Unknown TLD. Could not determine registration price'); + throw new \FOSSBilling\Exception('Unknown TLD. Could not determine registration price'); } if ($config['action'] == 'register') { @@ -252,6 +252,6 @@ class Model_ProductDomainTable extends Model_ProductTable public function rm(Model_Product $product) { - throw new \Box_Exception('Domain product can not be removed.'); + throw new \FOSSBilling\Exception('Domain product can not be removed.'); } } diff --git a/src/library/Model/ProductTable.php b/src/library/Model/ProductTable.php index ddefdc90f..9938ce8ae 100644 --- a/src/library/Model/ProductTable.php +++ b/src/library/Model/ProductTable.php @@ -58,7 +58,7 @@ class Model_ProductTable implements \FOSSBilling\InjectionAwareInterface '3Y' => 'tria' }; } catch (\UnhandledMatchError) { - throw new Box_Exception('Unknown period selected ' . $code); + throw new FOSSBilling\Exception('Unknown period selected ' . $code); } } @@ -70,7 +70,7 @@ class Model_ProductTable implements \FOSSBilling\InjectionAwareInterface return $service->toProductPaymentApiArray($productPayment); } - throw new \Box_Exception('Product pricing could not be determined. ' . static::class); + throw new \FOSSBilling\Exception('Product pricing could not be determined. ' . static::class); } /** @@ -102,7 +102,7 @@ class Model_ProductTable implements \FOSSBilling\InjectionAwareInterface return $price; } - throw new \Box_Exception('Unknown period selected for setup price'); + throw new \FOSSBilling\Exception('Unknown period selected for setup price'); } /** @@ -126,7 +126,7 @@ class Model_ProductTable implements \FOSSBilling\InjectionAwareInterface if ($pp->type == Model_ProductPayment::RECURRENT) { if (!isset($config['period'])) { - throw new \Box_Exception('Product :id payment type is recurrent, but period was not selected', array(':id' => $product->id)); + throw new \FOSSBilling\Exception('Product :id payment type is recurrent, but period was not selected', array(':id' => $product->id)); } $period = new Box_Period($config['period']); @@ -138,6 +138,6 @@ class Model_ProductTable implements \FOSSBilling\InjectionAwareInterface return $price; } - throw new \Box_Exception('Unknown Period selected for price'); + throw new \FOSSBilling\Exception('Unknown Period selected for price'); } } diff --git a/src/library/Payment/Adapter/PayPalEmail.php b/src/library/Payment/Adapter/PayPalEmail.php index 1e0d7a828..a970df9b7 100644 --- a/src/library/Payment/Adapter/PayPalEmail.php +++ b/src/library/Payment/Adapter/PayPalEmail.php @@ -28,7 +28,7 @@ class Payment_Adapter_PayPalEmail extends Payment_AdapterAbstract implements \FO public function __construct(private $config) { if (!isset($this->config['email'])) { - throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'PayPal', ':missing' => 'PayPal Email address']); + throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'PayPal', ':missing' => 'PayPal Email address'], 4001); } } diff --git a/src/library/Payment/Adapter/Stripe.php b/src/library/Payment/Adapter/Stripe.php index af876fc3f..f8727ce5e 100644 --- a/src/library/Payment/Adapter/Stripe.php +++ b/src/library/Payment/Adapter/Stripe.php @@ -30,19 +30,19 @@ class Payment_Adapter_Stripe implements \FOSSBilling\InjectionAwareInterface { if ($this->config['test_mode']) { if (!isset($this->config['test_api_key'])) { - throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'Stripe', ':missing' => 'Test API Key']); + throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'Stripe', ':missing' => 'Test API Key'], 4001); } if (!isset($this->config['test_pub_key'])) { - throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'Stripe', ':missing' => 'Test publishable key']); + throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'Stripe', ':missing' => 'Test publishable key'], 4001); } $this->stripe = new StripeClient($this->config['test_api_key']); } else { if (!isset($this->config['api_key'])) { - throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'Stripe', ':missing' => 'API key']); + throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'Stripe', ':missing' => 'API key'], 4001); } if (!isset($this->config['pub_key'])) { - throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'Stripe', ':missing' => 'Publishable key']); + throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'Stripe', ':missing' => 'Publishable key'], 4001); } $this->stripe = new StripeClient($this->config['api_key']); @@ -125,7 +125,7 @@ class Payment_Adapter_Stripe implements \FOSSBilling\InjectionAwareInterface $tx->updated_at = date('Y-m-d H:i:s'); $this->di['db']->store($tx); - if ($this->di['config']['debug']) { + if (BB_DEBUG) { error_log(json_encode($e->getJsonBody())); } throw new Exception($tx->error); @@ -180,7 +180,7 @@ class Payment_Adapter_Stripe implements \FOSSBilling\InjectionAwareInterface } } catch (\Stripe\Exception\CardException | \Stripe\Exception\InvalidRequestException | \Stripe\Exception\AuthenticationException | \Stripe\Exception\ApiConnectionException | \Stripe\Exception\ApiErrorException $e) { $this->logError($e, $tx); - throw new \Box_Exception("There was an error when processing the transaction"); + throw new \FOSSBilling\Exception("There was an error when processing the transaction"); } $paymentStatus = match ($charge->status) { diff --git a/src/library/Payment/Exception.php b/src/library/Payment/Exception.php index a864bd232..3b68f4381 100644 --- a/src/library/Payment/Exception.php +++ b/src/library/Payment/Exception.php @@ -8,10 +8,10 @@ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache-2.0 */ -class Payment_Exception extends Box_Exception +class Payment_Exception extends FOSSBilling\Exception { /** - * Creates a new translated exception, using the Box_Exception class. + * Creates a new translated exception, using the FOSSBilling\Exception class. * * @param string $message error message * @param array|null $variables translation variables diff --git a/src/library/Registrar/Adapter/Email.php b/src/library/Registrar/Adapter/Email.php index 11b8a73ea..a357b1de6 100644 --- a/src/library/Registrar/Adapter/Email.php +++ b/src/library/Registrar/Adapter/Email.php @@ -20,7 +20,7 @@ class Registrar_Adapter_Email extends Registrar_AdapterAbstract $this->config['email'] = $options['email']; unset($options['email']); } else { - throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Email', ':missing' => 'email']); + throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Email', ':missing' => 'email'], 3001); } if(isset($options['use_whois'])) { diff --git a/src/library/Registrar/Adapter/Internetbs.php b/src/library/Registrar/Adapter/Internetbs.php index 3290d12e8..36dd6be40 100644 --- a/src/library/Registrar/Adapter/Internetbs.php +++ b/src/library/Registrar/Adapter/Internetbs.php @@ -15,14 +15,14 @@ class Registrar_Adapter_Internetbs extends Registrar_AdapterAbstract $this->config['apikey'] = $options['apikey']; unset($options['apikey']); } else { - throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Internetbs', ':missing' => 'Internetbs API key']); + throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Internetbs', ':missing' => 'Internetbs API key'], 3001); } if(isset($options['password']) && !empty($options['password'])) { $this->config['password'] = $options['password']; unset($options['password']); } else { - throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Internetbs', ':missing' => 'Internetbs API password']); + throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Internetbs', ':missing' => 'Internetbs API password'], 3001); } } diff --git a/src/library/Registrar/Adapter/Namecheap.php b/src/library/Registrar/Adapter/Namecheap.php index 9abb5f228..a2776e7e9 100644 --- a/src/library/Registrar/Adapter/Namecheap.php +++ b/src/library/Registrar/Adapter/Namecheap.php @@ -26,13 +26,13 @@ class Registrar_Adapter_Namecheap extends Registrar_AdapterAbstract if (!empty($options['api-key'])) { $this->config['api-key'] = $options['api-key']; } else { - throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Namecheap', ':missing' => 'API Key']); + throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Namecheap', ':missing' => 'API Key'], 3001); } if (!empty($options['username'])) { $this->config['username'] = $options['username']; } else { - throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Namecheap', ':missing' => 'Username']); + throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Namecheap', ':missing' => 'Username'], 3001); } if (empty($options['api-user-id'])) { @@ -44,7 +44,7 @@ class Registrar_Adapter_Namecheap extends Registrar_AdapterAbstract if (!empty($options['ip'])) { $this->config['ip'] = $options['ip']; } else { - throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Namecheap', ':missing' => 'server IP address']); + throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Namecheap', ':missing' => 'server IP address'], 3001); } } diff --git a/src/library/Registrar/Adapter/Netearthone.php b/src/library/Registrar/Adapter/Netearthone.php index cb6a1836d..403ff9905 100644 --- a/src/library/Registrar/Adapter/Netearthone.php +++ b/src/library/Registrar/Adapter/Netearthone.php @@ -8,14 +8,14 @@ class Registrar_Adapter_Netearthone extends Registrar_Adapter_Resellerclub $this->config['userid'] = $options['userid']; unset($options['userid']); } else { - throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'NetEarthOne', ':missing' => 'NetEarthOne Reseller ID']); + throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'NetEarthOne', ':missing' => 'NetEarthOne Reseller ID'], 3001); } if(isset($options['api-key']) && !empty($options['api-key'])) { $this->config['api-key'] = $options['api-key']; unset($options['api-key']); } else { - throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'NetEarthOne', ':missing' => 'NetEarthOne API Key']); + throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'NetEarthOne', ':missing' => 'NetEarthOne API Key'], 3001); } } diff --git a/src/library/Registrar/Adapter/Resellbiz.php b/src/library/Registrar/Adapter/Resellbiz.php index d56110f11..22afa4287 100644 --- a/src/library/Registrar/Adapter/Resellbiz.php +++ b/src/library/Registrar/Adapter/Resellbiz.php @@ -8,14 +8,14 @@ class Registrar_Adapter_Resellbiz extends Registrar_Adapter_Resellerclub $this->config['userid'] = $options['userid']; unset($options['userid']); } else { - throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Resell.biz', ':missing' => 'Resell.biz Reseller ID']); + throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Resell.biz', ':missing' => 'Resell.biz Reseller ID'], 3001); } if(isset($options['api-key']) && !empty($options['api-key'])) { $this->config['api-key'] = $options['api-key']; unset($options['api-key']); } else { - throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Resell.biz', ':missing' => 'Resell.biz API Key']); + throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Resell.biz', ':missing' => 'Resell.biz API Key'], 3001); } } diff --git a/src/library/Registrar/Adapter/Resellerclub.php b/src/library/Registrar/Adapter/Resellerclub.php index d04c1c12c..05cb5c350 100644 --- a/src/library/Registrar/Adapter/Resellerclub.php +++ b/src/library/Registrar/Adapter/Resellerclub.php @@ -37,14 +37,14 @@ class Registrar_Adapter_Resellerclub extends Registrar_AdapterAbstract $this->config['userid'] = $options['userid']; unset($options['userid']); } else { - throw new Registrar_Exception('Domain registrar "ResellerClub" is not configured properly. Please update configuration parameter "ResellerClub Reseller ID" at "Configuration -> Domain registration".'); + throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'ResellerClub', ':missing' => 'ResellerClub Reseller ID'], 3001); } if(isset($options['api-key']) && !empty($options['api-key'])) { $this->config['api-key'] = $options['api-key']; unset($options['api-key']); } else { - throw new Registrar_Exception('Domain registrar "ResellerClub" is not configured properly. Please update configuration parameter "ResellerClub API Key" at "Configuration -> Domain registration".'); + throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'ResellerClub', ':missing' => 'ResellerClub API Key'], 3001); } } diff --git a/src/library/Registrar/Adapter/Resellerid.php b/src/library/Registrar/Adapter/Resellerid.php index 52209f9ae..d7e17a14f 100644 --- a/src/library/Registrar/Adapter/Resellerid.php +++ b/src/library/Registrar/Adapter/Resellerid.php @@ -8,14 +8,14 @@ class Registrar_Adapter_Resellerid extends Registrar_Adapter_Resellerclub $this->config['userid'] = $options['userid']; unset($options['userid']); } else { - throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'ResellerID', ':missing' => 'ResellerID Reseller ID']); + throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'ResellerID', ':missing' => 'ResellerID Reseller ID'], 3001); } if(isset($options['api-key']) && !empty($options['api-key'])) { $this->config['api-key'] = $options['api-key']; unset($options['api-key']); } else { - throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'ResellerID', ':missing' => 'ResellerID API Key']); + throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'ResellerID', ':missing' => 'ResellerID API Key'], 3001); } } diff --git a/src/library/Registrar/Exception.php b/src/library/Registrar/Exception.php index 472ed33d5..c703d8f19 100644 --- a/src/library/Registrar/Exception.php +++ b/src/library/Registrar/Exception.php @@ -8,10 +8,10 @@ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache-2.0 */ -class Registrar_Exception extends Box_Exception +class Registrar_Exception extends FOSSBilling\Exception { /** - * Creates a new translated exception, using the Box_Exception class. + * Creates a new translated exception, using the FOSSBilling\Exception class. * * @param string $message error message * @param array|null $variables translation variables diff --git a/src/library/Server/Exception.php b/src/library/Server/Exception.php index e26a99ee7..9de04be75 100644 --- a/src/library/Server/Exception.php +++ b/src/library/Server/Exception.php @@ -8,10 +8,10 @@ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache-2.0 */ -class Server_Exception extends Box_Exception +class Server_Exception extends FOSSBilling\Exception { /** - * Creates a new translated exception, using the Box_Exception class. + * Creates a new translated exception, using the FOSSBilling\Exception class. * * @param string $message error message * @param array|null $variables translation variables diff --git a/src/library/Server/Manager/CWP.php b/src/library/Server/Manager/CWP.php index a16b00c2d..e0c797854 100644 --- a/src/library/Server/Manager/CWP.php +++ b/src/library/Server/Manager/CWP.php @@ -17,15 +17,15 @@ class Server_Manager_CWP extends Server_Manager public function init() { if (empty($this->_config['ip'])) { - throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'CWP', ':missing' => 'IP address']); + throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'CWP', ':missing' => 'IP address'], 2001); } if (empty($this->_config['host'])) { - throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'CWP', ':missing' => 'Hostname']); + throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'CWP', ':missing' => 'Hostname'], 2001); } if (empty($this->_config['accesshash'])) { - throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'CWP', ':missing' => 'API Key / Access Hash']); + throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'CWP', ':missing' => 'API Key / Access Hash'], 2001); } else { $this->_config['accesshash'] = trim($this->_config['accesshash']); } diff --git a/src/library/Server/Manager/Directadmin.php b/src/library/Server/Manager/Directadmin.php index 64d961625..614cf4bba 100644 --- a/src/library/Server/Manager/Directadmin.php +++ b/src/library/Server/Manager/Directadmin.php @@ -13,15 +13,15 @@ class Server_Manager_Directadmin extends Server_Manager public function init() { if(empty($this->_config['host'])) { - throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'DirectAdmin', ':missing' => 'hostname']); + throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'DirectAdmin', ':missing' => 'hostname'], 2001); } if(empty($this->_config['username'])) { - throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'DirectAdmin', ':missing' => 'username']); + throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'DirectAdmin', ':missing' => 'username'], 2001); } if(empty($this->_config['password'])) { - throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'DirectAdmin', ':missing' => 'password']); + throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'DirectAdmin', ':missing' => 'password'], 2001); } } diff --git a/src/library/Server/Manager/Whm.php b/src/library/Server/Manager/Whm.php index e0940a540..1f1e78dc2 100644 --- a/src/library/Server/Manager/Whm.php +++ b/src/library/Server/Manager/Whm.php @@ -19,15 +19,15 @@ class Server_Manager_Whm extends Server_Manager public function init() { if(empty($this->_config['host'])) { - throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'cPanel WHM', ':missing' => 'hostname']); + throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'cPanel WHM', ':missing' => 'hostname'], 2001); } if(empty($this->_config['username'])) { - throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'cPanel WHM', ':missing' => 'username']); + throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'cPanel WHM', ':missing' => 'username'], 2001); } if(empty($this->_config['password']) && empty($this->_config['accesshash'])) { - throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'cPanel WHM', ':missing' => 'authentication credentials']); + throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'cPanel WHM', ':missing' => 'authentication credentials'], 2001); } // If port not set, use WHM default. diff --git a/src/load.php b/src/load.php index 51bafc1c5..69d891e84 100644 --- a/src/load.php +++ b/src/load.php @@ -1,4 +1,5 @@ exists(PATH_CONFIG) && $filesystem->exists('install/install.php') && Environment::isProduction()) { // Throw exception only if debug mode is NOT enabled. $config = require PATH_CONFIG; - if (!$config['debug']) { + if (!$config['debug_and_monitoring']['debug']) { throw new Exception('For security reasons, you have to delete the install directory before you can use FOSSBilling.', 2); } } @@ -135,10 +136,24 @@ function checkWebServer() */ function errorHandler(int $number, string $message, string $file, int $line) { + // Just some housekeeping to ensure a few things we rely on are loaded. + if (!class_exists('\FOSSBilling\ErrorPage')) { + require_once PATH_LIBRARY . DIRECTORY_SEPARATOR . 'FOSSBilling' . DIRECTORY_SEPARATOR . 'ErrorPage.php'; + } + + if (!class_exists('\FOSSBilling\SentryHelper')) { + require_once PATH_LIBRARY . DIRECTORY_SEPARATOR . 'FOSSBilling' . DIRECTORY_SEPARATOR . 'SentryHelper.php'; + } + + // Now we can handle the error appropriately. if ($number === E_RECOVERABLE_ERROR) { exceptionHandler(new ErrorException($message, $number, 0, $file, $line)); } else { - error_log($number . ' ' . $message . ' ' . $file . ' ' . $line); + $errorType = FOSSBilling\SentryHelper::getErrorType($number); + $completedMessage = ($errorType . " ($number): " . $message . ' in ' . $file . ' on line ' . $line); + + \Sentry\captureMessage($completedMessage, FOSSBilling\SentryHelper::getSeverityLevel($errorType)); + error_log($completedMessage); } return false; @@ -149,13 +164,17 @@ function errorHandler(int $number, string $message, string $file, int $line) */ function exceptionHandler($e) { - $message = htmlspecialchars($e->getMessage()); - if (getenv('APP_ENV') === 'test') { - echo $message . PHP_EOL; + // Let Sentry capture the exception and then send it + \FOSSBilling\SentryHelper::captureException($e); + if (getenv('APP_ENV') === 'test') { + echo $e->getMessage() . PHP_EOL; return; + } else { + error_log($e->getMessage()); } - error_log($message); + + $message = htmlspecialchars($e->getMessage()); if (defined('BB_MODE_API')) { $code = $e->getCode() ?: 9998; @@ -175,7 +194,8 @@ function exceptionHandler($e) $prettyPage->setPageTitle('An error ocurred'); $prettyPage->addDataTable('FOSSBilling environment', [ 'PHP Version' => PHP_VERSION, - 'Error code' => $e->getCode(), + 'Error code' => $e->getCode(), + 'Instance ID' => INSTANCE_ID ?? 'Unknown', ]); $whoops->pushHandler($prettyPage); $whoops->allowQuit(false); @@ -183,7 +203,6 @@ function exceptionHandler($e) echo $whoops->handleException($e); } else { - include PATH_LIBRARY . DIRECTORY_SEPARATOR . 'FOSSBilling' . DIRECTORY_SEPARATOR . 'ErrorPage.php'; $errorPage = new \FOSSBilling\ErrorPage(); $errorPage->generatePage($e->getCode(), $message); } @@ -223,19 +242,27 @@ $config = require PATH_CONFIG; // Config loaded - set globals and relevant settings. date_default_timezone_set($config['i18n']['timezone'] ?? 'UTC'); -define('BB_DEBUG', $config['debug']); +define('BB_DEBUG', (bool)$config['debug_and_monitoring']['debug']); define('BB_URL', $config['url']); define('PATH_CACHE', $config['path_data'] . DIRECTORY_SEPARATOR . 'cache'); define('PATH_LOG', $config['path_data'] . DIRECTORY_SEPARATOR . 'log'); define('BB_SSL', str_starts_with($config['url'], 'https')); define('ADMIN_PREFIX', $config['admin_area_prefix']); define('BB_URL_API', $config['url'] . 'api/'); +if(!empty($config['info']['instance_id'])){ + define('INSTANCE_ID', $config['info']['instance_id']); +} else { + define('INSTANCE_ID', 'Unknown'); +} // Initial setup and checks passed, now we setup our custom autoloader. include PATH_LIBRARY . DIRECTORY_SEPARATOR . 'FOSSBilling' . DIRECTORY_SEPARATOR . 'Autoloader.php'; $loader = new FOSSBilling\AutoLoader(); $loader->register(); +// Now that the config file is loaded, we can enable Sentry +\FOSSBilling\SentryHelper::registerSentry($config); + // Verify the installer was removed. checkInstaller(); @@ -246,12 +273,14 @@ checkSSL(); ini_set('log_errors', '1'); ini_set('html_errors', false); ini_set('error_log', PATH_LOG . DIRECTORY_SEPARATOR . 'php_error.log'); -if ($config['debug']) { - error_reporting(E_ALL); + +// We disable PHP's error reporting as our own error handler will log it and send it to Sentry. +error_reporting(0); + +if (BB_DEBUG) { ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); } else { - error_reporting(E_RECOVERABLE_ERROR); ini_set('display_errors', '0'); ini_set('display_startup_errors', '0'); } diff --git a/src/modules/Api/Controller/Client.php b/src/modules/Api/Controller/Client.php index 1b8f16e06..2c178b769 100644 --- a/src/modules/Api/Controller/Client.php +++ b/src/modules/Api/Controller/Client.php @@ -45,7 +45,7 @@ class Client implements InjectionAwareInterface public function show_error(\Box_App $app, $page) { - $exc = new \Box_Exception('Unknown API call :call', [':call' => $page], 879); + $exc = new \FOSSBilling\Exception('Unknown API call :call', [':call' => $page], 879); return $this->renderJson(null, $exc); } @@ -80,6 +80,8 @@ class Client implements InjectionAwareInterface try { $this->_apiCall($role, $call, $p); } catch (\Exception $exc) { + // Let Sentry capture the exception and then send it + \FOSSBilling\SentryHelper::captureException($exc); $this->renderJson(null, $exc); } } @@ -125,7 +127,7 @@ class Client implements InjectionAwareInterface $url = strtolower(BB_URL); $referer = isset($_SERVER['HTTP_REFERER']) ? strtolower($_SERVER['HTTP_REFERER']) : null; if (!$referer || !str_starts_with($referer, $url)) { - throw new \Box_Exception('Invalid request. Make sure request origin is :from', [':from' => BB_URL], 1004); + throw new \FOSSBilling\Exception('Invalid request. Make sure request origin is :from', [':from' => BB_URL], 1004); } } @@ -136,7 +138,7 @@ class Client implements InjectionAwareInterface { $ips = $this->_api_config['allowed_ips']; if (!empty($ips) && !in_array($this->_getIp(), $ips)) { - throw new \Box_Exception('Unauthorized IP', null, 1002); + throw new \FOSSBilling\Exception('Unauthorized IP', null, 1002); } return true; @@ -190,15 +192,15 @@ class Client implements InjectionAwareInterface } if (!isset($_SERVER['PHP_AUTH_USER'])) { - throw new \Box_Exception('Authentication Failed', null, 201); + throw new \FOSSBilling\Exception('Authentication Failed', null, 201); } if (!isset($_SERVER['PHP_AUTH_PW'])) { - throw new \Box_Exception('Authentication Failed', null, 202); + throw new \FOSSBilling\Exception('Authentication Failed', null, 202); } if (empty($_SERVER['PHP_AUTH_PW'])) { - throw new \Box_Exception('Authentication Failed', null, 206); + throw new \FOSSBilling\Exception('Authentication Failed', null, 206); } return [$_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']]; @@ -212,7 +214,7 @@ class Client implements InjectionAwareInterface case 'client': $model = $this->di['db']->findOne('Client', 'api_token = ?', [$password]); if (!$model instanceof \Model_Client) { - throw new \Box_Exception('Authentication Failed', null, 204); + throw new \FOSSBilling\Exception('Authentication Failed', null, 204); } $this->di['session']->set('client_id', $model->id); @@ -221,7 +223,7 @@ class Client implements InjectionAwareInterface case 'admin': $model = $this->di['db']->findOne('Admin', 'api_token = ?', [$password]); if (!$model instanceof \Model_Admin) { - throw new \Box_Exception('Authentication Failed', null, 205); + throw new \FOSSBilling\Exception('Authentication Failed', null, 205); } $sessionAdminArray = [ 'id' => $model->id, @@ -235,20 +237,20 @@ class Client implements InjectionAwareInterface case 'guest': // do not allow at the moment default: - throw new \Box_Exception('Authentication Failed', null, 203); + throw new \FOSSBilling\Exception('Authentication Failed', null, 203); } } /** * @param string $role * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ private function isRoleAllowed($role) { $allowed = ['guest', 'client', 'admin']; if (!in_array($role, $allowed)) { - new \Box_Exception('Unknown API call :call', [':call' => ''], 701); + new \FOSSBilling\Exception('Unknown API call :call', [':call' => ''], 701); } return true; @@ -296,7 +298,7 @@ class Client implements InjectionAwareInterface /** * Checks if the CSRF token provided is valid. * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function _checkCSRFToken() { @@ -327,7 +329,7 @@ class Client implements InjectionAwareInterface } if (!is_null($expectedToken) && $expectedToken !== $token) { - throw new \Box_Exception('CSRF token invalid', null, 403); + throw new \FOSSBilling\Exception('CSRF token invalid', null, 403); } } } diff --git a/src/modules/Cart/Api/Guest.php b/src/modules/Cart/Api/Guest.php index af0936c13..8b0f929df 100644 --- a/src/modules/Cart/Api/Guest.php +++ b/src/modules/Cart/Api/Guest.php @@ -54,7 +54,7 @@ class Guest extends \Api_Abstract $currencyService = $this->di['mod_service']('currency'); $currency = $currencyService->getByCode($data['currency']); if (!$currency instanceof \Model_Currency) { - throw new \Box_Exception('Currency not found'); + throw new \FOSSBilling\Exception('Currency not found'); } $cart = $this->getService()->getSessionCart(); @@ -93,15 +93,15 @@ class Guest extends \Api_Abstract $promo = $this->getService()->findActivePromoByCode($data['promocode']); if (!$promo instanceof \Model_Promo) { - throw new \Box_Exception('Promo code is expired or does not exist'); + throw new \FOSSBilling\InformationException('Promo code is expired or does not exist'); } if (!$this->getService()->isPromoAvailableForClientGroup($promo)) { - throw new \Box_Exception('Promo can not be applied to your account'); + throw new \FOSSBilling\InformationException('Promo can not be applied to your account'); } if (!$this->getService()->promoCanBeApplied($promo)) { - throw new \Box_Exception('Promo code is expired or does not exist'); + throw new \FOSSBilling\InformationException('Promo code is expired or does not exist'); } $cart = $this->getService()->getSessionCart(); @@ -158,7 +158,7 @@ class Guest extends \Api_Abstract $product = $this->di['db']->getExistingModelById('Product', $data['id'], 'Product not found'); if ($product->is_addon) { - throw new \Box_Exception('Addon products cannot be added separately.'); + throw new \FOSSBilling\InformationException('Addon products cannot be added separately.'); } if (is_array($data['addons'] ?? '')) { @@ -172,7 +172,7 @@ class Guest extends \Api_Abstract $addonModel = $this->di['db']->getExistingModelById('Product', $addon, 'Addon not found'); if ($addonModel->status !== 'enabled' || !in_array($addon, $validAddons)) { - throw new \Box_Exception('One or more of your selected addons are invalid for the associated product.'); + throw new \FOSSBilling\InformationException('One or more of your selected addons are invalid for the associated product.'); } } } diff --git a/src/modules/Cart/Service.php b/src/modules/Cart/Service.php index b1dd64361..5cc107deb 100644 --- a/src/modules/Cart/Service.php +++ b/src/modules/Cart/Service.php @@ -81,14 +81,14 @@ class Service implements InjectionAwareInterface $this->di['validator']->checkRequiredParamsForArray($required, $data); if (!$this->isPeriodEnabledForProduct($product, $data['period'])) { - throw new \Box_Exception('Selected billing period is invalid'); + throw new \FOSSBilling\InformationException('Selected billing period is invalid'); } } $qty = $data['quantity'] ?? 1; // check stock if (!$this->isStockAvailable($product, $qty)) { - throw new \Box_Exception('This item is currently out of stock'); + throw new \FOSSBilling\InformationException('This item is currently out of stock'); } $addons = $data['addons'] ?? []; @@ -121,7 +121,7 @@ class Service implements InjectionAwareInterface $this->di['validator']->checkRequiredParamsForArray($required, $ac); if (!$this->isPeriodEnabledForProduct($addon, $ac['period'])) { - throw new \Box_Exception('Selected billing period is invalid for the selected addon'); + throw new \FOSSBilling\InformationException('Selected billing period is invalid for the selected addon'); } } $ac['parent_id'] = $product->id; @@ -215,7 +215,7 @@ class Service implements InjectionAwareInterface $cartProduct = $this->di['db']->findOne('CartProduct', 'id = :id AND cart_id = :cart_id', $bindings); if (!$cartProduct instanceof \Model_CartProduct) { - throw new \Box_Exception('Product not found'); + throw new \FOSSBilling\Exception('Product not found'); } if ($removeAddons) { @@ -277,7 +277,7 @@ class Service implements InjectionAwareInterface } if ($this->isEmptyCart($cart)) { - throw new \Box_Exception('Add products to cart before applying promo code'); + throw new \FOSSBilling\InformationException('Add products to cart before applying promo code'); } $cart->promo_id = $promo->id; @@ -422,15 +422,15 @@ class Service implements InjectionAwareInterface if ($cart->promo_id) { $promo = $this->di['db']->getExistingModelById('Promo', $cart->promo_id, 'Promo not found'); if (!$this->isClientAbleToUsePromo($client, $promo)) { - throw new \Box_Exception('You have already used this promo code. Please remove promo code and checkout again.', null, 9874); + throw new \FOSSBilling\InformationException('You have already used this promo code. Please remove promo code and checkout again.', null, 9874); } if (!$promo instanceof \Model_Promo) { - throw new \Box_Exception('Promo code is expired or does not exist'); + throw new \FOSSBilling\InformationException('Promo code is expired or does not exist'); } if (!$this->isPromoAvailableForClientGroup($promo)) { - throw new \Box_Exception('Promo can not be applied to your account'); + throw new \FOSSBilling\InformationException('Promo can not be applied to your account'); } } @@ -482,7 +482,7 @@ class Service implements InjectionAwareInterface $cart = $this->getSessionCart(); $ca = $this->toApiArray($cart); if ((is_countable($ca['items']) ? count($ca['items']) : 0) == 0) { - throw new \Box_Exception('Can not checkout an empty cart'); + throw new \FOSSBilling\InformationException('Can not checkout an empty cart'); } $currency = $this->di['db']->getExistingModelById('Currency', $cart->currency_id, 'Currency not found.'); @@ -494,7 +494,7 @@ class Service implements InjectionAwareInterface } if ($client->currency != $currency->code) { - throw new \Box_Exception('Selected currency :selected does not match your profile currency :code. Please change cart currency to continue.', [':selected' => $currency->code, ':code' => $client->currency]); + throw new \FOSSBilling\InformationException('Selected currency :selected does not match your profile currency :code. Please change cart currency to continue.', [':selected' => $currency->code, ':code' => $client->currency]); } $clientService = $this->di['mod_service']('client'); @@ -510,7 +510,7 @@ class Service implements InjectionAwareInterface $product = $this->di['db']->getExistingModelById('Product', $item['product_id']); if (is_null($product) || $product->status !== 'enabled') { - throw new \Box_Exception('Unable to complete order. One or more of the selected products are invalid.'); + throw new \FOSSBilling\InformationException('Unable to complete order. One or more of the selected products are invalid.'); } /* diff --git a/src/modules/Client/Api/Admin.php b/src/modules/Client/Api/Admin.php index 8e720fb93..4d08a0bb7 100644 --- a/src/modules/Client/Api/Admin.php +++ b/src/modules/Client/Api/Admin.php @@ -146,7 +146,7 @@ class Admin extends \Api_Abstract $service = $this->getService(); if ($service->emailAlreadyRegistered($data['email'])) { - throw new \Box_Exception('Email is already registered.'); + throw new \FOSSBilling\InformationException('Email is already registered.'); } $validator->isPasswordStrong($data['password']); @@ -236,7 +236,7 @@ class Admin extends \Api_Abstract $email = $data['email']; $email = $this->di['tools']->validateAndSanitizeEmail($email); if ($service->emailAlreadyRegistered($email, $client)) { - throw new \Box_Exception('Can not change email. It is already registered.'); + throw new \FOSSBilling\InformationException('Can not change email. It is already registered.'); } } @@ -320,7 +320,7 @@ class Admin extends \Api_Abstract $this->di['validator']->checkRequiredParamsForArray($required, $data); if ($data['password'] != $data['password_confirm']) { - throw new \Box_Exception('Passwords do not match'); + throw new \FOSSBilling\InformationException('Passwords do not match'); } $this->di['validator']->isPasswordStrong($data['password']); @@ -480,7 +480,7 @@ class Admin extends \Api_Abstract $model = $this->di['db']->getExistingModelById('ActivityClientHistory', $data['id']); if (!$model instanceof \Model_ActivityClientHistory) { - throw new \Box_Exception('Event not found'); + throw new \FOSSBilling\Exception('Event not found'); } $this->di['db']->trash($model); @@ -564,7 +564,7 @@ class Admin extends \Api_Abstract $clients = $this->di['db']->find('Client', 'client_group_id = :group_id', [':group_id' => $data['id']]); if ((is_countable($clients) ? count($clients) : 0) > 0) { - throw new \Box_Exception('Group has clients assigned. Please reassign them first.'); + throw new \FOSSBilling\InformationException('Group has clients assigned. Please reassign them first.'); } return $this->getService()->deleteGroup($model); diff --git a/src/modules/Client/Api/Guest.php b/src/modules/Client/Api/Guest.php index ebd3dddd2..f34585298 100644 --- a/src/modules/Client/Api/Guest.php +++ b/src/modules/Client/Api/Guest.php @@ -56,7 +56,7 @@ class Guest extends \Api_Abstract $config = $this->di['mod_config']('client'); if (isset($config['disable_signup']) && $config['disable_signup']) { - throw new \Box_Exception('New registrations are temporary disabled'); + throw new \FOSSBilling\InformationException('New registrations are temporary disabled'); } $required = [ @@ -68,7 +68,7 @@ class Guest extends \Api_Abstract $this->di['validator']->checkRequiredParamsForArray($required, $data); if ($data['password'] != $data['password_confirm']) { - throw new \Box_Exception('Passwords do not match.'); + throw new \FOSSBilling\InformationException('Passwords do not match.'); } $this->getService()->checkExtraRequiredFields($data); @@ -81,7 +81,7 @@ class Guest extends \Api_Abstract $email = $this->di['tools']->validateAndSanitizeEmail($email); $email = strtolower(trim($email)); if ($service->clientAlreadyExists($email)) { - throw new \Box_Exception('Email is already registered. You may want to login instead of registering.'); + throw new \FOSSBilling\InformationException('Email is already registered. You may want to login instead of registering.'); } $client = $service->guestCreateClient($data); @@ -106,7 +106,7 @@ class Guest extends \Api_Abstract * * @return array - session data * - * @throws \Box_Exception + * @throws \FOSSBilling\InformationException */ public function login($data) { @@ -127,7 +127,7 @@ class Guest extends \Api_Abstract if (!$client instanceof \Model_Client) { $this->di['events_manager']->fire(['event' => 'onEventClientLoginFailed', 'params' => $event_params]); - throw new \Box_Exception('Please check your login details.', [], 401); + throw new \FOSSBilling\InformationException('Please check your login details.', [], 401); } $this->di['events_manager']->fire(['event' => 'onAfterClientLogin', 'params' => ['id' => $client->id, 'ip' => $this->ip]]); @@ -151,7 +151,7 @@ class Guest extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function reset_password($data) { @@ -225,16 +225,16 @@ class Guest extends \Api_Abstract $validator->checkRequiredParamsForArray($required, $data); if ($data['password'] != $data['password_confirm']) { - throw new \Box_Exception('Passwords do not match'); + throw new \FOSSBilling\InformationException('Passwords do not match'); } $reset = $this->di['db']->findOne('ClientPasswordReset', 'hash = ?', [$data['hash']]); if (!$reset instanceof \Model_ClientPasswordReset) { - throw new \Box_Exception('The link has expired or you have already reset your password.'); + throw new \FOSSBilling\InformationException('The link has expired or you have already reset your password.'); } if (strtotime($reset->created_at) - time() + 900 < 0) { - throw new \Box_Exception('The link has expired or you have already reset your password.'); + throw new \FOSSBilling\InformationException('The link has expired or you have already reset your password.'); } $c = $this->di['db']->getExistingModelById('Client', $reset->client_id, 'Client not found'); diff --git a/src/modules/Client/Service.php b/src/modules/Client/Service.php index be5d7e114..740af3583 100644 --- a/src/modules/Client/Service.php +++ b/src/modules/Client/Service.php @@ -32,7 +32,7 @@ class Service implements InjectionAwareInterface $db = $this->di['db']; $result = $db->getRow('SELECT id, client_id FROM extension_meta WHERE extension = "mod_client" AND meta_key = "confirm_email" AND meta_value = :hash', [':hash' => $hash]); if (!$result) { - throw new \Box_Exception('Invalid email confirmation link'); + throw new \FOSSBilling\InformationException('Invalid email confirmation link'); } $db->exec('UPDATE client SET email_approved = 1 WHERE id = :id', ['id' => $result['client_id']]); $db->exec('DELETE FROM extension_meta WHERE id = :id', ['id' => $result['id']]); @@ -180,7 +180,7 @@ class Service implements InjectionAwareInterface { $limit = $data['per_page'] ?? 30; if (!is_numeric($limit) || $limit < 1) { - throw new \Box_Exception('Invalid per page number'); + throw new \FOSSBilling\InformationException('Invalid per page number'); } [$sql, $params] = $this->getSearchQuery($data, "SELECT c.id, CONCAT(c.company, ': (', c.first_name, ' ', c.last_name, ')') as client"); @@ -222,12 +222,12 @@ class Service implements InjectionAwareInterface $invoice = $this->di['db']->findOne('Invoice', 'client_id = :client_id', [':client_id' => $model->id]); if ($invoice instanceof \Model_Invoice) { - throw new \Box_Exception('Currency can not be changed. Client already have invoices issued.'); + throw new \FOSSBilling\InformationException('Currency can not be changed. Client already have invoices issued.'); } $order = $this->di['db']->findOne('ClientOrder', 'client_id = :client_id', [':client_id' => $model->id]); if ($order instanceof \Model_ClientOrder) { - throw new \Box_Exception('Currency can not be changed. Client already have orders.'); + throw new \FOSSBilling\InformationException('Currency can not be changed. Client already have orders.'); } return true; @@ -236,15 +236,15 @@ class Service implements InjectionAwareInterface public function addFunds(\Model_Client $client, $amount, $description, array $data = []) { if (!$client->currency) { - throw new \Box_Exception('Define clients currency before adding funds.'); + throw new \FOSSBilling\InformationException('Define clients currency before adding funds.'); } if (!is_numeric($amount)) { - throw new \Box_Exception('Funds amount is invalid'); + throw new \FOSSBilling\InformationException('Funds amount is invalid'); } if (empty($description)) { - throw new \Box_Exception('Funds description is invalid'); + throw new \FOSSBilling\InformationException('Funds description is invalid'); } $credit = $this->di['db']->dispense('ClientBalance'); @@ -412,7 +412,7 @@ class Service implements InjectionAwareInterface public function get($data) { if (!isset($data['id']) && !isset($data['email'])) { - throw new \Box_Exception('Client ID or email is required'); + throw new \FOSSBilling\InformationException('Client ID or email is required'); } $db = $this->di['db']; @@ -426,7 +426,7 @@ class Service implements InjectionAwareInterface } if (!$client instanceof \Model_Client) { - throw new \Box_Exception('Client not found'); + throw new \FOSSBilling\Exception('Client not found'); } return $client; @@ -469,7 +469,7 @@ class Service implements InjectionAwareInterface { $client = $this->di['db']->findOne('Client', 'client_group_id = ?', [$model->id]); if ($client) { - throw new \Box_Exception('Can not remove group with clients'); + throw new \FOSSBilling\Exception('Can not remove group with clients'); } $this->di['db']->trash($model); @@ -629,7 +629,7 @@ class Service implements InjectionAwareInterface && isset($config['disable_change_email']) && $config['disable_change_email'] ) { - throw new \Box_Exception('Email can not be changed'); + throw new \FOSSBilling\InformationException('Email can not be changed'); } return true; @@ -643,7 +643,7 @@ class Service implements InjectionAwareInterface if (!isset($checkArr[$field]) || empty($checkArr[$field])) { $name = ucwords(str_replace('_', ' ', $field)); - throw new \Box_Exception('Field :field cannot be empty', [':field' => $name]); + throw new \FOSSBilling\InformationException('Field :field cannot be empty', [':field' => $name]); } } } @@ -659,7 +659,7 @@ class Service implements InjectionAwareInterface if (!isset($checkArr[$cFieldName]) || empty($checkArr[$cFieldName])) { $name = isset($cField['title']) && !empty($cField['title']) ? $cField['title'] : ucwords(str_replace('_', ' ', $cFieldName)); - throw new \Box_Exception('Field :field cannot be empty', [':field' => $name]); + throw new \FOSSBilling\InformationException('Field :field cannot be empty', [':field' => $name]); } } } @@ -687,7 +687,7 @@ class Service implements InjectionAwareInterface * * @return bool|int * - * @throws \Box_Exception + * @throws \FOSSBilling\InformationException */ public function password_reset_valid($data) { @@ -699,7 +699,7 @@ class Service implements InjectionAwareInterface $reset = $this->di['db']->findOne('ClientPasswordReset', 'hash = ?', [$data['hash']]); if (!$reset instanceof \Model_ClientPasswordReset) { - throw new \Box_Exception('The link has expired or you have already reset your password.'); + throw new \FOSSBilling\InformationException('The link has expired or you have already reset your password.'); } $c = $this->di['db']->findOne('Client', 'id = ?', [$reset->client_id]); diff --git a/src/modules/Client/ServiceBalance.php b/src/modules/Client/ServiceBalance.php index d7553981c..7aff34ea7 100644 --- a/src/modules/Client/ServiceBalance.php +++ b/src/modules/Client/ServiceBalance.php @@ -117,16 +117,16 @@ class ServiceBalance implements InjectionAwareInterface * * @return \Model_ClientBalance * - * @throws \Box_Exception + * @throws \FOSSBilling\InformationException */ public function deductFunds(\Model_Client $client, $amount, $description, array $data = null) { if (!is_numeric($amount)) { - throw new \Box_Exception('Funds amount is invalid'); + throw new \FOSSBilling\InformationException('Funds amount is invalid'); } if (strlen(trim($description)) == 0) { - throw new \Box_Exception('Funds description is invalid'); + throw new \FOSSBilling\InformationException('Funds description is invalid'); } $credit = $this->di['db']->dispense('ClientBalance'); diff --git a/src/modules/Cookieconsent/Api/Guest.php b/src/modules/Cookieconsent/Api/Guest.php index ebe0df00d..08310903d 100644 --- a/src/modules/Cookieconsent/Api/Guest.php +++ b/src/modules/Cookieconsent/Api/Guest.php @@ -23,7 +23,7 @@ class Guest extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function message() { diff --git a/src/modules/Currency/Api/Admin.php b/src/modules/Currency/Api/Admin.php index b80984e1b..9a863b81b 100644 --- a/src/modules/Currency/Api/Admin.php +++ b/src/modules/Currency/Api/Admin.php @@ -51,7 +51,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function get($data) { @@ -64,7 +64,7 @@ class Admin extends \Api_Abstract $model = $service->getByCode($data['code']); if (!$model instanceof \Model_Currency) { - throw new \Box_Exception('Currency not found'); + throw new \FOSSBilling\Exception('Currency not found'); } return $service->toApiArray($model); @@ -90,7 +90,7 @@ class Admin extends \Api_Abstract * * @return string - currency code * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function create($data = []) { @@ -103,11 +103,11 @@ class Admin extends \Api_Abstract $service = $this->getService(); if ($service->getByCode($data['code'] ?? null)) { - throw new \Box_Exception('Currency already registered'); + throw new \FOSSBilling\Exception('Currency already registered'); } if (!array_key_exists($data['code'] ?? null, $service->getAvailableCurrencies())) { - throw new \Box_Exception('Currency code is invalid'); + throw new \FOSSBilling\Exception('Currency code is invalid'); } $title = $data['title'] ?? null; @@ -125,7 +125,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function update($data) { @@ -205,7 +205,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function delete($data) { @@ -223,7 +223,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function set_default($data) { @@ -235,7 +235,7 @@ class Admin extends \Api_Abstract $service = $this->getService(); $model = $service->getByCode($data['code']); if (!$model instanceof \Model_Currency) { - throw new \Box_Exception('Currency not found'); + throw new \FOSSBilling\Exception('Currency not found'); } return $service->setAsDefault($model); diff --git a/src/modules/Currency/Api/Guest.php b/src/modules/Currency/Api/Guest.php index cb9046164..bd1157510 100644 --- a/src/modules/Currency/Api/Guest.php +++ b/src/modules/Currency/Api/Guest.php @@ -44,7 +44,7 @@ class Guest extends \Api_Abstract } if (!$model instanceof \Model_Currency) { - throw new \Box_Exception('Currency not found'); + throw new \FOSSBilling\Exception('Currency not found'); } return $service->toApiArray($model); diff --git a/src/modules/Currency/Service.php b/src/modules/Currency/Service.php index 50a74f42b..6c162d2fc 100644 --- a/src/modules/Currency/Service.php +++ b/src/modules/Currency/Service.php @@ -55,7 +55,7 @@ class Service implements InjectionAwareInterface { $f_rate = $this->getRateByCode($foreign_code); if ($f_rate == 0) { - throw new \Box_Exception('Currency conversion rate can not be zero'); + throw new \FOSSBilling\InformationException('Currency conversion rate can not be zero'); } return 1 / $f_rate; @@ -121,7 +121,7 @@ class Service implements InjectionAwareInterface } if ($currency->code === null || empty($currency->code)) { - throw new \Box_Exception('Currency code not provided'); + throw new \FOSSBilling\Exception('Currency code not provided'); } $sql1 = 'UPDATE currency SET is_default = 0 WHERE 1'; @@ -319,11 +319,11 @@ class Service implements InjectionAwareInterface public function rm(\Model_Currency $model) { if ($model->is_default) { - throw new \Box_Exception('Can not remove default currency'); + throw new \FOSSBilling\InformationException('Can not remove default currency'); } if ($model->code === null || empty($model->code)) { - throw new \Box_Exception('Currency not found'); + throw new \FOSSBilling\Exception('Currency not found'); } $sql = 'DELETE FROM currency WHERE code = :code'; @@ -454,7 +454,7 @@ class Service implements InjectionAwareInterface $model = $this->getByCode($code); if (!$model instanceof \Model_Currency) { - throw new \Box_Exception('Currency not found'); + throw new \FOSSBilling\Exception('Currency not found'); } if (isset($title)) { @@ -472,7 +472,7 @@ class Service implements InjectionAwareInterface if (isset($conversionRate)) { if (!is_numeric($conversionRate) || $conversionRate <= 0) { - throw new \Box_Exception('Currency rate is invalid', null, 151); + throw new \FOSSBilling\InformationException('Currency rate is invalid', null, 151); } $model->conversion_rate = $conversionRate; } @@ -537,7 +537,7 @@ class Service implements InjectionAwareInterface } } - throw new \Box_Exception('Failed to get currency rates for :currency from the European Central Bank API', [':currency' => $to_Currency]); + throw new \FOSSBilling\Exception('Failed to get currency rates for :currency from the European Central Bank API', [':currency' => $to_Currency]); } else { $client = HttpClient::create(); $response = $client->request('GET', 'https://api.apilayer.com/currency_data/live', [ @@ -553,7 +553,7 @@ class Service implements InjectionAwareInterface $array = $response->toArray(); if ($array['success'] !== true) { - throw new \Box_Exception('Currencylayer threw an error:
    :errorInfo', [':errorInfo' => $array['error']['info']]); + throw new \FOSSBilling\Exception('Currencylayer threw an error:
    :errorInfo', [':errorInfo' => $array['error']['info']]); } else { return (float) $array['quotes'][$from_Currency . $to_Currency]; } @@ -565,7 +565,7 @@ class Service implements InjectionAwareInterface $model = $this->getByCode($code); if (!$model instanceof \Model_Currency) { - throw new \Box_Exception('Currency not found'); + throw new \FOSSBilling\Exception('Currency not found'); } $code = $model->code; diff --git a/src/modules/Email/Api/Admin.php b/src/modules/Email/Api/Admin.php index 9b360c7b0..42ae53895 100644 --- a/src/modules/Email/Api/Admin.php +++ b/src/modules/Email/Api/Admin.php @@ -99,7 +99,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function email_resend($data) { @@ -111,7 +111,7 @@ class Admin extends \Api_Abstract $model = $this->di['db']->findOne('ActivityClientEmail', 'id = ?', [$data['id']]); if (!$model instanceof \Model_ActivityClientEmail) { - throw new \Box_Exception('Email not found'); + throw new \FOSSBilling\Exception('Email not found'); } return $this->getService()->resend($model); @@ -122,7 +122,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function email_delete($data) { @@ -134,7 +134,7 @@ class Admin extends \Api_Abstract $model = $this->di['db']->findOne('ActivityClientEmail', 'id = ?', [$data['id']]); if (!$model instanceof \Model_ActivityClientEmail) { - throw new \Box_Exception('Email not found'); + throw new \FOSSBilling\Exception('Email not found'); } $id = $model->id; @@ -175,7 +175,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function template_get($data) { @@ -194,7 +194,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function template_delete($data) { @@ -206,7 +206,7 @@ class Admin extends \Api_Abstract $model = $this->di['db']->findOne('EmailTemplate', 'id = ?', [$data['id']]); if (!$model instanceof \Model_EmailTemplate) { - throw new \Box_Exception('Email template not found'); + throw new \FOSSBilling\Exception('Email template not found'); } $id = $model->id; @@ -223,7 +223,7 @@ class Admin extends \Api_Abstract * * @return int - newly created template id * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function template_create($data) { @@ -247,7 +247,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception * = */ public function template_update($data) { @@ -382,7 +382,7 @@ class Admin extends \Api_Abstract $this->di['validator']->checkRequiredParamsForArray($required, $data); if (!isset($data['to']) && !isset($data['to_staff']) && !isset($data['to_client'])) { - throw new \Box_Exception('Receiver is not defined. Define to or to_client or to_staff parameter'); + throw new \FOSSBilling\InformationException('Receiver is not defined. Define to or to_client or to_staff parameter'); } return $this->getService()->sendTemplate($data); diff --git a/src/modules/Email/Api/Client.php b/src/modules/Email/Api/Client.php index 4fd76b0ad..330a337a0 100644 --- a/src/modules/Email/Api/Client.php +++ b/src/modules/Email/Api/Client.php @@ -51,7 +51,7 @@ class Client extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function get($data) { @@ -63,7 +63,7 @@ class Client extends \Api_Abstract $model = $this->getService()->findOneForClientById($this->getIdentity(), $data['id']); if (!$model instanceof \Model_ActivityClientEmail) { - throw new \Box_Exception('Email not found'); + throw new \FOSSBilling\Exception('Email not found'); } return $this->getService()->toApiArray($model); @@ -74,7 +74,7 @@ class Client extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function resend($data) { @@ -85,7 +85,7 @@ class Client extends \Api_Abstract $model = $this->getService()->findOneForClientById($this->getIdentity(), $data['id']); if (!$model instanceof \Model_ActivityClientEmail) { - throw new \Box_Exception('Email not found'); + throw new \FOSSBilling\Exception('Email not found'); } return $this->getService()->resend($model); @@ -96,7 +96,7 @@ class Client extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function delete($data) { @@ -107,7 +107,7 @@ class Client extends \Api_Abstract $model = $this->getService()->findOneForClientById($this->getIdentity(), $data['id']); if (!$model instanceof \Model_ActivityClientEmail) { - throw new \Box_Exception('Email not found'); + throw new \FOSSBilling\Exception('Email not found'); } return $this->getService()->rm($model); diff --git a/src/modules/Email/Service.php b/src/modules/Email/Service.php index 70c3deae6..8c1994d64 100644 --- a/src/modules/Email/Service.php +++ b/src/modules/Email/Service.php @@ -109,7 +109,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface public function setVars($t, $vars) { $config = $this->di['config']; - $t->vars = $this->di['crypt']->encrypt(json_encode($vars), $config['salt']); + $t->vars = $this->di['crypt']->encrypt(json_encode($vars), $config['info']['salt']); $this->di['db']->store($t); return true; @@ -121,7 +121,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface public function getVars($t) { $config = $this->di['config']; - $json = $this->di['crypt']->decrypt($t->vars, $config['salt']); + $json = $this->di['crypt']->decrypt($t->vars, $config['info']['salt']); return $this->di['tools']->decodeJ($json); } @@ -134,7 +134,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface $this->di['validator']->checkRequiredParamsForArray($required, $data); if (!isset($data['to']) && !isset($data['to_staff']) && !isset($data['to_client']) && !isset($data['to_admin'])) { - throw new \Box_Exception('Receiver is not defined. Define to or to_client or to_staff or to_admin parameter'); + throw new \FOSSBilling\InformationException('Receiver is not defined. Define to or to_client or to_staff or to_admin parameter'); } $vars = $data; unset($vars['to'], $vars['to_client'], $vars['to_staff'], $vars['to_name'], $vars['from'], $vars['from_name'], $vars['to_admin']); @@ -193,7 +193,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface $sent = false; if (!$from) { - throw new \Box_Exception('From email address can not be empty'); + throw new \FOSSBilling\InformationException('From email address can not be empty'); } if (isset($staff)) { @@ -448,7 +448,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface $t = $this->di['db']->findOne('EmailTemplate', 'action_code = :action', [':action' => $code]); if (!$t instanceof \Model_EmailTemplate) { - throw new \Box_Exception('Email template :code was not found', [':code' => $code]); + throw new \FOSSBilling\Exception('Email template :code was not found', [':code' => $code]); } $d = ['code' => $code]; @@ -463,7 +463,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface { $model = $this->di['db']->findOne('ActivityClientEmail', 'id = ?', [$id]); if (!$model instanceof \Model_ActivityClientEmail) { - throw new \Box_Exception('Email not found'); + throw new \FOSSBilling\Exception('Email not found'); } return $model; @@ -637,7 +637,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface // If the error message is long, truncate it and inform the user the rest is in the error log. $truncated = (strlen($message) > 350) ? __trans('Error message truncated due to length, please check the error log for the complete message: ') . substr($message, 0, 350) . '...' : $message; - throw new \Box_Exception($truncated); + throw new \FOSSBilling\Exception($truncated); } } diff --git a/src/modules/Extension/Api/Admin.php b/src/modules/Extension/Api/Admin.php index 5b9c94661..2160b7220 100644 --- a/src/modules/Extension/Api/Admin.php +++ b/src/modules/Extension/Api/Admin.php @@ -95,7 +95,7 @@ class Admin extends \Api_Abstract * * @param array $data The post data sent to the API. Should contain a key named `locale_id` which is set to the locale ID to change. (`en_US` for example) * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function toggle_language(array $data): bool { @@ -129,7 +129,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function update($data) { @@ -148,7 +148,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function activate($data) { @@ -169,7 +169,7 @@ class Admin extends \Api_Abstract * * @return bool - true * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function deactivate($data) { @@ -210,7 +210,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function install($data) { @@ -243,7 +243,7 @@ class Admin extends \Api_Abstract * * @return array - configuration parameters * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function config_get($data) { @@ -269,7 +269,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function config_save($data) { @@ -292,7 +292,7 @@ class Admin extends \Api_Abstract $service = $this->getService(); $ext = $service->findExtension($data['type'], $data['id']); if (!$ext instanceof \Model_Extension) { - throw new \Box_Exception('Extension not found'); + throw new \FOSSBilling\Exception('Extension not found'); } return $ext; diff --git a/src/modules/Extension/Api/Guest.php b/src/modules/Extension/Api/Guest.php index 625b323b3..cd3cb4313 100644 --- a/src/modules/Extension/Api/Guest.php +++ b/src/modules/Extension/Api/Guest.php @@ -51,12 +51,12 @@ class Guest extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function settings($data) { if (!isset($data['ext'])) { - throw new \Box_Exception('Parameter ext is missing'); + throw new \FOSSBilling\Exception('Parameter ext is missing'); } $service = $this->getService(); $config = $service->getConfig($data['ext']); diff --git a/src/modules/Extension/Service.php b/src/modules/Extension/Service.php index eaaf3b248..d0f47cd3a 100644 --- a/src/modules/Extension/Service.php +++ b/src/modules/Extension/Service.php @@ -317,7 +317,7 @@ class Service implements InjectionAwareInterface public function update(\Model_Extension $model) { - throw new \Box_Exception('Visit the extension directory for more information on updating this extension.', null, 252); + throw new \FOSSBilling\InformationException('Visit the extension directory for more information on updating this extension.', null, 252); } public function activate(\Model_Extension $ext) @@ -366,13 +366,13 @@ class Service implements InjectionAwareInterface case \FOSSBilling\ExtensionManager::TYPE_MOD: $mod = $ext->name; if ($this->isCoreModule($mod)) { - throw new \Box_Exception('FOSSBilling core modules can not be managed'); + throw new \FOSSBilling\InformationException('FOSSBilling core modules can not be managed'); } try { $mm = $this->di['mod']($mod); $mm->uninstall(); - } catch (\Box_Exception $e) { + } catch (\FOSSBilling\Exception $e) { if ($e->getCode() != 408) { throw $e; } @@ -431,7 +431,7 @@ class Service implements InjectionAwareInterface $code = $response->getStatusCode(); if ($code !== 200) { - throw new \Box_Exception('Failed to download the extension with error :code', [':code' => $code]); + throw new \FOSSBilling\Exception('Failed to download the extension with error :code', [':code' => $code]); } foreach ($client->stream($response) as $chunk) { @@ -448,7 +448,7 @@ class Service implements InjectionAwareInterface } catch (\PhpZip\Exception\ZipException $e) { error_log($e->getMessage()); - throw new \Box_Exception('Failed to extract file, please check file and folder permissions. Further details are available in the error log.'); + throw new \FOSSBilling\Exception('Failed to extract file, please check file and folder permissions. Further details are available in the error log.'); } switch ($type) { @@ -472,13 +472,13 @@ class Service implements InjectionAwareInterface if (isset($destination)) { if (file_exists($destination)) { - throw new \Box_Exception('Extension :id seems to be already installed.', [':id' => $id], 436); + throw new \FOSSBilling\Exception('Extension :id seems to be already installed.', [':id' => $id], 436); } if (!rename($extractedPath, $destination)) { - throw new \Box_Exception('Failed to move extension to it\'s final destination. Please check permissions for the destination folder. (:destination)', [':destination' => $destination], 437); + throw new \FOSSBilling\Exception('Failed to move extension to it\'s final destination. Please check permissions for the destination folder. (:destination)', [':destination' => $destination], 437); } } else { - throw new \Box_Exception('Extension type (:type) cannot be automatically installed.', [':type' => $type]); + throw new \FOSSBilling\InformationException('Extension type (:type) cannot be automatically installed.', [':type' => $type]); } if (file_exists($zipPath)) { @@ -509,12 +509,12 @@ class Service implements InjectionAwareInterface $mod = $this->di['mod']($ext->name); if ($mod->isCore()) { - throw new \Box_Exception('FOSSBilling core modules can not be installed or removed'); + throw new \FOSSBilling\InformationException('FOSSBilling core modules can not be installed or removed'); } $info = $mod->getManifest(); if (isset($info['minimum_boxbilling_version']) && \FOSSBilling\Version::compareVersion($info['minimum_boxbilling_version']) > 0) { - throw new \Box_Exception('Module can not be installed. It requires at least :min version of FOSSBilling. You are using :v', [':min' => $info['minimum_boxbilling_version'], ':v' => \FOSSBilling\Version::VERSION]); + throw new \FOSSBilling\InformationException('Module can not be installed. It requires at least :min version of FOSSBilling. You are using :v', [':min' => $info['minimum_boxbilling_version'], ':v' => \FOSSBilling\Version::VERSION]); } // Allow install module even if no installer exists @@ -522,7 +522,7 @@ class Service implements InjectionAwareInterface // perform install script if available try { $mod->install(); - } catch (\Box_Exception $e) { + } catch (\FOSSBilling\Exception $e) { if ($e->getCode() != 408) { throw $e; } @@ -611,7 +611,7 @@ class Service implements InjectionAwareInterface private function _getSalt() { - return $this->di['config']['salt']; + return $this->di['config']['info']['salt']; } public function getCoreAndActiveModules() diff --git a/src/modules/Formbuilder/Api/Admin.php b/src/modules/Formbuilder/Api/Admin.php index 73c14e59e..3005aa75a 100644 --- a/src/modules/Formbuilder/Api/Admin.php +++ b/src/modules/Formbuilder/Api/Admin.php @@ -23,7 +23,7 @@ class Admin extends \Api_Abstract * * @return int - ID of the created form * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function create_form($data) { @@ -33,7 +33,7 @@ class Admin extends \Api_Abstract $this->di['validator']->checkRequiredParamsForArray($required, $data); if (isset($data['type']) && (strtolower($data['type']) != 'horizontal' || strtolower($data['type']) != 'default')) { - throw new \Box_Exception('Form style was not found in predefined list', null, 3657); + throw new \FOSSBilling\Exception('Form style was not found in predefined list', null, 3657); } $service = $this->getService(); @@ -65,19 +65,19 @@ class Admin extends \Api_Abstract * * @return int - ID of created field * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function add_field($data) { $service = $this->getService(); if (!isset($data['type']) || !$service->typeValidation($data['type'])) { - throw new \Box_Exception('Form field type is invalid', null, 2684); + throw new \FOSSBilling\Exception('Form field type is invalid', null, 2684); } if (isset($data['options']) && is_array($data['options']) && !$service->isArrayUnique($data['options'])) { - throw new \Box_Exception('This input type must have unique values', null, 3658); + throw new \FOSSBilling\InformationException('This input type must have unique values', null, 3658); } if (!isset($data['form_id'])) { - throw new \Box_Exception('Form id was not passed', null, 9846); + throw new \FOSSBilling\InformationException('Form id was not passed', null, 9846); } $fieldId = $service->addNewField($data); @@ -90,7 +90,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function get_form($data) { @@ -109,7 +109,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function get_form_fields($data) { @@ -129,7 +129,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function get_field($data) { @@ -149,7 +149,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function get_forms() { @@ -164,7 +164,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function delete_form($data) { @@ -184,7 +184,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function delete_field($data) { @@ -223,7 +223,7 @@ class Admin extends \Api_Abstract * * @return int - The ID of the updated field * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function update_field($data) { @@ -234,7 +234,7 @@ class Admin extends \Api_Abstract $service = $this->getService(); if (isset($data['options']) && !$service->isArrayUnique($data['options'])) { - throw new \Box_Exception('This input type must have unique values', null, 3658); + throw new \FOSSBilling\InformationException('This input type must have unique values', null, 3658); } $fieldId = $service->updateField($data); @@ -257,15 +257,15 @@ class Admin extends \Api_Abstract * * @return int - ID of the new form * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function copy_form($data) { if (!isset($data['form_id'])) { - throw new \Box_Exception('Form id was not passed', null, 9958); + throw new \FOSSBilling\InformationException('Form id was not passed', null, 9958); } if (!isset($data['name'])) { - throw new \Box_Exception('Form name was not passed', null, 9842); + throw new \FOSSBilling\InformationException('Form name was not passed', null, 9842); } $service = $this->getService(); @@ -282,18 +282,18 @@ class Admin extends \Api_Abstract public function update_form_settings($data) { if (!isset($data['form_id']) || (trim($data['form_id']) == '')) { - throw new \Box_Exception('Form id was not passed', null, 1654); + throw new \FOSSBilling\InformationException('Form id was not passed', null, 1654); } if (!isset($data['form_name'])) { - throw new \Box_Exception('Form name was not passed', null, 9241); + throw new \FOSSBilling\InformationException('Form name was not passed', null, 9241); } if (!isset($data['type'])) { - throw new \Box_Exception('Form type was not passed', null, 3794); + throw new \FOSSBilling\InformationException('Form type was not passed', null, 3794); } if ($data['type'] != 'horizontal' && $data['type'] != 'default') { - throw new \Box_Exception('Field type not supported', null, 3207); + throw new \FOSSBilling\Exception('Field type not supported', null, 3207); } $service = $this->getService(); diff --git a/src/modules/Formbuilder/Api/Guest.php b/src/modules/Formbuilder/Api/Guest.php index 1e1fcd0a2..ef4350c1a 100644 --- a/src/modules/Formbuilder/Api/Guest.php +++ b/src/modules/Formbuilder/Api/Guest.php @@ -21,7 +21,7 @@ class Guest extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function get($data) { diff --git a/src/modules/Formbuilder/Service.php b/src/modules/Formbuilder/Service.php index 9df4628c0..e4d43d1dc 100644 --- a/src/modules/Formbuilder/Service.php +++ b/src/modules/Formbuilder/Service.php @@ -136,11 +136,11 @@ class Service implements InjectionAwareInterface $text = preg_replace('~[^\-\w]+~', '', $text); if (is_numeric(substr($text, 0, 1))) { - throw new \Box_Exception('Field name can not start with number.', null, 1649); + throw new \FOSSBilling\InformationException('Field name can not start with number.', null, 1649); } if (empty($text)) { - throw new \Box_Exception('Field name can not be empty. Please make sure it is not empty and does not contain special characters.', null, 3502); + throw new \FOSSBilling\InformationException('Field name can not be empty. Please make sure it is not empty and does not contain special characters.', null, 3502); } return $text; @@ -157,7 +157,7 @@ class Service implements InjectionAwareInterface $field['form_id'] = $get_field['form_id']; if ($this->formFieldNameExists(['form_id' => $field['form_id'], 'field_name' => $field['name'], 'field_id' => $fieldId])) { - throw new \Box_Exception('Unfortunately field with this name exists in this form already. Form must have different field names.', null, 7628); + throw new \FOSSBilling\InformationException('Unfortunately field with this name exists in this form already. Form must have different field names.', null, 7628); } $field['options'] = isset($field['options']) ? json_encode($field['options']) : ''; @@ -168,10 +168,10 @@ class Service implements InjectionAwareInterface if (isset($field['type'])) { if ($field['type'] == 'checkbox' || $field['type'] == 'radio' || $field['type'] == 'select') { if (!$this->isArrayUnique(array_filter($field['values'], 'strlen'))) { - throw new \Box_Exception(ucfirst($field['type']) . ' values must be unique', null, 1597); + throw new \FOSSBilling\InformationException(ucfirst($field['type']) . ' values must be unique', null, 1597); } if (!$this->isArrayUnique(array_filter($field['labels'], 'strlen'))) { - throw new \Box_Exception(ucfirst($field['type']) . ' labels must be unique', null, 1598); + throw new \FOSSBilling\InformationException(ucfirst($field['type']) . ' labels must be unique', null, 1598); } $field['options'] = array_combine($field['labels'], $field['values']); $field['options'] = array_filter($field['options'], 'strlen'); @@ -179,7 +179,7 @@ class Service implements InjectionAwareInterface } if ($field['type'] == 'textarea') { if ((is_countable($field['textarea_size']) ? count($field['textarea_size']) : 0) != count((array) array_filter($field['textarea_size'], 'is_numeric'))) { - throw new \Box_Exception('Textarea size options must be integer values', null, 3510); + throw new \FOSSBilling\InformationException('Textarea size options must be integer values', null, 3510); } $field['options'] = array_combine($field['textarea_option'], $field['textarea_size']); $field['options'] = json_encode($field['options'], JSON_FORCE_OBJECT); diff --git a/src/modules/Hook/Api/Admin.php b/src/modules/Hook/Api/Admin.php index 833dec4dd..4d121d6cf 100644 --- a/src/modules/Hook/Api/Admin.php +++ b/src/modules/Hook/Api/Admin.php @@ -47,7 +47,7 @@ class Admin extends \Api_Abstract $event = $data['event']; $params = $data['params'] ?? null; - if ($this->di['config']['debug']) { + if (BB_DEBUG) { try { $this->di['logger']->info($event . ': ' . var_export($params, 1)); } catch (\Exception $e) { diff --git a/src/modules/Hook/Service.php b/src/modules/Hook/Service.php index 7dfbb3efb..1dc08a5e2 100644 --- a/src/modules/Hook/Service.php +++ b/src/modules/Hook/Service.php @@ -115,7 +115,7 @@ class Service implements InjectionAwareInterface * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ private function connect($data) { diff --git a/src/modules/Invoice/Api/Admin.php b/src/modules/Invoice/Api/Admin.php index 8878d5b1e..4e1fa0749 100644 --- a/src/modules/Invoice/Api/Admin.php +++ b/src/modules/Invoice/Api/Admin.php @@ -230,7 +230,7 @@ class Admin extends \Api_Abstract * * @return string - invoice id * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function renewal_invoice($data) { @@ -242,7 +242,7 @@ class Admin extends \Api_Abstract $model = $this->di['db']->getExistingModelById('ClientOrder', $data['id'], 'Order not found'); if ($model->price <= 0) { - throw new \Box_Exception('Order :id is free. No need to generate invoice.', [':id' => $model->id]); + throw new \FOSSBilling\InformationException('Order :id is free. No need to generate invoice.', [':id' => $model->id]); } return $this->getService()->renewInvoice($model, $data); @@ -606,7 +606,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function gateway_get($data) { @@ -625,7 +625,7 @@ class Admin extends \Api_Abstract /** * Copy gateway from existing one. * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function gateway_copy($data) { @@ -652,7 +652,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function gateway_update($data) { @@ -672,7 +672,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function gateway_delete($data) { @@ -718,7 +718,7 @@ class Admin extends \Api_Abstract * * @return int - id * - * @throws \Box_Exception + * @throws \FOSSBilling\InformationException */ public function subscription_create($data) { @@ -733,7 +733,7 @@ class Admin extends \Api_Abstract $payGateway = $this->di['db']->getExistingModelById('PayGateway', $data['gateway_id'], 'Payment gateway not found'); if ($client->currency != $data['currency']) { - throw new \Box_Exception('Client currency must match subscription currency. Check if clients currency is defined.'); + throw new \FOSSBilling\InformationException('Client currency must match subscription currency. Check if clients currency is defined.'); } $subscriptionService = $this->di['mod_service']('Invoice', 'Subscription'); @@ -751,7 +751,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function subscription_update($data) { @@ -771,7 +771,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function subscription_get($data) { @@ -792,7 +792,7 @@ class Admin extends \Api_Abstract } if (!$model instanceof \Model_Subscription) { - throw new \Box_Exception('Subscription not found'); + throw new \FOSSBilling\Exception('Subscription not found'); } $subscriptionService = $this->di['mod_service']('Invoice', 'Subscription'); @@ -805,7 +805,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function subscription_delete($data) { @@ -825,7 +825,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function tax_delete($data) { diff --git a/src/modules/Invoice/Api/Client.php b/src/modules/Invoice/Api/Client.php index bef804637..b6bcb4062 100644 --- a/src/modules/Invoice/Api/Client.php +++ b/src/modules/Invoice/Api/Client.php @@ -41,7 +41,7 @@ class Client extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function get($data) { @@ -52,7 +52,7 @@ class Client extends \Api_Abstract $model = $this->di['db']->findOne('Invoice', 'hash = :hash', ['hash' => $data['hash']]); if (!$model) { - throw new \Box_Exception('Invoice was not found'); + throw new \FOSSBilling\Exception('Invoice was not found'); } return $this->getService()->toApiArray($model, true, $this->getIdentity()); @@ -65,7 +65,7 @@ class Client extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function update($data) { @@ -76,10 +76,10 @@ class Client extends \Api_Abstract $invoice = $this->di['db']->findOne('Invoice', 'hash = :hash', ['hash' => $data['hash']]); if (!$invoice) { - throw new \Box_Exception('Invoice was not found'); + throw new \FOSSBilling\Exception('Invoice was not found'); } if ($invoice->status == 'paid') { - throw new \Box_Exception('Paid Invoice can not be modified'); + throw new \FOSSBilling\InformationException('Paid Invoice can not be modified'); } $updateParams = []; @@ -95,7 +95,7 @@ class Client extends \Api_Abstract * * @return string - invoice hash * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function renewal_invoice($data) { @@ -107,10 +107,10 @@ class Client extends \Api_Abstract $model = $this->di['db']->findOne('ClientOrder', 'client_id = ? and id = ?', [$this->getIdentity()->id, $data['order_id']]); if (!$model instanceof \Model_ClientOrder) { - throw new \Box_Exception('Order not found'); + throw new \FOSSBilling\Exception('Order not found'); } if ($model->price <= 0) { - throw new \Box_Exception('Order :id is free. No need to generate invoice.', [':id' => $model->id]); + throw new \FOSSBilling\InformationException('Order :id is free. No need to generate invoice.', [':id' => $model->id]); } $service = $this->getService(); $invoice = $service->generateForOrder($model); @@ -135,7 +135,7 @@ class Client extends \Api_Abstract $this->di['validator']->checkRequiredParamsForArray($required, $data); if (!is_numeric($data['amount'])) { - throw new \Box_Exception('You need to enter numeric value'); + throw new \FOSSBilling\InformationException('You need to enter numeric value'); } $service = $this->getService(); @@ -151,7 +151,7 @@ class Client extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function delete($data) { @@ -162,7 +162,7 @@ class Client extends \Api_Abstract $model = $this->di['db']->findOne('Invoice', 'hash = :hash', ['hash' => $data['hash']]); if (!$model) { - throw new \Box_Exception('Invoice was not found'); + throw new \FOSSBilling\Exception('Invoice was not found'); } return $this->getService()->deleteInvoiceByClient($model); diff --git a/src/modules/Invoice/Api/Guest.php b/src/modules/Invoice/Api/Guest.php index 81626024a..46b6d9ec3 100644 --- a/src/modules/Invoice/Api/Guest.php +++ b/src/modules/Invoice/Api/Guest.php @@ -21,7 +21,7 @@ class Guest extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function get($data) { @@ -32,7 +32,7 @@ class Guest extends \Api_Abstract $model = $this->di['db']->findOne('Invoice', 'hash = :hash', ['hash' => $data['hash']]); if (!$model) { - throw new \Box_Exception('Invoice was not found'); + throw new \FOSSBilling\Exception('Invoice was not found'); } return $this->getService()->toApiArray($model, true, $this->getIdentity()); @@ -45,7 +45,7 @@ class Guest extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function update($data) { @@ -56,10 +56,10 @@ class Guest extends \Api_Abstract $invoice = $this->di['db']->findOne('Invoice', 'hash = :hash', ['hash' => $data['hash']]); if (!$invoice) { - throw new \Box_Exception('Invoice was not found'); + throw new \FOSSBilling\Exception('Invoice was not found'); } if ($invoice->status == 'paid') { - throw new \Box_Exception('Paid Invoice can not be modified'); + throw new \FOSSBilling\InformationException('Paid Invoice can not be modified'); } $updateParams = []; @@ -94,16 +94,16 @@ class Guest extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function payment($data) { if (!isset($data['hash'])) { - throw new \Box_Exception('Invoice hash not passed. Missing param hash', null, 810); + throw new \FOSSBilling\Exception('Invoice hash not passed. Missing param hash', null, 810); } if (!isset($data['gateway_id'])) { - throw new \Box_Exception('Payment method not found. Missing param gateway_id', null, 811); + throw new \FOSSBilling\Exception('Payment method not found. Missing param gateway_id', null, 811); } return $this->getService()->processInvoice($data); @@ -112,7 +112,7 @@ class Guest extends \Api_Abstract /** * Generates PDF for given invoice. * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function pdf($data) { diff --git a/src/modules/Invoice/Service.php b/src/modules/Invoice/Service.php index eaec25871..950a981ac 100644 --- a/src/modules/Invoice/Service.php +++ b/src/modules/Invoice/Service.php @@ -414,7 +414,7 @@ class Service implements InjectionAwareInterface if ($r instanceof \Model_Invoice && is_numeric($r->nr)) { $next_nr = intval($r->nr) + 1; } else { - throw new \Box_Exception('Unable to determine the next invoice number'); + throw new \FOSSBilling\Exception('Unable to determine the next invoice number'); } } @@ -559,7 +559,7 @@ class Service implements InjectionAwareInterface $epsilon = 0.05; if (abs($balance - $required) < $epsilon) { - if ($this->di['config']['debug']) { + if (BB_DEBUG) { error_log(sprintf('Setting invoice %s as paid with credits', $invoice->id)); } $this->markAsPaid($invoice); @@ -568,14 +568,14 @@ class Service implements InjectionAwareInterface } if ($balance - $required > 0.00001) { - if ($this->di['config']['debug']) { + if (BB_DEBUG) { error_log(sprintf('Setting invoice %s as paid with credits', $invoice->id)); } $this->markAsPaid($invoice); return true; } - if ($this->di['config']['debug']) { + if (BB_DEBUG) { error_log(sprintf('Invoice %s could not be paid with credits. Money in balance %s Required: %s', $invoice->id, $balance, $required)); } } @@ -628,7 +628,7 @@ class Service implements InjectionAwareInterface case 'negative_invoice': $total = $this->getTotalWithTax($invoice); if ($total <= 0) { - throw new \Box_Exception('Can not refund invoice with negative amount'); + throw new \FOSSBilling\InformationException('Can not refund invoice with negative amount'); } $new = $this->di['db']->dispense('Invoice'); @@ -708,7 +708,7 @@ class Service implements InjectionAwareInterface break; case 'manual': - if ($this->di['config']['debug']) { + if (BB_DEBUG) { error_log('Refunds are managed manually. No actions performed'); } @@ -843,7 +843,7 @@ class Service implements InjectionAwareInterface $invoiceItem = $this->di['db']->find('InvoiceItem', 'invoice_id = ?', [$model->id]); foreach ($invoiceItem as $item) { if ($item->type == \Model_InvoiceItem::TYPE_ORDER) { - throw new \Box_Exception('Invoice is related to order #:id. Please cancel order first.', [':id' => $item->rel_id]); + throw new \FOSSBilling\InformationException('Invoice is related to order #:id. Please cancel order first.', [':id' => $item->rel_id]); } } @@ -876,7 +876,7 @@ class Service implements InjectionAwareInterface $model = $this->di['db']->getExistingModelById('Invoice', $proforma['id']); $this->tryPayWithCredits($model); } catch (\Exception $e) { - if ($this->di['config']['debug']) { + if (BB_DEBUG) { error_log($e->getMessage()); } } @@ -910,7 +910,7 @@ class Service implements InjectionAwareInterface } if ($order->price <= 0) { - throw new \Box_Exception('Invoices are not generated for 0 amount orders'); + throw new \FOSSBilling\InformationException('Invoices are not generated for 0 amount orders'); } $client = $this->di['db']->getExistingModelById('Client', $order->client_id, 'Client not found'); @@ -1078,7 +1078,7 @@ class Service implements InjectionAwareInterface public function generateFundsInvoice(\Model_Client $client, $amount) { if (!$client->currency) { - throw new \Box_Exception('You must have at least one active order before you can add funds so you cannot proceed at the current time!'); + throw new \FOSSBilling\InformationException('You must have at least one active order before you can add funds so you cannot proceed at the current time!'); } $systemService = $this->di['mod_service']('system'); @@ -1087,11 +1087,11 @@ class Service implements InjectionAwareInterface $max_amount = $systemService->getParamValue('funds_max_amount', null); if ($min_amount && $amount < $min_amount) { - throw new \Box_Exception('Amount must be at least :min_amount', [':min_amount' => $min_amount], 981); + throw new \FOSSBilling\InformationException('Amount must be at least :min_amount', [':min_amount' => $min_amount], 981); } if ($max_amount && $amount > $max_amount) { - throw new \Box_Exception('Amount cannot exceed :max_amount', [':max_amount' => $max_amount], 982); + throw new \FOSSBilling\InformationException('Amount cannot exceed :max_amount', [':max_amount' => $max_amount], 982); } $proforma = $this->di['db']->dispense('Invoice'); @@ -1117,16 +1117,16 @@ class Service implements InjectionAwareInterface $invoice = $this->di['db']->findOne('Invoice', 'hash = ?', [$data['hash']]); if (!$invoice instanceof \Model_Invoice) { - throw new \Box_Exception('Invoice not found', null, 812); + throw new \FOSSBilling\Exception('Invoice not found', null, 812); } $gtw = $this->di['db']->load('PayGateway', $data['gateway_id']); if (!$gtw instanceof \Model_PayGateway) { - throw new \Box_Exception('Payment method not found', null, 813); + throw new \FOSSBilling\Exception('Payment method not found', null, 813); } if (!$gtw->enabled) { - throw new \Box_Exception('Payment method not enabled', null, 814); + throw new \FOSSBilling\Exception('Payment method not enabled', null, 814); } $subscribeService = $this->di['mod_service']('Invoice', 'Subscription'); @@ -1185,7 +1185,7 @@ class Service implements InjectionAwareInterface $invoice = $this->di['db']->findOne('Invoice', 'hash = :hash', [':hash' => $hash]); if (!$invoice instanceof \Model_Invoice) { - throw new \Box_Exception('Invoice not found'); + throw new \FOSSBilling\Exception('Invoice not found'); } if (isset($invoice->currency)) { diff --git a/src/modules/Invoice/ServiceInvoiceItem.php b/src/modules/Invoice/ServiceInvoiceItem.php index 5316e4d1e..1cad98d8b 100644 --- a/src/modules/Invoice/ServiceInvoiceItem.php +++ b/src/modules/Invoice/ServiceInvoiceItem.php @@ -58,7 +58,7 @@ class ServiceInvoiceItem implements InjectionAwareInterface $order_id = $this->getOrderId($item); $order = $this->di['db']->load('ClientOrder', $order_id); if (!$order instanceof \Model_ClientOrder) { - throw new \Box_Exception('Could not activate proforma item. Order :id not found', [':id' => $order_id]); + throw new \FOSSBilling\Exception('Could not activate proforma item. Order :id not found', [':id' => $order_id]); } $orderService = $this->di['mod_service']('Order'); switch ($item->task) { @@ -125,7 +125,7 @@ class ServiceInvoiceItem implements InjectionAwareInterface { $title = $data['title'] ?? ''; if (empty($title)) { - throw new \Box_Exception('Invoice item title is missing'); + throw new \FOSSBilling\InformationException('Invoice item title is missing'); } $period = $data['period'] ?? 0; diff --git a/src/modules/Invoice/ServicePayGateway.php b/src/modules/Invoice/ServicePayGateway.php index 32d833122..885d0346a 100644 --- a/src/modules/Invoice/ServicePayGateway.php +++ b/src/modules/Invoice/ServicePayGateway.php @@ -95,7 +95,7 @@ class ServicePayGateway implements InjectionAwareInterface { $available = $this->getAvailable(); if (!in_array($code, $available)) { - throw new \Box_Exception('Payment gateway is not available for installation.'); + throw new \FOSSBilling\Exception('Payment gateway is not available for installation.'); } $new = $this->di['db']->dispense('PayGateway'); @@ -249,7 +249,7 @@ class ServicePayGateway implements InjectionAwareInterface $class = $this->getAdapterClassName($pg); if (!class_exists($class)) { - throw new \Box_Exception('Payment gateway :adapter was not found', [':adapter' => $class]); + throw new \FOSSBilling\Exception('Payment gateway :adapter was not found', [':adapter' => $class]); } $adapter = new $class($config); @@ -278,12 +278,12 @@ class ServicePayGateway implements InjectionAwareInterface $class = $this->getAdapterClassName($pg); if (!file_exists(PATH_LIBRARY . '/Payment/Adapter/' . $pg->gateway . '.php')) { if (!file_exists(PATH_LIBRARY . '/Payment/Adapter/' . $pg->gateway . '/' . $pg->gateway . '.php')) { - throw new \Box_Exception('Payment gateway :adapter was not found', [':adapter' => $pg->gateway]); + throw new \FOSSBilling\Exception('Payment gateway :adapter was not found', [':adapter' => $pg->gateway]); } } if (!class_exists($class)) { - throw new \Box_Exception("Payment gateway class $class was not found"); + throw new \FOSSBilling\Exception("Payment gateway class $class was not found"); } if (!method_exists($class, 'getConfig')) { diff --git a/src/modules/Invoice/ServiceTransaction.php b/src/modules/Invoice/ServiceTransaction.php index 4ca932ff8..74b0a8222 100644 --- a/src/modules/Invoice/ServiceTransaction.php +++ b/src/modules/Invoice/ServiceTransaction.php @@ -79,11 +79,11 @@ class ServiceTransaction implements InjectionAwareInterface $skip_validation = isset($data['skip_validation']) ? (bool) $data['skip_validation'] : false; if (!$skip_validation) { if (!isset($data['bb_invoice_id'])) { - throw new \Box_Exception('Transaction invoice id is missing'); + throw new \FOSSBilling\InformationException('Transaction invoice id is missing'); } if (!isset($data['bb_gateway_id'])) { - throw new \Box_Exception('Payment gateway id is missing'); + throw new \FOSSBilling\InformationException('Payment gateway id is missing'); } $this->di['db']->getExistingModelById('Invoice', $data['bb_invoice_id'], 'Invoice was not found'); $this->di['db']->getExistingModelById('PayGateway', $data['bb_gateway_id'], 'Gateway was not found'); @@ -314,7 +314,7 @@ class ServiceTransaction implements InjectionAwareInterface { try { $output = $this->processTransaction($model->id); - } catch (\Box_Exception $e) { + } catch (\FOSSBilling\Exception $e) { $model->status = \Model_Transaction::STATUS_ERROR; $model->error = $e->getMessage(); $model->error_code = $e->getCode(); @@ -337,29 +337,29 @@ class ServiceTransaction implements InjectionAwareInterface * * @param int $id * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function processTransaction($id) { /** @var \Model_Transaction $tx */ $tx = $this->di['db']->load('Transaction', $id); if (!$tx) { - throw new \Box_Exception('Transaction :id not found.', ['id' => $id], 404); + throw new \FOSSBilling\Exception('Transaction :id not found.', ['id' => $id], 404); } if (empty($tx->gateway_id)) { - throw new \Box_Exception('Could not determine transaction origin. Transaction payment gateway is unknown.', null, 701); + throw new \FOSSBilling\Exception('Could not determine transaction origin. Transaction payment gateway is unknown.', null, 701); } $gtw = $this->di['db']->load('PayGateway', $tx->gateway_id); if (!$gtw instanceof \Model_PayGateway) { - throw new \Box_Exception('Can not handle transaction received from unknown payment gateway: :id', [':id' => $tx->gateway_id], 704); + throw new \FOSSBilling\Exception('Can not handle transaction received from unknown payment gateway: :id', [':id' => $tx->gateway_id], 704); } $payGatewayService = $this->di['mod_service']('Invoice', 'PayGateway'); $adapter = $payGatewayService->getPaymentAdapter($gtw); if (!method_exists($adapter, 'processTransaction')) { - throw new \Box_Exception('Payment adapter :adapter does not support action :action', [':adapter' => $gtw->name, ':action' => 'processTransaction'], 705); + throw new \FOSSBilling\Exception('Payment adapter :adapter does not support action :action', [':adapter' => $gtw->name, ':action' => 'processTransaction'], 705); } $ipn = json_decode($tx->ipn, 1); @@ -393,7 +393,7 @@ class ServiceTransaction implements InjectionAwareInterface \Payment_Transaction::TXTYPE_REFUND => $this->_refund($transaction), \Payment_Transaction::TXTYPE_SUBSCR_CREATE => $this->_subscribe($transaction), \Payment_Transaction::TXTYPE_SUBSCR_CANCEL => $this->_unsubscribe($transaction), - default => throw new \Box_Exception('Unknown transaction #:id type: :type', [':id' => $transaction->id, ':type' => $transaction->type], 632), + default => throw new \FOSSBilling\Exception('Unknown transaction #:id type: :type', [':id' => $transaction->id, ':type' => $transaction->type], 632), }; } catch (\Exception $e) { $transaction->status = \Model_Transaction::STATUS_ERROR; @@ -468,12 +468,12 @@ class ServiceTransaction implements InjectionAwareInterface $ipn = $this->di['tools']->decodeJ($tx->ipn); if (empty($tx->gateway_id)) { - throw new \Box_Exception('Could not determine transaction origin. Transaction payment gateway is unknown.', null, 701); + throw new \FOSSBilling\Exception('Could not determine transaction origin. Transaction payment gateway is unknown.', null, 701); } $gtw = $this->di['db']->load('PayGateway', $tx->gateway_id); if (!$gtw instanceof \Model_PayGateway) { - throw new \Box_Exception('Can not handle transaction received from unknown payment gateway: :id', [':id' => $tx->gateway_id], 704); + throw new \FOSSBilling\Exception('Can not handle transaction received from unknown payment gateway: :id', [':id' => $tx->gateway_id], 704); } $adapter = $payGatewayService->getPaymentAdapter($gtw); @@ -482,12 +482,12 @@ class ServiceTransaction implements InjectionAwareInterface } if (!$tx->invoice_id) { - throw new \Box_Exception('Transaction :id is not associated with an invoice.', [':id' => $tx->id], 702); + throw new \FOSSBilling\Exception('Transaction :id is not associated with an invoice.', [':id' => $tx->id], 702); } $invoice = $this->di['db']->load('Invoice', $tx->invoice_id); if (!$invoice instanceof \Model_Invoice) { - throw new \Box_Exception('Invoice #:id not found', [':id' => $tx->invoice_id], 703); + throw new \FOSSBilling\Exception('Invoice #:id not found', [':id' => $tx->invoice_id], 703); } $adapter = $payGatewayService->getPaymentAdapter($gtw, $invoice); @@ -497,18 +497,18 @@ class ServiceTransaction implements InjectionAwareInterface if (!$adapter->isIpnValid($ipn, $mpi)) { $tx->output = $adapter->getOutput(); - throw new \Box_Exception('Instant payment notification (IPN) did not pass gateway :id validation', [':id' => $gtw->gateway], 706); + throw new \FOSSBilling\Exception('Instant payment notification (IPN) did not pass gateway :id validation', [':id' => $gtw->gateway], 706); } $tx->output = $adapter->getOutput(); } if (!method_exists($adapter, 'getTransaction')) { - throw new \Box_Exception('Payment adapter :adapter does not support action :action', [':adapter' => $gtw->name, ':action' => 'getTransaction'], 705); + throw new \FOSSBilling\Exception('Payment adapter :adapter does not support action :action', [':adapter' => $gtw->name, ':action' => 'getTransaction'], 705); } $response = $adapter->getTransaction($ipn, $mpi); if (!$response instanceof \Payment_Transaction) { - throw new \Box_Exception('Payment gateway :id method getTransaction should return Payment_Transaction object', [':id' => $gtw->gateway], 705); + throw new \FOSSBilling\Exception('Payment gateway :id method getTransaction should return Payment_Transaction object', [':id' => $gtw->gateway], 705); } // if tx type is already defined, do not set them again @@ -561,7 +561,7 @@ class ServiceTransaction implements InjectionAwareInterface $invoiceService = $this->di['mod_service']('Invoice'); $invoiceService->tryPayWithCredits($tx->Invoice); } catch (\Exception $e) { - if ($this->di['config']['debug']) { + if (BB_DEBUG) { error_log($e->getMessage()); } } @@ -596,7 +596,7 @@ class ServiceTransaction implements InjectionAwareInterface $this->_validateApprovedTransaction($tx); if (empty($tx->s_id)) { - throw new \Box_Exception('Can not create subscription. Subscription id from payment gateway was not received'); + throw new \FOSSBilling\Exception('Can not create subscription. Subscription id from payment gateway was not received'); } $invoice = $this->di['db']->load('Invoice', $tx->invoice_id); @@ -631,7 +631,7 @@ class ServiceTransaction implements InjectionAwareInterface $serviceSubscription = $this->di['mod_service']('Subscription'); $model = $this->di['db']->load('Subscription', $tx->s_id); if (!$model instanceof \Model_Subscription) { - throw new \Box_Exception('Subscription #:id was not found. Could not unsubscribe', [':id' => $tx->s_id]); + throw new \FOSSBilling\Exception('Subscription #:id was not found. Could not unsubscribe', [':id' => $tx->s_id]); } $serviceSubscription->unsubscribe($model); @@ -644,23 +644,23 @@ class ServiceTransaction implements InjectionAwareInterface private function _validateApprovedTransaction(\Model_Transaction $tx) { if ($tx->status != \Model_Transaction::STATUS_APPROVED) { - throw new \Box_Exception('Only approved transaction can be processed'); + throw new \FOSSBilling\Exception('Only approved transaction can be processed'); } if (empty($tx->invoice_id)) { - throw new \Box_Exception('Transaction :id is not associated with an invoice.', [':id' => $tx->id], 7022); + throw new \FOSSBilling\Exception('Transaction :id is not associated with an invoice.', [':id' => $tx->id], 7022); } $invoice = $this->di['db']->load('Invoice', $tx->invoice_id); // check that payment currency is correct if ($invoice->currency != $tx->currency) { - throw new \Box_Exception('Transaction currency :code do not match required currency :required', [':code' => $tx->currency, ':required' => $invoice->currency], 709); + throw new \FOSSBilling\Exception('Transaction currency :code do not match required currency :required', [':code' => $tx->currency, ':required' => $invoice->currency], 709); } // check that payment status is completed if if ($tx->txn_status == \Payment_Transaction::STATUS_PENDING) { - throw new \Box_Exception('Transaction status on payment gateway is Pending. Only Complete or Unknown transactions can be processed.', null, 712); + throw new \FOSSBilling\Exception('Transaction status on payment gateway is Pending. Only Complete or Unknown transactions can be processed.', null, 712); } } @@ -670,12 +670,12 @@ class ServiceTransaction implements InjectionAwareInterface $client = $this->di['db']->load('Client', $proforma->client_id); if ($client->currency != $proforma->currency) { - throw new \Box_Exception('Client currency do not match invoice currency'); + throw new \FOSSBilling\Exception('Client currency do not match invoice currency'); } // do not debit negative or zero amount if ($tx->amount < 0) { - throw new \Box_Exception('Can not add negative amount to client balance for debit transaction'); + throw new \FOSSBilling\Exception('Can not add negative amount to client balance for debit transaction'); } $credit = $this->di['db']->dispense('ClientBalance'); diff --git a/src/modules/Kb/Api/Admin.php b/src/modules/Kb/Api/Admin.php index 9984e56d1..ad72f0e86 100644 --- a/src/modules/Kb/Api/Admin.php +++ b/src/modules/Kb/Api/Admin.php @@ -52,7 +52,7 @@ class Admin extends \Api_Abstract $model = $this->di['db']->findOne('KbArticle', 'id = ?', [$data['id']]); if (!$model instanceof \Model_KbArticle) { - throw new \Box_Exception('Article not found'); + throw new \FOSSBilling\Exception('Article not found'); } return $this->getService()->toApiArray($model, true, $this->getIdentity()); @@ -126,7 +126,7 @@ class Admin extends \Api_Abstract $model = $this->di['db']->findOne('KbArticle', 'id = ?', [$data['id']]); if (!$model instanceof \Model_KbArticle) { - throw new \Box_Exception('Article not found'); + throw new \FOSSBilling\Exception('Article not found'); } $this->getService()->rm($model); @@ -168,7 +168,7 @@ class Admin extends \Api_Abstract $model = $this->di['db']->findOne('KbArticleCategory', 'id = ?', [$data['id']]); if (!$model instanceof \Model_KbArticleCategory) { - throw new \Box_Exception('Article Category not found'); + throw new \FOSSBilling\Exception('Article Category not found'); } return $this->getService()->categoryToApiArray($model); @@ -213,7 +213,7 @@ class Admin extends \Api_Abstract $model = $this->di['db']->findOne('KbArticleCategory', 'id = ?', [$data['id']]); if (!$model instanceof \Model_KbArticleCategory) { - throw new \Box_Exception('Article Category not found'); + throw new \FOSSBilling\Exception('Article Category not found'); } $title = $data['title'] ?? null; @@ -238,7 +238,7 @@ class Admin extends \Api_Abstract $model = $this->di['db']->findOne('KbArticleCategory', 'id = ?', [$data['id']]); if (!$model instanceof \Model_KbArticleCategory) { - throw new \Box_Exception('Category not found'); + throw new \FOSSBilling\Exception('Category not found'); } return $this->getService()->categoryRm($model); diff --git a/src/modules/Kb/Api/Guest.php b/src/modules/Kb/Api/Guest.php index 5f0fb107a..4ea1eb152 100644 --- a/src/modules/Kb/Api/Guest.php +++ b/src/modules/Kb/Api/Guest.php @@ -50,7 +50,7 @@ class Guest extends \Api_Abstract public function article_get($data) { if (!isset($data['id']) && !isset($data['slug'])) { - throw new \Box_Exception('ID or slug is missing'); + throw new \FOSSBilling\Exception('ID or slug is missing'); } $id = $data['id'] ?? null; @@ -64,7 +64,7 @@ class Guest extends \Api_Abstract } if (!$model instanceof \Model_KbArticle) { - throw new \Box_Exception('Article item not found'); + throw new \FOSSBilling\Exception('Article item not found'); } $this->getService()->hitView($model); @@ -112,7 +112,7 @@ class Guest extends \Api_Abstract public function category_get($data) { if (!isset($data['id']) && !isset($data['slug'])) { - throw new \Box_Exception('Category ID or slug is missing'); + throw new \FOSSBilling\Exception('Category ID or slug is missing'); } $id = $data['id'] ?? null; @@ -126,7 +126,7 @@ class Guest extends \Api_Abstract } if (!$model instanceof \Model_KbArticleCategory) { - throw new \Box_Exception('Knowledge base category not found'); + throw new \FOSSBilling\Exception('Knowledge base category not found'); } return $this->getService()->categoryToApiArray($model, $this->getIdentity()); diff --git a/src/modules/Kb/Service.php b/src/modules/Kb/Service.php index 9fb550c98..4c627e754 100644 --- a/src/modules/Kb/Service.php +++ b/src/modules/Kb/Service.php @@ -144,7 +144,7 @@ class Service $model = $this->di['db']->findOne('KbArticle', 'id = ?', [$id]); if (!$model instanceof \Model_KbArticle) { - throw new \Box_Exception('Article not found'); + throw new \FOSSBilling\Exception('Article not found'); } if (isset($articleCategoryId)) { @@ -241,7 +241,7 @@ class Service $articlesCount = $this->di['db']->getCell('SELECT count(*) as cnt FROM kb_article WHERE kb_article_category_id = :kb_article_category_id', $bindings); if ($articlesCount > 0) { - throw new \Box_Exception('Can not remove category which has articles'); + throw new \FOSSBilling\InformationException('Can not remove category which has articles'); } $id = $model->id; diff --git a/src/modules/Massmailer/Api/Admin.php b/src/modules/Massmailer/Api/Admin.php index f069b4fa5..b2ef22298 100644 --- a/src/modules/Massmailer/Api/Admin.php +++ b/src/modules/Massmailer/Api/Admin.php @@ -69,7 +69,7 @@ class Admin extends \Api_Abstract if (isset($data['from_name'])) { if (empty($data['from_name'])) { - throw new \Box_Exception('Message from name can not be empty'); + throw new \FOSSBilling\InformationException('Message from name can not be empty'); } $model->from_name = $data['from_name']; } @@ -151,7 +151,7 @@ Order our services at {{ "order"|link }} $client_id = $this->_getTestClientId(); if (empty($model->content)) { - throw new \Box_Exception('Add some content before sending message'); + throw new \FOSSBilling\InformationException('Add some content before sending message'); } $this->getService()->sendMessage($model, $client_id); @@ -172,7 +172,7 @@ Order our services at {{ "order"|link }} $model = $this->_getMessage($data); if (empty($model->content)) { - throw new \Box_Exception('Add some content before sending message'); + throw new \FOSSBilling\InformationException('Add some content before sending message'); } $mod = $this->di['mod']('massmailer'); diff --git a/src/modules/Massmailer/Service.php b/src/modules/Massmailer/Service.php index 0357fa6de..69e4bc54d 100644 --- a/src/modules/Massmailer/Service.php +++ b/src/modules/Massmailer/Service.php @@ -158,11 +158,11 @@ class Service implements \FOSSBilling\InjectionAwareInterface $extensionService = $this->di['mod_service']('extension'); if ($extensionService->isExtensionActive('mod', 'demo')) { - throw new \Box_Exception('Disabled for security reasons (Demo mode enabled)'); + throw new \FOSSBilling\InformationException('Disabled for security reasons (Demo mode enabled)'); } if (!Environment::isProduction()) { - if ($this->di['config']['debug']) { + if (BB_DEBUG) { error_log('Skip email sending. Application ENV: ' . Environment::getCurrentEnvironment()); } diff --git a/src/modules/News/Api/Admin.php b/src/modules/News/Api/Admin.php index e5d41c756..ae57730e0 100644 --- a/src/modules/News/Api/Admin.php +++ b/src/modules/News/Api/Admin.php @@ -43,7 +43,7 @@ class Admin extends \Api_Abstract public function get($data) { if (!isset($data['id']) && !isset($data['slug'])) { - throw new \Box_Exception('ID or slug is missing'); + throw new \FOSSBilling\Exception('ID or slug is missing'); } $id = $data['id'] ?? null; @@ -59,7 +59,7 @@ class Admin extends \Api_Abstract } if (!$model instanceof \Model_Post) { - throw new \Box_Exception('News item not found'); + throw new \FOSSBilling\Exception('News item not found'); } return $this->getService()->toApiArray($model, 'admin'); diff --git a/src/modules/News/Api/Guest.php b/src/modules/News/Api/Guest.php index e563cfbd9..ebf007146 100644 --- a/src/modules/News/Api/Guest.php +++ b/src/modules/News/Api/Guest.php @@ -44,7 +44,7 @@ class Guest extends \Api_Abstract public function get($data) { if (!isset($data['id']) && !isset($data['slug'])) { - throw new \Box_Exception('ID or slug is missing'); + throw new \FOSSBilling\Exception('ID or slug is missing'); } $id = $data['id'] ?? null; @@ -57,7 +57,7 @@ class Guest extends \Api_Abstract } if (!$model || $model->status !== 'active') { - throw new \Box_Exception('News item not found'); + throw new \FOSSBilling\Exception('News item not found'); } return $this->getService()->toApiArray($model); diff --git a/src/modules/Notification/Api/Admin.php b/src/modules/Notification/Api/Admin.php index 559f7dd5b..043484a97 100644 --- a/src/modules/Notification/Api/Admin.php +++ b/src/modules/Notification/Api/Admin.php @@ -39,7 +39,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function get($data) { @@ -50,7 +50,7 @@ class Admin extends \Api_Abstract $meta = $this->di['db']->load('extension_meta', $data['id']); if ($meta->extension != 'mod_notification' || $meta->meta_key != 'message') { - throw new \Box_Exception('Notification message was not found'); + throw new \FOSSBilling\Exception('Notification message was not found'); } return $this->getService()->toApiArray($meta); @@ -77,7 +77,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function delete($data) { @@ -88,7 +88,7 @@ class Admin extends \Api_Abstract $meta = $this->di['db']->load('extension_meta', $data['id']); if ($meta->extension != 'mod_notification' || $meta->meta_key != 'message') { - throw new \Box_Exception('Notification message was not found'); + throw new \FOSSBilling\Exception('Notification message was not found'); } $this->di['db']->trash($meta); @@ -100,7 +100,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function delete_all() { diff --git a/src/modules/Order/Api/Admin.php b/src/modules/Order/Api/Admin.php index b1aebc3d7..3f48b2b2d 100644 --- a/src/modules/Order/Api/Admin.php +++ b/src/modules/Order/Api/Admin.php @@ -163,7 +163,7 @@ class Admin extends \Api_Abstract { $order = $this->_getOrder($data); if ($order->status != \Model_ClientOrder::STATUS_SUSPENDED) { - throw new \Box_Exception('Only suspended orders can be unsuspended'); + throw new \FOSSBilling\InformationException('Only suspended orders can be unsuspended'); } return $this->getService()->unsuspendFromOrder($order); @@ -195,7 +195,7 @@ class Admin extends \Api_Abstract { $order = $this->_getOrder($data); if ($order->status != \Model_ClientOrder::STATUS_CANCELED) { - throw new \Box_Exception('Only canceled orders can be uncanceled'); + throw new \FOSSBilling\InformationException('Only canceled orders can be uncanceled'); } return $this->getService()->uncancelFromOrder($order); @@ -254,7 +254,7 @@ class Admin extends \Api_Abstract $order = $this->_getOrder($data); if (!isset($data['config']) || !is_array($data['config'])) { - throw new \Box_Exception('Order config not passed'); + throw new \FOSSBilling\Exception('Order config not passed'); } $config = $data['config']; diff --git a/src/modules/Order/Api/Client.php b/src/modules/Order/Api/Client.php index 4f6462787..481b4f271 100644 --- a/src/modules/Order/Api/Client.php +++ b/src/modules/Order/Api/Client.php @@ -103,7 +103,7 @@ class Client extends \Api_Abstract { $model = $this->_getOrder($data); if (!in_array($model->status, [\Model_ClientOrder::STATUS_PENDING_SETUP, \Model_ClientOrder::STATUS_FAILED_SETUP])) { - throw new \Box_Exception('Only pending and failed setup orders can be deleted.'); + throw new \FOSSBilling\InformationException('Only pending and failed setup orders can be deleted.'); } return $this->getService()->deleteFromOrder($model); @@ -118,7 +118,7 @@ class Client extends \Api_Abstract $order = $this->getService()->findForClientById($this->getIdentity(), $data['id']); if (!$order instanceof \Model_ClientOrder) { - throw new \Box_Exception('Order not found'); + throw new \FOSSBilling\Exception('Order not found'); } return $order; diff --git a/src/modules/Order/Service.php b/src/modules/Order/Service.php index 65aed621f..555acf9a7 100644 --- a/src/modules/Order/Service.php +++ b/src/modules/Order/Service.php @@ -495,7 +495,7 @@ class Service implements InjectionAwareInterface $currency = $currencyService->getDefault(); } if (!$currency instanceof \Model_Currency) { - throw new \Box_Exception('Currency could not be determined for order'); + throw new \FOSSBilling\Exception('Currency could not be determined for order'); } $this->di['events_manager']->fire(['event' => 'onBeforeAdminOrderCreate', 'params' => $data, 'subject' => $product->type]); @@ -511,19 +511,19 @@ class Service implements InjectionAwareInterface $cartService = $this->di['mod_service']('cart'); // check stock if (!$cartService->isStockAvailable($product, $qty)) { - throw new \Box_Exception('Product :id is out of stock.', [':id' => $product->id], 831); + throw new \FOSSBilling\InformationException('Product :id is out of stock.', [':id' => $product->id], 831); } // Addons must have defined master order $parent_order = false; if ($product->is_addon && empty($group_id)) { - throw new \Box_Exception('Group ID parameter is missing for addon product order', null, 832); + throw new \FOSSBilling\Exception('Group ID parameter is missing for addon product order', null, 832); } if (!empty($group_id)) { $parent_order = $this->getMasterOrderForClient($client, $group_id); if (!$parent_order instanceof \Model_ClientOrder) { - throw new \Box_Exception('Parent order :group_id was not found', [':group_id' => $group_id]); + throw new \FOSSBilling\Exception('Parent order :group_id was not found', [':group_id' => $group_id]); } } @@ -673,7 +673,7 @@ class Service implements InjectionAwareInterface ]; if (!in_array($order->status, $statues)) { if (!isset($data['force']) || !$data['force']) { - throw new \Box_Exception('Only pending setup or failed orders can be activated'); + throw new \FOSSBilling\Exception('Only pending setup or failed orders can be activated'); } } @@ -701,7 +701,7 @@ class Service implements InjectionAwareInterface if (method_exists($s, 'create') || method_exists($s, 'action_create')) { $service = $this->_callOnService($order, \Model_ClientOrder::ACTION_CREATE); if (!is_object($service)) { - throw new \Box_Exception('Error creating ' . $order->service_type . ' service for order ' . $order->id); + throw new \FOSSBilling\Exception('Error creating ' . $order->service_type . ' service for order ' . $order->id); } $order->service_id = $service->id; @@ -770,7 +770,7 @@ class Service implements InjectionAwareInterface if (in_array($order->service_type, $core_services)) { $m = 'action_' . $action; if (!method_exists($repo, $m) || !is_callable([$repo, $m])) { - throw new \Box_Exception('Service ' . $order->service_type . ' do not support ' . $m); + throw new \FOSSBilling\Exception('Service ' . $order->service_type . ' do not support ' . $m); } return $repo->$m($order); @@ -975,7 +975,7 @@ class Service implements InjectionAwareInterface } if ($order->status != \Model_ClientOrder::STATUS_ACTIVE) { - throw new \Box_Exception('Only active orders can be suspended'); + throw new \FOSSBilling\InformationException('Only active orders can be suspended'); } $this->_callOnService($order, \Model_ClientOrder::ACTION_SUSPEND); @@ -1027,7 +1027,7 @@ class Service implements InjectionAwareInterface } if (in_array($order->status, [\Model_ClientOrder::STATUS_CANCELED, \Model_ClientOrder::STATUS_PENDING_SETUP, \Model_ClientOrder::STATUS_FAILED_SETUP])) { - throw new \Box_Exception('Can not cancel ' . $order->status . ' order'); + throw new \FOSSBilling\Exception('Can not cancel ' . $order->status . ' order'); } $this->_callOnService($order, \Model_ClientOrder::ACTION_CANCEL); diff --git a/src/modules/Paidsupport/Service.php b/src/modules/Paidsupport/Service.php index d6dd0cbd7..5c0666841 100644 --- a/src/modules/Paidsupport/Service.php +++ b/src/modules/Paidsupport/Service.php @@ -120,7 +120,7 @@ class Service implements InjectionAwareInterface $clientBalance = $clientBalanceService->getClientBalance($client); if ($this->getTicketPrice() > $clientBalance) { - throw new \Box_Exception($this->getErrorMessage()); + throw new \FOSSBilling\Exception($this->getErrorMessage()); } return true; diff --git a/src/modules/Product/Api/Admin.php b/src/modules/Product/Api/Admin.php index a5aecdba2..4cf0237e1 100644 --- a/src/modules/Product/Api/Admin.php +++ b/src/modules/Product/Api/Admin.php @@ -78,7 +78,7 @@ class Admin extends \Api_Abstract * * @return int - new product id * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function prepare($data) { @@ -93,13 +93,13 @@ class Admin extends \Api_Abstract if ($data['type'] == 'domain') { $model = $service->getMainDomainProduct(); if ($model instanceof \Model_Product) { - throw new \Box_Exception('You have already created domain product.', null, 413); + throw new \FOSSBilling\InformationException('You have already created domain product.', null, 413); } } $types = $service->getTypes(); if (!array_key_exists($data['type'], $types)) { - throw new \Box_Exception('Product type :type is not registered', [':type' => $data['type']], 413); + throw new \FOSSBilling\Exception('Product type :type is not registered', [':type' => $data['type']], 413); } $categoryId = $data['product_category_id'] ?? null; @@ -128,7 +128,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function update($data) { @@ -143,12 +143,12 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function update_priority($data) { if (!isset($data['priority']) || !is_array($data['priority'])) { - throw new \Box_Exception('priority params is missing'); + throw new \FOSSBilling\Exception('priority params is missing'); } $service = $this->getService(); @@ -187,7 +187,7 @@ class Admin extends \Api_Abstract * * @return int - new addon id * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function addon_create($data) { @@ -212,7 +212,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function addon_get($data) { @@ -223,7 +223,7 @@ class Admin extends \Api_Abstract $model = $this->di['db']->load('Product', $data['id']); if (!$model instanceof \Model_Product || !$model->is_addon) { - throw new \Box_Exception('Addon not found'); + throw new \FOSSBilling\Exception('Addon not found'); } $service = $this->getService(); @@ -251,7 +251,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function addon_update($data) { @@ -262,7 +262,7 @@ class Admin extends \Api_Abstract $model = $this->di['db']->load('Product', $data['id']); if (!$model instanceof \Model_Product || !$model->is_addon) { - throw new \Box_Exception('Addon not found'); + throw new \FOSSBilling\Exception('Addon not found'); } $this->di['logger']->info('Updated addon #%s', $model->id); @@ -311,7 +311,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function category_update($data) { @@ -336,7 +336,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function category_get($data) { @@ -358,7 +358,7 @@ class Admin extends \Api_Abstract * * @return int - new category id * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function category_create($data) { @@ -381,7 +381,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function category_delete($data) { @@ -430,7 +430,7 @@ class Admin extends \Api_Abstract * * @return int - new promo code id * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function promo_create($data) { @@ -464,7 +464,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function promo_get($data) { @@ -497,7 +497,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function promo_update($data) { @@ -518,7 +518,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function promo_delete($data) { diff --git a/src/modules/Product/Api/Guest.php b/src/modules/Product/Api/Guest.php index 382352e0b..f0237ea2c 100644 --- a/src/modules/Product/Api/Guest.php +++ b/src/modules/Product/Api/Guest.php @@ -60,12 +60,12 @@ class Guest extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function get($data) { if (!isset($data['id']) && !isset($data['slug'])) { - throw new \Box_Exception('Product ID or slug is missing'); + throw new \FOSSBilling\Exception('Product ID or slug is missing'); } $id = $data['id'] ?? null; @@ -79,7 +79,7 @@ class Guest extends \Api_Abstract } if (!$model instanceof \Model_Product) { - throw new \Box_Exception('Product not found'); + throw new \FOSSBilling\Exception('Product not found'); } return $service->toApiArray($model); diff --git a/src/modules/Product/Service.php b/src/modules/Product/Service.php index fff5c87ed..ec7db07af 100644 --- a/src/modules/Product/Service.php +++ b/src/modules/Product/Service.php @@ -203,7 +203,7 @@ class Service implements InjectionAwareInterface $types = $this->getPaymentTypes(); if (!isset($data['pricing']['type']) || !array_key_exists($data['pricing']['type'], $types)) { - throw new \Box_Exception('Pricing type is required'); + throw new \FOSSBilling\InformationException('Pricing type is required'); } $productPayment = $this->di['db']->getExistingModelById('ProductPayment', $model->product_payment_id, 'Product payment not found'); @@ -414,7 +414,7 @@ class Service implements InjectionAwareInterface { $orderService = $this->di['mod_service']('order'); if ($orderService->productHasOrders($product)) { - throw new \Box_Exception('Can not remove product which has active orders.'); + throw new \FOSSBilling\InformationException('Can not remove product which has active orders.'); } $id = $product->id; $this->di['db']->trash($product); @@ -473,7 +473,7 @@ class Service implements InjectionAwareInterface { $model = $this->di['db']->findOne('Product', 'product_category_id = :category_id', [':category_id' => $category->id]); if ($model instanceof \Model_Product) { - throw new \Box_Exception('Can not remove product category with products'); + throw new \FOSSBilling\InformationException('Can not remove product category with products'); } $id = $category->id; $this->di['db']->trash($category); @@ -877,7 +877,7 @@ class Service implements InjectionAwareInterface public function createPromo($code, $type, $value, $products, $periods, $clientGroups, $data) { if ($this->di['db']->findOne('Promo', 'code = :code', [':code' => $code])) { - throw new \Box_Exception('This promotion code already exists.'); + throw new \FOSSBilling\InformationException('This promotion code already exists.'); } $systemService = $this->di['mod_service']('system'); diff --git a/src/modules/Profile/Api/Admin.php b/src/modules/Profile/Api/Admin.php index 659185a43..15629d4a7 100644 --- a/src/modules/Profile/Api/Admin.php +++ b/src/modules/Profile/Api/Admin.php @@ -67,7 +67,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function update($data) { @@ -93,7 +93,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function change_password($data) { @@ -107,13 +107,13 @@ class Admin extends \Api_Abstract $validator->isPasswordStrong($data['new_password']); if ($data['new_password'] != $data['confirm_password']) { - throw new \Exception('Passwords do not match'); + throw new \FOSSBilling\InformationException('Passwords do not match'); } $staff = $this->getIdentity(); if (!$this->di['password']->verify($data['current_password'], $staff->pass)) { - throw new \Exception('Current password incorrect'); + throw new \FOSSBilling\InformationException('Current password incorrect'); } $this->getService()->invalidateSessions(); diff --git a/src/modules/Profile/Api/Client.php b/src/modules/Profile/Api/Client.php index 06ddf237b..4678f2ff3 100644 --- a/src/modules/Profile/Api/Client.php +++ b/src/modules/Profile/Api/Client.php @@ -63,7 +63,7 @@ class Client extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function update($data) { @@ -97,7 +97,7 @@ class Client extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function change_password($data) { @@ -110,13 +110,13 @@ class Client extends \Api_Abstract $this->di['validator']->isPasswordStrong($data['new_password']); if ($data['new_password'] != $data['confirm_password']) { - throw new \Exception('Passwords do not match'); + throw new \FOSSBilling\InformationException('Passwords do not match'); } $client = $this->getIdentity(); if (!$this->di['password']->verify($data['current_password'], $client->pass)) { - throw new \Exception('Current password incorrect'); + throw new \FOSSBilling\InformationException('Current password incorrect'); } $this->getService()->invalidateSessions(); diff --git a/src/modules/Profile/Service.php b/src/modules/Profile/Service.php index 6efd115b7..6d8d2a4ea 100644 --- a/src/modules/Profile/Service.php +++ b/src/modules/Profile/Service.php @@ -114,7 +114,7 @@ class Service implements InjectionAwareInterface && isset($config['disable_change_email']) && $config['disable_change_email'] ) { - throw new \Box_Exception('Email can not be changed'); + throw new \FOSSBilling\InformationException('Email can not be changed'); } if (!empty($email)) { @@ -122,7 +122,7 @@ class Service implements InjectionAwareInterface $clientService = $this->di['mod_service']('client'); if ($clientService->emailAlreadyRegistered($email, $client)) { - throw new \Box_Exception('Can not change email. It is already registered.'); + throw new \FOSSBilling\InformationException('Can not change email. It is already registered.'); } $client->email = $email; @@ -134,7 +134,7 @@ class Service implements InjectionAwareInterface $birthday = $data['birthday'] ?? null; if (strlen(trim($birthday)) > 0 && strtotime($birthday) === false) { - throw new \Box_Exception('Invalid birthdate value'); + throw new \FOSSBilling\InformationException('Invalid birthdate value'); } $client->birthday = $birthday; @@ -226,7 +226,7 @@ class Service implements InjectionAwareInterface } elseif ($auth->isClientLoggedIn()) { $type = 'client'; } else { - throw new \Box_Exception('Unable to invalidate sessions, nobody is logged in'); + throw new \FOSSBilling\Exception('Unable to invalidate sessions, nobody is logged in'); } } @@ -245,7 +245,7 @@ class Service implements InjectionAwareInterface } if ($type !== 'admin' && $type !== 'client') { - throw new \Box_Exception('Unable to invalidate sessions, an invalid type was used'); + throw new \FOSSBilling\Exception('Unable to invalidate sessions, an invalid type was used'); } $sessions = $this->getSessions(); diff --git a/src/modules/Queue/Api/Admin.php b/src/modules/Queue/Api/Admin.php index db3c0446f..b84cfe1f3 100644 --- a/src/modules/Queue/Api/Admin.php +++ b/src/modules/Queue/Api/Admin.php @@ -93,7 +93,7 @@ class Admin extends \Api_Abstract $service = $mod->getService(); $handler = $data['handler'] ?? $data['queue']; if (!method_exists($service, $handler)) { - throw new \Box_Exception('Message handler function :method does not exists', [':ext' => $data['mod'], ':method' => $service::class . ':' . $handler]); + throw new \FOSSBilling\Exception('Message handler function :method does not exists', [':ext' => $data['mod'], ':method' => $service::class . ':' . $handler]); } $interval = isset($data['interval']) ? (int) $data['interval'] : 30; diff --git a/src/modules/Redirect/Api/Admin.php b/src/modules/Redirect/Api/Admin.php index eac2cef4b..656b275d6 100644 --- a/src/modules/Redirect/Api/Admin.php +++ b/src/modules/Redirect/Api/Admin.php @@ -128,7 +128,7 @@ class Admin extends \Api_Abstract $bean = $this->di['db']->findOne('extension_meta', $sql, $values); if (!$bean) { - throw new \Box_Exception('Redirect not found'); + throw new \FOSSBilling\Exception('Redirect not found'); } return $bean; diff --git a/src/modules/Serviceapikey/Service.php b/src/modules/Serviceapikey/Service.php index c4195c14d..11e7cfbfe 100644 --- a/src/modules/Serviceapikey/Service.php +++ b/src/modules/Serviceapikey/Service.php @@ -51,7 +51,7 @@ class Service implements InjectionAwareInterface { $config = json_decode($order->config, 1); if (!is_object($model)) { - throw new \Box_Exception('Order does not exist.'); + throw new \FOSSBilling\Exception('Order does not exist.'); } $model->api_key = $this->generateKey($config); @@ -113,12 +113,12 @@ class Service implements InjectionAwareInterface public function isValid(array $data): bool { if (empty($data['key'])) { - throw new \Box_Exception('You must provide an API key to check it\'s validity.'); + throw new \FOSSBilling\Exception('You must provide an API key to check it\'s validity.'); } $model = $this->di['db']->findOne('service_apikey', 'api_key = :api_key', [':api_key' => $data['key']]); if (is_null($model)) { - throw new \Box_Exception('API key does not exist'); + throw new \FOSSBilling\Exception('API key does not exist'); } return $this->isActive($model); @@ -132,12 +132,12 @@ class Service implements InjectionAwareInterface public function getInfo(array $data): array { if (empty($data['key'])) { - throw new \Box_Exception('You must provide an API key to check it\'s validity.'); + throw new \FOSSBilling\Exception('You must provide an API key to check it\'s validity.'); } $model = $this->di['db']->findOne('service_apikey', 'api_key = :api_key', [':api_key' => $data['key']]); if (is_null($model)) { - throw new \Box_Exception('API key does not exist'); + throw new \FOSSBilling\Exception('API key does not exist'); } // Load the stored JSON config from the DB @@ -177,7 +177,7 @@ class Service implements InjectionAwareInterface public function resetApiKey(array $data): bool { if (empty($data['key']) && empty($data['order_id'])) { - throw new \Box_Exception('You must provide either the API key or API key order ID in order to reset it.'); + throw new \FOSSBilling\Exception('You must provide either the API key or API key order ID in order to reset it.'); } elseif (!empty($data['order_id'])) { $order = $this->di['db']->getExistingModelById('ClientOrder', $data['order_id'], 'Order not found'); $orderService = $this->di['mod_service']('order'); @@ -187,7 +187,7 @@ class Service implements InjectionAwareInterface } if (is_null($model)) { - throw new \Box_Exception('API key does not exist'); + throw new \FOSSBilling\Exception('API key does not exist'); } try { @@ -198,7 +198,7 @@ class Service implements InjectionAwareInterface } if (!is_null($client) && $client->id !== $model->client_id) { - throw new \Box_Exception('API key does not exist'); + throw new \FOSSBilling\Exception('API key does not exist'); } $config = json_decode($model->config, true); @@ -220,7 +220,7 @@ class Service implements InjectionAwareInterface public function updateApiKey(array $data): bool { if (empty($data['order_id'])) { - throw new \Box_Exception('You must provide the API key order ID in order to update it.'); + throw new \FOSSBilling\Exception('You must provide the API key order ID in order to update it.'); } $order = $this->di['db']->getExistingModelById('ClientOrder', $data['order_id'], 'Order not found'); @@ -228,11 +228,11 @@ class Service implements InjectionAwareInterface $model = $orderService->getOrderService($order); if (is_null($model)) { - throw new \Box_Exception('API key does not exist'); + throw new \FOSSBilling\Exception('API key does not exist'); } if (isset($data['api_key']) && $model->api_key !== $data['api_key']) { - throw new \Box_Exception('To change the API key, please use the reset function rather than updating it.'); + throw new \FOSSBilling\Exception('To change the API key, please use the reset function rather than updating it.'); } $config = !empty($data['config']) ? json_encode($data['config']) : $model->config; @@ -295,7 +295,7 @@ class Service implements InjectionAwareInterface do { // Try 10 times to generate a unique API key. Fail if we are unable to. if ($i++ >= 10) { - throw new \Box_Exception('Maximum number of iterations reached while generating API key'); + throw new \FOSSBilling\Exception('Maximum number of iterations reached while generating API key'); } // Generate random bytes half the length of the configured length, as the length will doubled when converted to a hex string. @@ -330,7 +330,7 @@ class Service implements InjectionAwareInterface break; default: - throw new \Box_Exception("Unknown uppercase option ':case:'. API generator only accepts 'lower', 'upper', or 'mixed'.", [':case:' => $case]); + throw new \FOSSBilling\Exception("Unknown uppercase option ':case:'. API generator only accepts 'lower', 'upper', or 'mixed'.", [':case:' => $case]); } } while ($this->di['db']->findOne('service_apikey', 'api_key = :api_key', [':api_key' => $apiKey]) !== null); @@ -341,7 +341,7 @@ class Service implements InjectionAwareInterface { $order = $this->di['db']->findOne('ClientOrder', 'service_id = :id AND service_type = "apikey"', [':id' => $model->id]); if (is_null($order)) { - throw new \Box_Exception('API key does not exist'); + throw new \FOSSBilling\Exception('API key does not exist'); } return $order->status === 'active'; diff --git a/src/modules/Servicecustom/Api/Admin.php b/src/modules/Servicecustom/Api/Admin.php index 486f9b896..34d846590 100644 --- a/src/modules/Servicecustom/Api/Admin.php +++ b/src/modules/Servicecustom/Api/Admin.php @@ -23,7 +23,7 @@ class Admin extends \Api_Abstract public function update($data) { if (!isset($data['order_id'])) { - throw new \Box_Exception('Order id is required'); + throw new \FOSSBilling\Exception('Order id is required'); } if (isset($data['config']) && is_array($data['config'])) { @@ -37,18 +37,18 @@ class Admin extends \Api_Abstract * Universal method to call method from plugin * Pass any other params and they will be passed to plugin. * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function __call($name, $arguments) { if (!isset($arguments[0])) { - throw new \Box_Exception('API call is missing arguments', null, 7103); + throw new \FOSSBilling\Exception('API call is missing arguments', null, 7103); } $data = $arguments[0]; if (!isset($data['order_id'])) { - throw new \Box_Exception('Order id is required'); + throw new \FOSSBilling\Exception('Order id is required'); } $model = $this->getService()->getServiceCustomByOrderId($data['order_id']); diff --git a/src/modules/Servicecustom/Api/Client.php b/src/modules/Servicecustom/Api/Client.php index 5fa94ed3c..d8a10904f 100644 --- a/src/modules/Servicecustom/Api/Client.php +++ b/src/modules/Servicecustom/Api/Client.php @@ -19,18 +19,18 @@ class Client extends \Api_Abstract * Universal method to call method from plugin * Pass any other params and they will be passed to plugin. * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function __call($name, $arguments) { if (!isset($arguments[0])) { - throw new \Box_Exception('API call is missing arguments', null, 7103); + throw new \FOSSBilling\Exception('API call is missing arguments', null, 7103); } $data = $arguments[0]; if (!isset($data['order_id'])) { - throw new \Box_Exception('Order id is required'); + throw new \FOSSBilling\Exception('Order id is required'); } $model = $this->getService()->getServiceCustomByOrderId($data['order_id']); diff --git a/src/modules/Servicecustom/Service.php b/src/modules/Servicecustom/Service.php index cb182b48d..51808aa2b 100644 --- a/src/modules/Servicecustom/Service.php +++ b/src/modules/Servicecustom/Service.php @@ -35,14 +35,14 @@ class Service implements \FOSSBilling\InjectionAwareInterface if ($field['required'] == 1) { $field_name = $field['name']; if (!isset($data[$field_name]) || empty($data[$field_name])) { - throw new \Box_Exception('You must fill in all required fields. ' . $field['label'] . ' is missing', null, 9684); + throw new \FOSSBilling\InformationException('You must fill in all required fields. ' . $field['label'] . ' is missing', null, 9684); } } if ($field['readonly'] == 1) { $field_name = $field['name']; if ($data[$field_name] != $field['default_value']) { - throw new \Box_Exception('Field ' . $field['label'] . ' is read only. You can not change its value', null, 5468); + throw new \FOSSBilling\InformationException('Field ' . $field['label'] . ' is read only. You can not change its value', null, 5468); } } } @@ -76,7 +76,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface $orderService = $this->di['mod_service']('order'); $model = $orderService->getOrderService($order); if (!$model instanceof \RedBeanPHP\SimpleModel) { - throw new \Box_Exception('Could not activate order. Service was not created', null, 7456); + throw new \FOSSBilling\Exception('Could not activate order. Service was not created', null, 7456); } $this->callOnAdapter($model, 'activate'); @@ -216,7 +216,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface 'activate', ]; if (in_array($method, $forbidden_methods)) { - throw new \Box_Exception('Custom plugin method :method is forbidden', [':method' => $method], 403); + throw new \FOSSBilling\Exception('Custom plugin method :method is forbidden', [':method' => $method], 403); } return $this->callOnAdapter($model, $method, $params); @@ -225,7 +225,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface public function updateConfig($orderId, $config) { if (!is_array($config)) { - throw new \Box_Exception('Config must be an array'); + throw new \FOSSBilling\Exception('Config must be an array'); } $model = $this->getServiceCustomByOrderId($orderId); @@ -245,7 +245,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface $s = $orderService->getOrderService($order); if (!$s instanceof \Model_ServiceCustom) { - throw new \Box_Exception('Order is not activated'); + throw new \FOSSBilling\Exception('Order is not activated'); } return $s; @@ -262,7 +262,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface // check if plugin exists. If plugin does not exist, do not throw error. Simply add to log $file = sprintf('Plugin/%s/%s.php', $plugin, $plugin); if (!Environment::isTesting() && !file_exists(PATH_LIBRARY . DIRECTORY_SEPARATOR . $file)) { - $e = new \Box_Exception('Plugin class file :file was not found', [':file' => $file], 3124); + $e = new \FOSSBilling\Exception('Plugin class file :file was not found', [':file' => $file], 3124); if (BB_DEBUG) { error_log($e->getMessage()); } @@ -276,7 +276,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface $adapter = new $plugin($config); if (!method_exists($adapter, $method)) { - throw new \Box_Exception('Plugin :plugin does not support action :action', [':plugin' => $plugin, ':action' => $method], 3125); + throw new \FOSSBilling\Exception('Plugin :plugin does not support action :action', [':plugin' => $plugin, ':action' => $method], 3125); } $orderService = $this->di['mod_service']('order'); @@ -292,7 +292,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface $orderService = $this->di['mod_service']('order'); $model = $orderService->getOrderService($order); if (!$model instanceof \RedBeanPHP\SimpleModel) { - throw new \Box_Exception('Order :id has no active service', [':id' => $order->id]); + throw new \FOSSBilling\Exception('Order :id has no active service', [':id' => $order->id]); } return $model; diff --git a/src/modules/Servicedomain/Api/Admin.php b/src/modules/Servicedomain/Api/Admin.php index a53016258..68aff7869 100644 --- a/src/modules/Servicedomain/Api/Admin.php +++ b/src/modules/Servicedomain/Api/Admin.php @@ -148,7 +148,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function tld_get($data) { @@ -164,7 +164,7 @@ class Admin extends \Api_Abstract $model = $this->getService()->tldFindOneByTld($tld); if (!$model instanceof \Model_Tld) { - throw new \Box_Exception('TLD not found'); + throw new \FOSSBilling\Exception('TLD not found'); } return $this->getService()->tldToApiArray($model); @@ -175,7 +175,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function tld_get_id($data) { @@ -186,7 +186,7 @@ class Admin extends \Api_Abstract $model = $this->getService()->tldFindOneById($data['id']); if (!$model instanceof \Model_Tld) { - throw new \Box_Exception('ID not found'); + throw new \FOSSBilling\Exception('ID not found'); } return $this->getService()->tldToApiArray($model); @@ -197,7 +197,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function tld_delete($data) { @@ -209,13 +209,13 @@ class Admin extends \Api_Abstract $model = $this->getService()->tldFindOneByTld($data['tld']); if (!$model instanceof \Model_Tld) { - throw new \Box_Exception('TLD not found'); + throw new \FOSSBilling\Exception('TLD not found'); } // check if tld is used by any domain $service_domains = $this->di['db']->find('ServiceDomain', 'tld = ?', ['tld' => $model->tld]); $count = is_countable($service_domains) ? count($service_domains) : 0; if ($count > 0) { - throw new \Box_Exception('TLD is used by :count: domains', [':count:' => $count], 707); + throw new \FOSSBilling\InformationException('TLD is used by :count: domains', [':count:' => $count], 707); } return $this->getService()->tldRm($model); @@ -226,7 +226,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function tld_create($data) { @@ -240,7 +240,7 @@ class Admin extends \Api_Abstract $this->di['validator']->checkRequiredParamsForArray($required, $data); if ($this->getService()->tldAlreadyRegistered($data['tld'])) { - throw new \Box_Exception('Tld already registered'); + throw new \FOSSBilling\InformationException('Tld already registered'); } return $this->getService()->tldCreate($data); @@ -256,7 +256,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function tld_update($data) { @@ -267,7 +267,7 @@ class Admin extends \Api_Abstract $model = $this->getService()->tldFindOneByTld($data['tld']); if (!$model instanceof \Model_Tld) { - throw new \Box_Exception('TLD not found'); + throw new \FOSSBilling\Exception('TLD not found'); } return $this->getService()->tldUpdate($model, $data); @@ -330,7 +330,7 @@ class Admin extends \Api_Abstract $code = $data['code']; if (!in_array($code, $this->getService()->registrarGetAvailable())) { - throw new \Box_Exception('Registrar is not available for installation.'); + throw new \FOSSBilling\Exception('Registrar is not available for installation.'); } return $this->getService()->registrarCreate($data['code']); @@ -357,7 +357,7 @@ class Admin extends \Api_Abstract $count = is_array($service_domains) ? count($service_domains) : 0; // Handle the case where $service_domains might be null if ($count > 0) { - throw new \Box_Exception('Registrar is used by :count: domains', [':count:' => $count], 707); + throw new \FOSSBilling\InformationException('Registrar is used by :count: domains', [':count:' => $count], 707); } return $this->getService()->registrarRm($model); @@ -443,7 +443,7 @@ class Admin extends \Api_Abstract $s = $orderService->getOrderService($order); if (!$s instanceof \Model_ServiceDomain) { - throw new \Box_Exception('Domain order is not activated'); + throw new \FOSSBilling\Exception('Domain order is not activated'); } return $s; diff --git a/src/modules/Servicedomain/Api/Client.php b/src/modules/Servicedomain/Api/Client.php index 3338f5191..18797a487 100644 --- a/src/modules/Servicedomain/Api/Client.php +++ b/src/modules/Servicedomain/Api/Client.php @@ -113,18 +113,18 @@ class Client extends \Api_Abstract protected function _getService($data) { if (!isset($data['order_id'])) { - throw new \Box_Exception('Order id is required'); + throw new \FOSSBilling\Exception('Order id is required'); } $orderService = $this->di['mod_service']('order'); $order = $orderService->findForClientById($this->getIdentity(), $data['order_id']); if (!$order instanceof \Model_ClientOrder) { - throw new \Box_Exception('Order not found'); + throw new \FOSSBilling\Exception('Order not found'); } $s = $orderService->getOrderService($order); if (!$s instanceof \Model_ServiceDomain) { - throw new \Box_Exception('Order is not activated'); + throw new \FOSSBilling\Exception('Order is not activated'); } return $s; diff --git a/src/modules/Servicedomain/Api/Guest.php b/src/modules/Servicedomain/Api/Guest.php index a436f298c..9ffe4149c 100644 --- a/src/modules/Servicedomain/Api/Guest.php +++ b/src/modules/Servicedomain/Api/Guest.php @@ -64,7 +64,7 @@ class Guest extends \Api_Abstract $model = $this->getService()->tldFindOneByTld($data['tld']); if (!$model instanceof \Model_Tld) { - throw new \Box_Exception('TLD not found'); + throw new \FOSSBilling\Exception('TLD not found'); } return $this->getService()->tldToApiArray($model); @@ -87,16 +87,16 @@ class Guest extends \Api_Abstract $sld = htmlspecialchars($data['sld'], ENT_QUOTES | ENT_HTML5, 'UTF-8'); $validator = $this->di['validator']; if (!$validator->isSldValid($sld)) { - throw new \Box_Exception('Domain :domain is invalid', [':domain' => $sld]); + throw new \FOSSBilling\InformationException('Domain :domain is invalid', [':domain' => $sld]); } $tld = $this->getService()->tldFindOneByTld($data['tld']); if (!$tld instanceof \Model_Tld) { - throw new \Box_Exception('Domain availability could not be determined. TLD is not active.'); + throw new \FOSSBilling\InformationException('Domain availability could not be determined. TLD is not active.'); } if (!$this->getService()->isDomainAvailable($tld, $sld)) { - throw new \Box_Exception('Domain is not available.'); + throw new \FOSSBilling\InformationException('Domain is not available.'); } return true; @@ -118,10 +118,10 @@ class Guest extends \Api_Abstract $tld = $this->getService()->tldFindOneByTld($data['tld']); if (!$tld instanceof \Model_Tld) { - throw new \Box_Exception('TLD is not active.'); + throw new \FOSSBilling\InformationException('TLD is not active.'); } if (!$this->getService()->canBeTransferred($tld, $data['sld'])) { - throw new \Box_Exception('Domain can not be transferred.'); + throw new \FOSSBilling\InformationException('Domain can not be transferred.'); } return true; diff --git a/src/modules/Servicedomain/Service.php b/src/modules/Servicedomain/Service.php index fe4577911..c70a09563 100644 --- a/src/modules/Servicedomain/Service.php +++ b/src/modules/Servicedomain/Service.php @@ -52,18 +52,18 @@ class Service implements \FOSSBilling\InjectionAwareInterface $action = $data['action']; if (!in_array($action, ['register', 'transfer', 'owndomain'])) { - throw new \Box_Exception('Invalid domain action.'); + throw new \FOSSBilling\Exception('Invalid domain action.'); } if ($action == 'owndomain') { if (!isset($data['owndomain_sld'])) { - throw new \Box_Exception('Order data must contain :field configuration field', [':field' => 'owndomain_sld']); + throw new \FOSSBilling\Exception('Order data must contain :field configuration field', [':field' => 'owndomain_sld']); } if (!$validator->isSldValid($data['owndomain_sld'])) { $safe_dom = htmlspecialchars($data['owndomain_sld'], ENT_QUOTES | ENT_HTML5, 'UTF-8'); - throw new \Box_Exception('Domain name :domain is invalid', [':domain' => $safe_dom]); + throw new \FOSSBilling\InformationException('Domain name :domain is invalid', [':domain' => $safe_dom]); } $required = [ @@ -75,13 +75,13 @@ class Service implements \FOSSBilling\InjectionAwareInterface if ($action == 'transfer') { if (!isset($data['transfer_sld'])) { - throw new \Box_Exception('Order data must contain :field configuration field', [':field' => 'transfer_sld']); + throw new \FOSSBilling\InformationException('Order data must contain :field configuration field', [':field' => 'transfer_sld']); } if (!$validator->isSldValid($data['transfer_sld'])) { $safe_dom = htmlspecialchars($data['transfer_sld'], ENT_QUOTES | ENT_HTML5, 'UTF-8'); - throw new \Box_Exception('Domain name :domain is invalid', [':domain' => $safe_dom]); + throw new \FOSSBilling\InformationException('Domain name :domain is invalid', [':domain' => $safe_dom]); } $required = [ @@ -92,12 +92,12 @@ class Service implements \FOSSBilling\InjectionAwareInterface $tld = $this->tldFindOneByTld($data['transfer_tld']); if (!$tld instanceof \Model_Tld) { - throw new \Box_Exception('TLD not found'); + throw new \FOSSBilling\Exception('TLD not found'); } $domain = $data['transfer_sld'] . $tld->tld; if (!$this->canBeTransferred($tld, $data['transfer_sld'])) { - throw new \Box_Exception(':domain can not be transferred!', [':domain' => $domain]); + throw new \FOSSBilling\InformationException(':domain can not be transferred!', [':domain' => $domain]); } // return by reference @@ -107,13 +107,13 @@ class Service implements \FOSSBilling\InjectionAwareInterface if ($action == 'register') { if (!isset($data['register_sld'])) { - throw new \Box_Exception('Order data must contain :field configuration field', [':field' => 'register_sld']); + throw new \FOSSBilling\InformationException('Order data must contain :field configuration field', [':field' => 'register_sld']); } if (!$validator->isSldValid($data['register_sld'])) { $safe_dom = htmlspecialchars($data['register_sld'], ENT_QUOTES | ENT_HTML5, 'UTF-8'); - throw new \Box_Exception('Domain name :domain is invalid', [':domain' => $safe_dom]); + throw new \FOSSBilling\InformationException('Domain name :domain is invalid', [':domain' => $safe_dom]); } $required = [ @@ -125,17 +125,17 @@ class Service implements \FOSSBilling\InjectionAwareInterface $tld = $this->tldFindOneByTld($data['register_tld']); if (!$tld instanceof \Model_Tld) { - throw new \Box_Exception('TLD not found'); + throw new \FOSSBilling\Exception('TLD not found'); } $years = (int) $data['register_years']; if ($years < $tld->min_years) { - throw new \Box_Exception(':tld can be registered for at least :years years', [':tld' => $tld->tld, ':years' => $tld->min_years]); + throw new \FOSSBilling\Exception(':tld can be registered for at least :years years', [':tld' => $tld->tld, ':years' => $tld->min_years]); } $domain = $data['register_sld'] . $tld->tld; if (!$this->isDomainAvailable($tld, $data['register_sld'])) { - throw new \Box_Exception(':domain is already registered!', [':domain' => $domain]); + throw new \FOSSBilling\InformationException(':domain is already registered!', [':domain' => $domain]); } // return by reference @@ -163,7 +163,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface $systemService = $this->di['mod_service']('system'); $ns = $systemService->getNameservers(); if (empty($ns)) { - throw new \Box_Exception('Default domain nameservers are not configured'); + throw new \FOSSBilling\InformationException('Default domain nameservers are not configured'); } $tldModel = $this->tldFindOneByTld($tld); @@ -215,7 +215,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface $orderService = $this->di['mod_service']('order'); $model = $orderService->getOrderService($order); if (!$model instanceof \Model_ServiceDomain) { - throw new \Box_Exception('Could not activate order. Service was not created'); + throw new \FOSSBilling\Exception('Could not activate order. Service was not created'); } // @adapterAction @@ -249,7 +249,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface $orderService = $this->di['mod_service']('order'); $model = $orderService->getOrderService($order); if (!$model instanceof \RedBeanPHP\SimpleModel) { - throw new \Box_Exception('Order :id has no active service', [':id' => $order->id]); + throw new \FOSSBilling\Exception('Order :id has no active service', [':id' => $order->id]); } // @adapterAction [$domain, $adapter] = $this->_getD($model); @@ -288,7 +288,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface $orderService = $this->di['mod_service']('order'); $model = $orderService->getOrderService($order); if (!$model instanceof \RedBeanPHP\SimpleModel) { - throw new \Box_Exception('Order :id has no active service', [':id' => $order->id]); + throw new \FOSSBilling\Exception('Order :id has no active service', [':id' => $order->id]); } // @adapterAction [$domain, $adapter] = $this->_getD($model); @@ -364,10 +364,10 @@ class Service implements \FOSSBilling\InjectionAwareInterface public function updateNameservers(\Model_ServiceDomain $model, $data) { if (!isset($data['ns1'])) { - throw new \Box_Exception('Nameserver 1 is required'); + throw new \FOSSBilling\InformationException('Nameserver 1 is required'); } if (!isset($data['ns2'])) { - throw new \Box_Exception('Nameserver 2 is required'); + throw new \FOSSBilling\InformationException('Nameserver 2 is required'); } $ns1 = $data['ns1']; @@ -521,11 +521,11 @@ class Service implements \FOSSBilling\InjectionAwareInterface public function canBeTransferred(\Model_Tld $model, $sld) { if (empty($sld)) { - throw new \Box_Exception('Domain name is invalid'); + throw new \FOSSBilling\InformationException('Domain name is invalid'); } if (!$model->allow_transfer) { - throw new \Box_Exception('Domain can not be transferred', null, 403); + throw new \FOSSBilling\InformationException('Domain can not be transferred', null, 403); } // @adapterAction @@ -542,18 +542,18 @@ class Service implements \FOSSBilling\InjectionAwareInterface public function isDomainAvailable(\Model_Tld $model, $sld) { if (empty($sld)) { - throw new \Box_Exception('Domain name is invalid'); + throw new \FOSSBilling\InformationException('Domain name is invalid'); } $validator = $this->di['validator']; if (!$validator->isSldValid($sld)) { $safe_dom = htmlspecialchars($sld, ENT_QUOTES | ENT_HTML5, 'UTF-8'); - throw new \Box_Exception('Domain name :domain is invalid', [':domain' => $safe_dom]); + throw new \FOSSBilling\InformationException('Domain name :domain is invalid', [':domain' => $safe_dom]); } if (!$model->allow_register) { - throw new \Box_Exception('Domain can not be registered', null, 403); + throw new \FOSSBilling\InformationException('Domain can not be registered', null, 403); } // @adapterAction @@ -945,12 +945,12 @@ class Service implements \FOSSBilling\InjectionAwareInterface private function registrarGetRegistrarAdapterClassName(\Model_TldRegistrar $model) { if (!file_exists(PATH_LIBRARY . '/Registrar/Adapter/' . $model->registrar . '.php')) { - throw new \Box_Exception('Domain registrar :adapter was not found', [':adapter' => $model->registrar]); + throw new \FOSSBilling\Exception('Domain registrar :adapter was not found', [':adapter' => $model->registrar]); } $class = sprintf('Registrar_Adapter_%s', $model->registrar); if (!class_exists($class)) { - throw new \Box_Exception('Registrar :adapter was not found', [':adapter' => $class]); + throw new \FOSSBilling\Exception('Registrar :adapter was not found', [':adapter' => $class]); } return $class; @@ -962,7 +962,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface $class = $this->registrarGetRegistrarAdapterClassName($r); $registrar = new $class($config); if (!$registrar instanceof \Registrar_AdapterAbstract) { - throw new \Box_Exception('Registrar adapter :adapter should extend Registrar_AdapterAbstract', [':adapter' => $class]); + throw new \FOSSBilling\Exception('Registrar adapter :adapter should extend Registrar_AdapterAbstract', [':adapter' => $class]); } $registrar->setLog($this->di['logger']); @@ -1025,7 +1025,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface { $domains = $this->di['db']->find('ServiceDomain', 'tld_registrar_id = :registrar_id', [':registrar_id' => $model->id]); if ((is_countable($domains) ? count($domains) : 0) > 0) { - throw new \Box_Exception('Can not remove registrar which has domains'); + throw new \FOSSBilling\InformationException('Can not remove registrar which has domains'); } $name = $model->name; diff --git a/src/modules/Servicedownloadable/Api/Admin.php b/src/modules/Servicedownloadable/Api/Admin.php index e2d369288..ccf404367 100644 --- a/src/modules/Servicedownloadable/Api/Admin.php +++ b/src/modules/Servicedownloadable/Api/Admin.php @@ -32,7 +32,7 @@ class Admin extends \Api_Abstract $model = $this->di['db']->getExistingModelById('Product', $data['id'], 'Product not found'); if (!isset($_FILES['file_data'])) { - throw new \Box_Exception('File was not uploaded'); + throw new \FOSSBilling\Exception('File was not uploaded'); } $service = $this->getService(); @@ -61,7 +61,7 @@ class Admin extends \Api_Abstract $orderService = $this->di['mod_service']('order'); $serviceDownloadable = $orderService->getOrderService($order); if (!$serviceDownloadable instanceof \Model_ServiceDownloadable) { - throw new \Box_Exception('Order is not activated'); + throw new \FOSSBilling\Exception('Order is not activated'); } $service = $this->getService(); diff --git a/src/modules/Servicedownloadable/Api/Client.php b/src/modules/Servicedownloadable/Api/Client.php index e1616a7c8..eec670e63 100644 --- a/src/modules/Servicedownloadable/Api/Client.php +++ b/src/modules/Servicedownloadable/Api/Client.php @@ -24,18 +24,18 @@ class Client extends \Api_Abstract public function send_file($data) { if (!isset($data['order_id'])) { - throw new \Box_Exception('Order id is required'); + throw new \FOSSBilling\Exception('Order id is required'); } $identity = $this->getIdentity(); $order = $this->di['db']->findOne('ClientOrder', 'id = :id AND client_id = :client_id', [':id' => $data['order_id'], ':client_id' => $identity->id]); if (!$order instanceof \Model_ClientOrder) { - throw new \Box_Exception('Order not found'); + throw new \FOSSBilling\Exception('Order not found'); } $orderService = $this->di['mod_service']('order'); $s = $orderService->getOrderService($order); if (!$s instanceof \Model_ServiceDownloadable || $order->status !== 'active') { - throw new \Box_Exception('Order is not activated'); + throw new \FOSSBilling\Exception('Order is not activated'); } $service = $this->getService(); diff --git a/src/modules/Servicedownloadable/Service.php b/src/modules/Servicedownloadable/Service.php index 3477a5252..3d6b5cf33 100644 --- a/src/modules/Servicedownloadable/Service.php +++ b/src/modules/Servicedownloadable/Service.php @@ -56,7 +56,7 @@ class Service implements InjectionAwareInterface { $c = json_decode($order->config, 1); if (!is_array($c)) { - throw new \Box_Exception(sprintf('Order #%s config is missing', $order->id)); + throw new \FOSSBilling\Exception(sprintf('Order #%s config is missing', $order->id)); } $this->validateOrderData($c); @@ -166,7 +166,7 @@ class Service implements InjectionAwareInterface { $request = $this->di['request']; if ($request->hasFiles() == 0) { - throw new \Box_Exception('Error uploading file'); + throw new \FOSSBilling\Exception('Error uploading file'); } $files = $request->getUploadedFiles(); $file = $files[0]; @@ -213,13 +213,13 @@ class Service implements InjectionAwareInterface /** * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function updateProductFile(\Model_ServiceDownloadable $serviceDownloadable, \Model_ClientOrder $order) { $request = $this->di['request']; if ($request->hasFiles() == 0) { - throw new \Box_Exception('Error uploading file'); + throw new \FOSSBilling\Exception('Error uploading file'); } $productService = $this->di['mod_service']('product'); $files = $request->getUploadedFiles(); @@ -272,7 +272,7 @@ class Service implements InjectionAwareInterface $filename = $info['filename']; $path = $info['path']; if (!file_exists($path)) { - throw new \Box_Exception('File can not be downloaded at the moment. Please contact support', null, 404); + throw new \FOSSBilling\Exception('File can not be downloaded at the moment. Please contact support', null, 404); } $this->hitDownload($serviceDownloadable); $this->sendDownload($filename, $path); diff --git a/src/modules/Servicehosting/Api/Admin.php b/src/modules/Servicehosting/Api/Admin.php index e2101fae6..2e64a1b1b 100644 --- a/src/modules/Servicehosting/Api/Admin.php +++ b/src/modules/Servicehosting/Api/Admin.php @@ -23,7 +23,7 @@ class Admin extends \Api_Abstract public function change_plan($data) { if (!isset($data['plan_id'])) { - throw new \Box_Exception('plan_id is missing'); + throw new \FOSSBilling\Exception('plan_id is missing'); } [$order, $s] = $this->_getService($data); @@ -175,7 +175,7 @@ class Admin extends \Api_Abstract * * @return int - server id * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function server_create($data) { @@ -196,7 +196,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function server_get($data) { @@ -216,7 +216,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function server_delete($data) { @@ -232,7 +232,7 @@ class Admin extends \Api_Abstract $count = is_array($hosting_services) ? count($hosting_services) : 0; // Handle the case where $hosting_services might be null if ($count > 0) { - throw new \Box_Exception('Hosting server is used by :count: service hostings', [':count:' => $count], 704); + throw new \FOSSBilling\InformationException('Hosting server is used by :count: service hostings', [':count:' => $count], 704); } return (bool) $this->getService()->deleteServer($model); @@ -256,7 +256,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function server_update($data) { @@ -280,7 +280,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function server_test_connection($data) { @@ -327,7 +327,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\InformationException */ public function hp_delete($data) { @@ -344,7 +344,7 @@ class Admin extends \Api_Abstract // Ensure $hosting_services is an array before counting its elements $count = is_array($hosting_services) ? count($hosting_services) : 0; // Handle the case where $hosting_services might be null if ($count > 0) { - throw new \Box_Exception('Hosting plan is used by :count: service hostings', [':count:' => $count], 704); + throw new \FOSSBilling\InformationException('Hosting plan is used by :count: service hostings', [':count:' => $count], 704); } return (bool) $this->getService()->deleteHp($model); @@ -355,7 +355,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function hp_get($data) { @@ -376,7 +376,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function hp_update($data) { @@ -397,7 +397,7 @@ class Admin extends \Api_Abstract * * @return int - new hosting plan id * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function hp_create($data) { @@ -422,7 +422,7 @@ class Admin extends \Api_Abstract $orderService = $this->di['mod_service']('order'); $s = $orderService->getOrderService($order); if (!$s instanceof \Model_ServiceHosting) { - throw new \Box_Exception('Order is not activated'); + throw new \FOSSBilling\Exception('Order is not activated'); } return [$order, $s]; diff --git a/src/modules/Servicehosting/Api/Client.php b/src/modules/Servicehosting/Api/Client.php index b8fe45861..baa599cf4 100644 --- a/src/modules/Servicehosting/Api/Client.php +++ b/src/modules/Servicehosting/Api/Client.php @@ -64,18 +64,18 @@ class Client extends \Api_Abstract public function _getService($data) { if (!isset($data['order_id'])) { - throw new \Box_Exception('Order id is required'); + throw new \FOSSBilling\Exception('Order id is required'); } $identity = $this->getIdentity(); $order = $this->di['db']->findOne('ClientOrder', 'id = ? and client_id = ?', [$data['order_id'], $identity->id]); if (!$order instanceof \Model_ClientOrder) { - throw new \Box_Exception('Order not found'); + throw new \FOSSBilling\Exception('Order not found'); } $orderService = $this->di['mod_service']('order'); $s = $orderService->getOrderService($order); if (!$s instanceof \Model_ServiceHosting) { - throw new \Box_Exception('Order is not activated'); + throw new \FOSSBilling\Exception('Order is not activated'); } return [$order, $s]; diff --git a/src/modules/Servicehosting/Api/Guest.php b/src/modules/Servicehosting/Api/Guest.php index 1dcff8756..3deac02e5 100644 --- a/src/modules/Servicehosting/Api/Guest.php +++ b/src/modules/Servicehosting/Api/Guest.php @@ -20,7 +20,7 @@ class Guest extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function free_tlds($data = []) { @@ -35,7 +35,7 @@ class Guest extends \Api_Abstract if ($product->type !== \Model_Product::HOSTING) { $friendlyName = ucfirst(__trans('Product type')); - throw new \Box_Exception(':friendlyName: is invalid', [':friendlyName:' => $friendlyName]); + throw new \FOSSBilling\Exception(':friendlyName: is invalid', [':friendlyName:' => $friendlyName]); } return $this->getService()->getFreeTlds($product); diff --git a/src/modules/Servicehosting/Service.php b/src/modules/Servicehosting/Service.php index a5b608a07..41e41f4f3 100644 --- a/src/modules/Servicehosting/Service.php +++ b/src/modules/Servicehosting/Service.php @@ -43,16 +43,16 @@ class Service implements InjectionAwareInterface public function validateOrderData(array &$data) { if (!isset($data['server_id'])) { - throw new \Box_Exception('Hosting product is not configured completely. Configure server for hosting product.', null, 701); + throw new \FOSSBilling\InformationException('Hosting product is not configured completely. Configure server for hosting product.', null, 701); } if (!isset($data['hosting_plan_id'])) { - throw new \Box_Exception('Hosting product is not configured completely. Configure hosting plan for hosting product.', null, 702); + throw new \FOSSBilling\InformationException('Hosting product is not configured completely. Configure hosting plan for hosting product.', null, 702); } if (!isset($data['sld']) || empty($data['sld'])) { - throw new \Box_Exception('Domain name is invalid.', null, 703); + throw new \FOSSBilling\InformationException('Domain name is invalid.', null, 703); } if (!isset($data['tld']) || empty($data['tld'])) { - throw new \Box_Exception('Domain extension is invalid.', null, 704); + throw new \FOSSBilling\InformationException('Domain extension is invalid.', null, 704); } } @@ -91,7 +91,7 @@ class Service implements InjectionAwareInterface $orderService = $this->di['mod_service']('order'); $model = $orderService->getOrderService($order); if (!$model instanceof \RedBeanPHP\SimpleModel) { - throw new \Box_Exception('Order :id has no active service', [':id' => $order->id]); + throw new \FOSSBilling\Exception('Order :id has no active service', [':id' => $order->id]); } $pass = $this->di['tools']->generatePassword(10, 4); @@ -136,7 +136,7 @@ class Service implements InjectionAwareInterface $orderService = $this->di['mod_service']('order'); $model = $orderService->getOrderService($order); if (!$model instanceof \RedBeanPHP\SimpleModel) { - throw new \Box_Exception('Order :id has no active service', [':id' => $order->id]); + throw new \FOSSBilling\Exception('Order :id has no active service', [':id' => $order->id]); } // @todo ? @@ -154,7 +154,7 @@ class Service implements InjectionAwareInterface $orderService = $this->di['mod_service']('order'); $model = $orderService->getOrderService($order); if (!$model instanceof \RedBeanPHP\SimpleModel) { - throw new \Box_Exception('Order :id has no active service', [':id' => $order->id]); + throw new \FOSSBilling\Exception('Order :id has no active service', [':id' => $order->id]); } [$adapter, $account] = $this->_getAM($model); $adapter->suspendAccount($account); @@ -173,7 +173,7 @@ class Service implements InjectionAwareInterface $orderService = $this->di['mod_service']('order'); $model = $orderService->getOrderService($order); if (!$model instanceof \RedBeanPHP\SimpleModel) { - throw new \Box_Exception('Order :id has no active service', [':id' => $order->id]); + throw new \FOSSBilling\Exception('Order :id has no active service', [':id' => $order->id]); } [$adapter, $account] = $this->_getAM($model); $adapter->unsuspendAccount($account); @@ -192,7 +192,7 @@ class Service implements InjectionAwareInterface $orderService = $this->di['mod_service']('order'); $model = $orderService->getOrderService($order); if (!$model instanceof \RedBeanPHP\SimpleModel) { - throw new \Box_Exception('Order :id has no active service', [':id' => $order->id]); + throw new \FOSSBilling\Exception('Order :id has no active service', [':id' => $order->id]); } [$adapter, $account] = $this->_getAM($model); $adapter->cancelAccount($account); @@ -252,7 +252,7 @@ class Service implements InjectionAwareInterface public function changeAccountUsername(\Model_ClientOrder $order, \Model_ServiceHosting $model, $data) { if (!isset($data['username']) || empty($data['username'])) { - throw new \Box_Exception('Account username is missing or is invalid'); + throw new \FOSSBilling\InformationException('Account username is missing or is invalid'); } $u = strtolower($data['username']); @@ -274,7 +274,7 @@ class Service implements InjectionAwareInterface public function changeAccountIp(\Model_ClientOrder $order, \Model_ServiceHosting $model, $data) { if (!isset($data['ip']) || empty($data['ip'])) { - throw new \Box_Exception('Account ip is missing or is invalid'); + throw new \FOSSBilling\InformationException('Account ip is missing or is invalid'); } $ip = $data['ip']; @@ -298,7 +298,7 @@ class Service implements InjectionAwareInterface !isset($data['tld']) || empty($data['tld']) || !isset($data['sld']) || empty($data['sld']) ) { - throw new \Box_Exception('Domain sld or tld is missing'); + throw new \FOSSBilling\InformationException('Domain sld or tld is missing'); } $sld = $data['sld']; @@ -324,7 +324,7 @@ class Service implements InjectionAwareInterface !isset($data['password']) || !isset($data['password_confirm']) || $data['password'] != $data['password_confirm'] ) { - throw new \Box_Exception('Account password is missing or is invalid'); + throw new \FOSSBilling\InformationException('Account password is missing or is invalid'); } $newPassword = $data['password']; @@ -722,7 +722,7 @@ class Service implements InjectionAwareInterface public function getServerManager(\Model_ServiceHostingServer $model) { if (empty($model->manager)) { - throw new \Box_Exception('Invalid server manager. Server was not configured properly.', null, 654); + throw new \FOSSBilling\Exception('Invalid server manager. Server was not configured properly.', null, 654); } $config = []; @@ -742,7 +742,7 @@ class Service implements InjectionAwareInterface $manager = $this->di['server_manager']($model->manager, $config); if (!$manager instanceof \Server_Manager) { - throw new \Box_Exception('Server manager :adapter is invalid', [':adapter' => $model->manager]); + throw new \FOSSBilling\Exception('Server manager :adapter is invalid', [':adapter' => $model->manager]); } return $manager; @@ -782,7 +782,7 @@ class Service implements InjectionAwareInterface $id = $model->id; $serviceHosting = $this->di['db']->findOne('ServiceHosting', 'service_hosting_hp_id = ?', [$model->id]); if ($serviceHosting) { - throw new \Box_Exception('Can not remove hosting plan which has active accounts'); + throw new \FOSSBilling\InformationException('Can not remove hosting plan which has active accounts'); } $this->di['db']->trash($model); $this->di['logger']->info('Deleted hosting plan %s', $id); @@ -967,7 +967,7 @@ class Service implements InjectionAwareInterface $table = $this->di['mod_service']('product'); $d = $table->getMainDomainProduct(); if (!$d instanceof \Model_Product) { - throw new \Box_Exception('Could not find main domain product'); + throw new \FOSSBilling\Exception('Could not find main domain product'); } return ['product' => $d, 'config' => $dc]; diff --git a/src/modules/Servicelicense/Api/Admin.php b/src/modules/Servicelicense/Api/Admin.php index 55ae97e23..81f035610 100644 --- a/src/modules/Servicelicense/Api/Admin.php +++ b/src/modules/Servicelicense/Api/Admin.php @@ -70,7 +70,7 @@ class Admin extends \Api_Abstract /** * @return \Model_ServiceLicense * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function _getService(array $data) { @@ -82,7 +82,7 @@ class Admin extends \Api_Abstract $orderService = $this->di['mod_service']('order'); $s = $orderService->getOrderService($order); if (!$s instanceof \Model_ServiceLicense) { - throw new \Box_Exception('Order is not activated'); + throw new \FOSSBilling\Exception('Order is not activated'); } return $s; diff --git a/src/modules/Servicelicense/Api/Client.php b/src/modules/Servicelicense/Api/Client.php index d4f0935f9..7ef181248 100644 --- a/src/modules/Servicelicense/Api/Client.php +++ b/src/modules/Servicelicense/Api/Client.php @@ -42,13 +42,13 @@ class Client extends \Api_Abstract $order = $this->di['db']->findOne('ClientOrder', 'id = :id AND client_id = :client_id', $bindings); if (!$order instanceof \Model_ClientOrder) { - throw new \Box_Exception('Order not found'); + throw new \FOSSBilling\Exception('Order not found'); } $orderService = $this->di['mod_service']('order'); $s = $orderService->getOrderService($order); if (!$s instanceof \Model_ServiceLicense) { - throw new \Box_Exception('Order is not activated'); + throw new \FOSSBilling\Exception('Order is not activated'); } return $s; diff --git a/src/modules/Servicelicense/Service.php b/src/modules/Servicelicense/Service.php index 10740ce39..ae1832268 100644 --- a/src/modules/Servicelicense/Service.php +++ b/src/modules/Servicelicense/Service.php @@ -109,17 +109,17 @@ class Service implements InjectionAwareInterface $iterations = $c['iterations'] ?? 10; $model = $orderService->getOrderService($order); if (!$model instanceof \Model_ServiceLicense) { - throw new \Box_Exception('Could not activate order. Service was not created'); + throw new \FOSSBilling\Exception('Could not activate order. Service was not created'); } $plugin = $this->_getPlugin($model); if (!is_object($plugin)) { - throw new \Box_Exception('License plugin :plugin was not found', [':plugin' => $model->plugin]); + throw new \FOSSBilling\Exception('License plugin :plugin was not found', [':plugin' => $model->plugin]); } if (!method_exists($plugin, 'generate')) { - throw new \Box_Exception('License plugin do not have generate method'); + throw new \FOSSBilling\Exception('License plugin do not have generate method'); } if (method_exists($plugin, 'setDi')) { @@ -130,7 +130,7 @@ class Service implements InjectionAwareInterface do { $licenseKey = $plugin->generate($model, $order, $c); if ($i++ >= $iterations) { - throw new \Box_Exception('Maximum number of iterations reached while generating license key'); + throw new \FOSSBilling\Exception('Maximum number of iterations reached while generating license key'); } } while ($this->di['db']->findOne('ServiceLicense', 'license_key = :license_key', [':license_key' => $licenseKey]) !== null); @@ -431,7 +431,7 @@ class Service implements InjectionAwareInterface { $result = []; $log = $this->di['logger']->setChannel('license'); - if ($this->di['config']['debug']) { + if (BB_DEBUG) { $log->debug(print_r($data, 1)); } diff --git a/src/modules/Spamchecker/Service.php b/src/modules/Spamchecker/Service.php index 2613e7340..90565e7aa 100644 --- a/src/modules/Spamchecker/Service.php +++ b/src/modules/Spamchecker/Service.php @@ -54,7 +54,7 @@ class Service implements InjectionAwareInterface $blocked_ips = explode(PHP_EOL, $config['blocked_ips']); $blocked_ips = array_map('trim', $blocked_ips); if (in_array($di['request']->getClientAddress(), $blocked_ips)) { - throw new \Box_Exception('Your IP address (:ip) is blocked. Please contact our support to lift your block.', [':ip' => $di['request']->getClientAddress()], 403); + throw new \FOSSBilling\InformationException('Your IP address (:ip) is blocked. Please contact our support to lift your block.', [':ip' => $di['request']->getClientAddress()], 403); } } } @@ -75,11 +75,11 @@ class Service implements InjectionAwareInterface if (isset($config['captcha_enabled']) && $config['captcha_enabled']) { if (isset($config['captcha_version']) && 2 == $config['captcha_version']) { if (!isset($config['captcha_recaptcha_privatekey']) || '' == $config['captcha_recaptcha_privatekey']) { - throw new \Box_Exception("To use reCAPTCHA you must get an API key from here"); + throw new \FOSSBilling\InformationException("To use reCAPTCHA you must get an API key from here"); } if (!isset($params['g-recaptcha-response']) || '' == $params['g-recaptcha-response']) { - throw new \Box_Exception('You have to complete the CAPTCHA to continue'); + throw new \FOSSBilling\InformationException('You have to complete the CAPTCHA to continue'); } $client = HttpClient::create(); @@ -93,10 +93,10 @@ class Service implements InjectionAwareInterface $content = $response->toArray(); if (!$content['success']) { - throw new \Box_Exception('reCAPTCHA verification failed.'); + throw new \FOSSBilling\InformationException('reCAPTCHA verification failed.'); } } else { - throw new \Box_Exception('reCAPTCHA verification failed.'); + throw new \FOSSBilling\InformationException('reCAPTCHA verification failed.'); } } @@ -127,13 +127,13 @@ class Service implements InjectionAwareInterface } if (isset($json->username->appears) && $json->username->appears) { - throw new \Box_Exception('Your username is blacklisted in the Stop Forum Spam database'); + throw new \FOSSBilling\InformationException('Your username is blacklisted in the Stop Forum Spam database'); } if (isset($json->email->appears) && $json->email->appears) { - throw new \Box_Exception('Your e-mail is blacklisted in the Stop Forum Spam database'); + throw new \FOSSBilling\InformationException('Your e-mail is blacklisted in the Stop Forum Spam database'); } if (isset($json->ip->appears) && $json->ip->appears) { - throw new \Box_Exception('Your IP address is blacklisted in the Stop Forum Spam database'); + throw new \FOSSBilling\InformationException('Your IP address is blacklisted in the Stop Forum Spam database'); } return false; diff --git a/src/modules/Staff/Api/Admin.php b/src/modules/Staff/Api/Admin.php index 6fcfa1a75..0b29551f9 100644 --- a/src/modules/Staff/Api/Admin.php +++ b/src/modules/Staff/Api/Admin.php @@ -40,7 +40,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function get($data) { @@ -65,7 +65,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function update($data) { @@ -88,7 +88,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function delete($data) { @@ -107,7 +107,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\InformationException */ public function change_password($data) { @@ -120,7 +120,7 @@ class Admin extends \Api_Abstract $validator->checkRequiredParamsForArray($required, $data); if ($data['password'] != $data['password_confirm']) { - throw new \Box_Exception('Passwords do not match'); + throw new \FOSSBilling\InformationException('Passwords do not match'); } $validator->isPasswordStrong($data['password']); @@ -137,7 +137,7 @@ class Admin extends \Api_Abstract * * @return int - ID of newly created staff member * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function create($data) { @@ -229,7 +229,7 @@ class Admin extends \Api_Abstract * * @return int - new staff group ID * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function group_create($data) { @@ -246,7 +246,7 @@ class Admin extends \Api_Abstract * * @return array - group details * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function group_get($data) { @@ -265,7 +265,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function group_delete($data) { @@ -286,7 +286,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function group_update($data) { diff --git a/src/modules/Staff/Api/Guest.php b/src/modules/Staff/Api/Guest.php index eadcd0829..d379face4 100644 --- a/src/modules/Staff/Api/Guest.php +++ b/src/modules/Staff/Api/Guest.php @@ -29,7 +29,7 @@ class Guest extends \Api_Abstract { $allow = (!is_countable($this->di['db']->findOne('Admin', '1=1')) || count($this->di['db']->findOne('Admin', '1=1')) == 0); if (!$allow) { - throw new \Box_Exception('Administrator account already exists', null, 55); + throw new \FOSSBilling\InformationException('Administrator account already exists', null, 55); } $required = [ 'email' => 'Administrator email is missing.', @@ -56,7 +56,7 @@ class Guest extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function login($data) { @@ -76,7 +76,7 @@ class Guest extends \Api_Abstract if ($allowed_ips) { $allowed_ips = array_map('trim', $allowed_ips); if (!in_array($this->getIp(), $allowed_ips)) { - throw new \Box_Exception('You are not allowed to login to admin area from :ip address', [':ip' => $this->getIp()], 403); + throw new \FOSSBilling\InformationException('You are not allowed to login to admin area from :ip address', [':ip' => $this->getIp()], 403); } } } @@ -88,7 +88,7 @@ class Guest extends \Api_Abstract { $config = $this->getMod()->getConfig(); if (isset($config['public']['reset_pw']) && $config['public']['reset_pw'] == '0') { - throw new \Box_Exception('Password reset has been disabled'); + throw new \FOSSBilling\InformationException('Password reset has been disabled'); } $this->di['events_manager']->fire(['event' => 'onBeforePasswordResetStaff']); $required = [ @@ -101,16 +101,16 @@ class Guest extends \Api_Abstract $validator->checkRequiredParamsForArray($required, $data); if ($data['password'] != $data['password_confirm']) { - throw new \Box_Exception('Passwords do not match'); + throw new \FOSSBilling\InformationException('Passwords do not match'); } $reset = $this->di['db']->findOne('AdminPasswordReset', 'hash = ?', [$data['code']]); if (!$reset instanceof \Model_AdminPasswordReset) { - throw new \Box_Exception('The link have expired or you have already confirmed password reset.'); + throw new \FOSSBilling\InformationException('The link have expired or you have already confirmed password reset.'); } if (strtotime($reset->created_at) - time() + 900 < 0) { - throw new \Box_Exception('The link have expired or you have already confirmed password reset.'); + throw new \FOSSBilling\InformationException('The link have expired or you have already confirmed password reset.'); } $c = $this->di['db']->getExistingModelById('Admin', $reset->admin_id, 'User not found'); @@ -133,7 +133,7 @@ class Guest extends \Api_Abstract { $config = $this->getMod()->getConfig(); if (isset($config['public']['reset_pw']) && $config['public']['reset_pw'] == '0') { - throw new \Box_Exception('Password reset has been disabled'); + throw new \FOSSBilling\InformationException('Password reset has been disabled'); } $this->di['events_manager']->fire(['event' => 'onBeforePasswordResetStaff']); $required = [ diff --git a/src/modules/Staff/Controller/Admin.php b/src/modules/Staff/Controller/Admin.php index 2dcbb2672..60ed09dc6 100644 --- a/src/modules/Staff/Controller/Admin.php +++ b/src/modules/Staff/Controller/Admin.php @@ -118,16 +118,16 @@ class Admin implements InjectionAwareInterface $mod = $this->di['mod']('staff'); $config = $mod->getConfig(); if (isset($config['public']['reset_pw']) && $config['public']['reset_pw'] == '0') { - throw new \Box_Exception('Password reset has been disabled'); + throw new \FOSSBilling\InformationException('Password reset has been disabled'); } // send confirmation email $service = $this->di['mod_service']('staff'); $reset = $this->di['db']->findOne('AdminPasswordReset', 'hash = ?', [$hash]); if (!$reset instanceof \Model_AdminPasswordReset) { - throw new \Box_Exception('The link have expired or you have already confirmed password reset.'); + throw new \FOSSBilling\InformationException('The link have expired or you have already confirmed password reset.'); } if (strtotime($reset->created_at) - time() + 900 < 0) { - throw new \Box_Exception('The link have expired or you have already confirmed password reset.'); + throw new \FOSSBilling\InformationException('The link have expired or you have already confirmed password reset.'); } $admin = $this->di['db']->getExistingModelById('Admin', $reset->admin_id, 'User not found'); $data['hash'] = $reset->hash; diff --git a/src/modules/Staff/Service.php b/src/modules/Staff/Service.php index 3b2b00c18..af2353acf 100644 --- a/src/modules/Staff/Service.php +++ b/src/modules/Staff/Service.php @@ -38,7 +38,7 @@ class Service implements InjectionAwareInterface if (!$model instanceof \Model_Admin) { $this->di['events_manager']->fire(['event' => 'onEventAdminLoginFailed', 'params' => $event_params]); - throw new \Box_Exception('Check your login details', null, 403); + throw new \FOSSBilling\InformationException('Check your login details', null, 403); } $this->di['events_manager']->fire(['event' => 'onAfterAdminLogin', 'params' => ['id' => $model->id, 'ip' => $ip]]); @@ -421,7 +421,7 @@ class Service implements InjectionAwareInterface public function delete(\Model_Admin $model) { if ($model->protected) { - throw new \Box_Exception('This administrator account is protected and can not be removed'); + throw new \FOSSBilling\InformationException('This administrator account is protected and can not be removed'); } $this->di['events_manager']->fire(['event' => 'onBeforeAdminStaffDelete', 'params' => ['id' => $model->id]]); @@ -476,7 +476,7 @@ class Service implements InjectionAwareInterface try { $newId = $this->di['db']->store($model); } catch (\RedBeanPHP\RedException) { - throw new \Box_Exception('Staff member with email :email is already registered', [':email' => $data['email']], 788954); + throw new \FOSSBilling\InformationException('Staff member with email :email is already registered', [':email' => $data['email']], 788954); } $this->di['events_manager']->fire(['event' => 'onAfterAdminStaffCreate', 'params' => ['id' => $newId]]); @@ -561,7 +561,7 @@ class Service implements InjectionAwareInterface { $id = $model->id; if ($model->id == 1) { - throw new \Box_Exception('Administrators group can not be removed'); + throw new \FOSSBilling\InformationException('Administrators group can not be removed'); } $sql = 'SELECT count(1) @@ -569,7 +569,7 @@ class Service implements InjectionAwareInterface WHERE admin_group_id = :id'; $staffMembersInGroup = $this->di['db']->getCell($sql, ['id' => $model->id]); if ($staffMembersInGroup > 0) { - throw new \Box_Exception('Can not remove group which has staff members'); + throw new \FOSSBilling\InformationException('Can not remove group which has staff members'); } $this->di['db']->trash($model); diff --git a/src/modules/Support/Api/Admin.php b/src/modules/Support/Api/Admin.php index 889ed4e02..ab4d63e09 100644 --- a/src/modules/Support/Api/Admin.php +++ b/src/modules/Support/Api/Admin.php @@ -259,7 +259,7 @@ class Admin extends \Api_Abstract * * @return int - inquiry id * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function public_ticket_create($data) { @@ -279,7 +279,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function public_ticket_get($data) { @@ -298,7 +298,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function public_ticket_delete($data) { @@ -317,7 +317,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function public_ticket_close($data) { @@ -339,7 +339,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function public_ticket_update($data) { @@ -358,7 +358,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function public_ticket_reply($data) { @@ -413,7 +413,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function helpdesk_get($data) { @@ -438,7 +438,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function helpdesk_update($data) { @@ -462,7 +462,7 @@ class Admin extends \Api_Abstract * * @return int - id * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function helpdesk_create($data) { @@ -479,7 +479,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function helpdesk_delete($data) { @@ -533,7 +533,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function canned_get($data) { @@ -552,7 +552,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function canned_delete($data) { @@ -573,7 +573,7 @@ class Admin extends \Api_Abstract * * @return int * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function canned_create($data) { @@ -597,7 +597,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function canned_update($data) { @@ -626,7 +626,7 @@ class Admin extends \Api_Abstract * * @return array * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function canned_category_get($data) { @@ -647,7 +647,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function canned_category_update($data) { @@ -668,7 +668,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function canned_category_delete($data) { @@ -687,7 +687,7 @@ class Admin extends \Api_Abstract * * @return int - new category id * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function canned_category_create($data) { @@ -704,7 +704,7 @@ class Admin extends \Api_Abstract * * @return int - new note id * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function note_create($data) { @@ -724,7 +724,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function note_delete($data) { @@ -743,7 +743,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function task_complete($data) { diff --git a/src/modules/Support/Api/Client.php b/src/modules/Support/Api/Client.php index 5be981ae4..f2575ac08 100644 --- a/src/modules/Support/Api/Client.php +++ b/src/modules/Support/Api/Client.php @@ -121,11 +121,11 @@ class Client extends \Api_Abstract $ticket = $this->di['db']->findOne('SupportTicket', 'id = :id AND client_id = :client_id', $bindings); if (!$ticket instanceof \Model_SupportTicket) { - throw new \Box_Exception('Ticket not found'); + throw new \FOSSBilling\Exception('Ticket not found'); } if (!$this->getService()->canBeReopened($ticket)) { - throw new \Box_Exception('Ticket can not be reopened.'); + throw new \FOSSBilling\InformationException('Ticket can not be reopened.'); } $result = $this->getService()->ticketReply($ticket, $client, $data['content']); diff --git a/src/modules/Support/Api/Guest.php b/src/modules/Support/Api/Guest.php index 224725686..e49c830f0 100644 --- a/src/modules/Support/Api/Guest.php +++ b/src/modules/Support/Api/Guest.php @@ -32,7 +32,7 @@ class Guest extends \Api_Abstract $this->di['validator']->checkRequiredParamsForArray($required, $data); if (strlen($data['message']) < 4) { - throw new \Box_Exception('Please enter your message'); + throw new \FOSSBilling\InformationException('Please enter your message'); } return $this->getService()->ticketCreateForGuest($data); diff --git a/src/modules/Support/Service.php b/src/modules/Support/Service.php index abe848d06..166c08537 100644 --- a/src/modules/Support/Service.php +++ b/src/modules/Support/Service.php @@ -244,7 +244,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface $ticket = $this->di['db']->findOne('SupportTicket', 'id = :id AND client_id = :client_id', $bindings); if (!$ticket instanceof \Model_SupportTicket) { - throw new \Box_Exception('Ticket not found'); + throw new \FOSSBilling\Exception('Ticket not found'); } return $ticket; @@ -648,7 +648,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface $tickets = $this->di['db']->find('SupportTicket', 'support_helpdesk_id = :support_helpdesk_id', [':support_helpdesk_id' => $model->id]); if ((is_countable($tickets) ? count($tickets) : 0) > 0) { - throw new \Box_Exception('Can not remove helpdesk which has tickets'); + throw new \FOSSBilling\InformationException('Can not remove helpdesk which has tickets'); } $this->di['db']->trash($model); $this->di['logger']->info('Deleted helpdesk #%s', $id); @@ -855,7 +855,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface $timeSinceLast = round(abs(strtotime($lastTicket->created_at) - strtotime(date('Y-m-d H:i:s'))) / 3600, 0); if ($timeSinceLast < $hours) { - throw new \Box_Exception(sprintf('You can submit one ticket per %s hours. %s hours left', $hours, $hours - $timeSinceLast)); + throw new \FOSSBilling\InformationException(sprintf('You can submit one ticket per %s hours. %s hours left', $hours, $hours - $timeSinceLast)); } return true; @@ -871,7 +871,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface $orderService = $this->di['mod_service']('order'); $o = $orderService->findForClientById($client, $rel_id); if (!$o instanceof \Model_ClientOrder) { - throw new \Box_Exception('Order ID does not exist'); + throw new \FOSSBilling\Exception('Order ID does not exist'); } } @@ -881,7 +881,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface if ($rel_task == 'upgrade') { if (empty($o) || empty($rel_new_value)) { - throw new \Box_Exception('You must provide both an order ID and a new product ID in order to request an upgrade.'); + throw new \FOSSBilling\Exception('You must provide both an order ID and a new product ID in order to request an upgrade.'); } $product = $this->di['db']->getExistingModelById('Product', $o->product_id); @@ -889,13 +889,13 @@ class Service implements \FOSSBilling\InjectionAwareInterface if (!in_array($rel_new_value, $allowedUpgrades)) { $upgrade = $this->di['db']->getExistingModelById('Product', $rel_new_value); - throw new \Box_Exception('Sorry, but ":product" is not allowed to be upgraded to ":upgrade"', [':product' => $product->title, ':upgrade' => $upgrade->title ?? 'unknown']); + throw new \FOSSBilling\InformationException('Sorry, but ":product" is not allowed to be upgraded to ":upgrade"', [':product' => $product->title, ':upgrade' => $upgrade->title ?? 'unknown']); } } // check if support ticket with same uncompleted task already exists if ($rel_id && $rel_type && $rel_task && $this->checkIfTaskAlreadyExists($client, $rel_id, $rel_type, $rel_task)) { - throw new \Box_Exception('We have already received this request.'); + throw new \FOSSBilling\InformationException('We have already received this request.'); } $mod = $this->di['mod']('support'); @@ -970,7 +970,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface } elseif ($identity instanceof \Model_Client) { $msg->client_id = $identity->id; } else { - throw new \Box_Exception('Identity is invalid'); + throw new \FOSSBilling\Exception('Identity is invalid'); } $msg->content = $content; $msg->ip = $this->di['request']->getClientAddress(); @@ -999,7 +999,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface $publicTicket = $this->di['db']->findOne('SupportPTicket', 'hash = :hash', $bindings); if (!$publicTicket instanceof \Model_SupportPTicket) { - throw new \Box_Exception('Public ticket not found'); + throw new \FOSSBilling\Exception('Public ticket not found'); } return $publicTicket; diff --git a/src/modules/System/Api/Admin.php b/src/modules/System/Api/Admin.php index 5d2969750..1e5b2a8e2 100644 --- a/src/modules/System/Api/Admin.php +++ b/src/modules/System/Api/Admin.php @@ -14,6 +14,8 @@ namespace Box\Mod\System\Api; +use Symfony\Component\Filesystem\Filesystem; + class Admin extends \Api_Abstract { /** @@ -117,7 +119,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function is_allowed($data) { @@ -171,13 +173,13 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function update_core($data) { $updater = $this->di['updater']; if ($updater->getUpdateBranch() !== 'preview' && !$updater->isUpdateAvailable()) { - throw new \Box_Exception('You have latest version of FOSSBilling. You do not need to update.'); + throw new \FOSSBilling\InformationException('You have latest version of FOSSBilling. You do not need to update.'); } $new_version = $updater->getLatestVersion(); @@ -195,7 +197,7 @@ class Admin extends \Api_Abstract * * @return bool * - * @throws \Box_Exception + * @throws \FOSSBilling\Exception */ public function manual_update() { @@ -207,4 +209,50 @@ class Admin extends \Api_Abstract return true; } + + /** + * Returns the unique instance ID for this FOSSBilling installation. + * + * @return string + */ + public function instance_id(): string + { + return INSTANCE_ID; + } + + /** + * Returns if error reporting is enabled or not on this FOSSBilling instance. + */ + public function error_reporting_enabled(): bool + { + return (bool)$this->di['config']['debug_and_monitoring']['report_errors']; + } + + /** + * Toggles error reporting on this FOSSBilling instance. + */ + public function toggle_error_reporting(): bool + { + $filesystem = new Filesystem(); + $config = include PATH_CONFIG; + + // Invert the current config value + $config['debug_and_monitoring']['report_errors'] = !$config['debug_and_monitoring']['report_errors']; + + // Create the output file + $output = 'dumpFile(PATH_CONFIG, $output); + return true; + } + + /** + * Returns the last FOSSBilling version number that changed error reporting behavior. + */ + public function last_error_reporting_change(): string + { + return \FOSSBilling\SentryHelper::last_change; + } } diff --git a/src/modules/System/Service.php b/src/modules/System/Service.php index d4d1b2037..02bd3de88 100644 --- a/src/modules/System/Service.php +++ b/src/modules/System/Service.php @@ -11,6 +11,8 @@ namespace Box\Mod\System; use FOSSBilling\Environment; +use FOSSBilling\SentryHelper; +use FOSSBilling\Version; use Pimple\Container; use Symfony\Component\HttpClient\HttpClient; use Symfony\Contracts\Cache\ItemInterface; @@ -31,7 +33,7 @@ class Service public function getParamValue($param, $default = null) { if (empty($param)) { - throw new \Box_Exception('Parameter key is missing'); + throw new \FOSSBilling\Exception('Parameter key is missing'); } $query = 'SELECT value @@ -95,7 +97,7 @@ class Service } foreach ($params as $param) { if (!preg_match('/^[a-z0-9_]+$/', $param)) { - throw new \Box_Exception('Invalid parameter name, received: param_', ['param_' => $param]); + throw new \FOSSBilling\InformationException('Invalid parameter name, received: param_', ['param_' => $param]); } } $query = "SELECT param, value @@ -259,12 +261,12 @@ class Service // And now return the correctly message for the given situation if (!$last_exec) { return [ - 'text' => 'Cron was never executed, please ensure you have configured the cronjob or else scheduled tasks within FOSSBilling will not behave correctly. (Message is cached for 15 minutes)', + 'text' => 'Cron was never executed, please ensure you have configured the cronjob or else scheduled tasks within FOSSBilling will not behave correctly. (Message will remain for 15 minutes)', 'url' => $cronUrl, ]; } elseif ((time() - strtotime($last_exec)) / 60 >= 15) { return [ - 'text' => 'FOSSBilling has detected that cron hasn\'t been run in an abnormal time period. Please ensure the cronjob is configured to be run every 5 minutes. (Message is cached for 15 minutes)', + 'text' => 'FOSSBilling has detected that cron hasn\'t been run in an abnormal time period. Please ensure the cronjob is configured to be run every 5 minutes. (Message will remain for 15 minutes)', 'url' => $cronUrl, ]; } else { @@ -277,6 +279,44 @@ class Service } } + /** + * The below logic is to help ensure that we nudge the user when needed about error reporting. + */ + if (Environment::isProduction()) { + // Get the last time we've nudged the user about error reporting + $lastErrorReportingNudge = $this->getParamValue('last_error_reporting_nudge'); + + $result = $this->di['cache']->get('error_reporting_nudge', function (ItemInterface $item) use ($lastErrorReportingNudge) { + $item->expiresAfter(15 * 60); + $url = $this->di['url']->adminLink('extension/settings/system'); + $this->setParamValue('last_error_reporting_nudge', Version::VERSION); + + if (!$lastErrorReportingNudge) { + // The user upgraded from a version that didn't have error reporting functionality, so let's nudge them about it now. + return [ + 'text' => 'We\'d apreciate it if you\'d consider opting into error reporting for FOSSBilling. Doing so will help us improve the software and provide you with a better experience. (Message will remain for 15 minutes)', + 'url' => $url, + ]; + } elseif ((version_compare(SentryHelper::last_change, $lastErrorReportingNudge) === 1) && $this->di['config']['debug_and_monitoring']['report_errors']) { + /** + * The installation already had error reporting enabled, but something has changed so we should nudge the user to review the changes. + * This message is cached for a full 24 hours to help ensure it is seen. + */ + $item->expiresAfter(60 * 60 * 24); + return [ + 'text' => 'Error reporting in FOSSBilling has changed since you last reviewed it. You may want to consider reviewing the changes to see what\'s been changed. (This message will remain for 24 hours)', + 'url' => $url, + ]; + } else { + return []; + } + }); + + if ($result) { + $msgs['info'][] = $result; + } + } + $install = PATH_ROOT . '/install'; if (file_exists(PATH_ROOT . '/install')) { $msgs['danger'][] = [ @@ -308,7 +348,7 @@ class Service { try { return $this->di['central_alerts']->filterAlerts(); - } catch (\Box_Exception $e) { + } catch (\FOSSBilling\Exception $e) { return [ [ 'type' => 'warning', @@ -467,7 +507,7 @@ class Service $stmt->execute(['param' => $param]); $results = $stmt->fetchColumn(); if ($results === false) { - throw new \Box_Exception('Parameter :param does not exist', [':param' => $param]); + throw new \FOSSBilling\Exception('Parameter :param does not exist', [':param' => $param]); } return $results; @@ -1360,7 +1400,7 @@ class Service if (array_key_exists($data['country'], $codes)) { return $codes[$data['country']]; } else { - throw new \Box_Exception('Country :code phone code is not registered', [':code' => $data['country']]); + throw new \FOSSBilling\InformationException('Country :code phone code is not registered', [':code' => $data['country']]); } } diff --git a/src/modules/System/html_admin/mod_system_settings.html.twig b/src/modules/System/html_admin/mod_system_settings.html.twig index d11dadc87..5f5c766e4 100644 --- a/src/modules/System/html_admin/mod_system_settings.html.twig +++ b/src/modules/System/html_admin/mod_system_settings.html.twig @@ -31,7 +31,7 @@ {{ 'Company details'|trans }}
  • +
    @@ -512,21 +515,56 @@ ZW=Zimbabwe
    -
    FOSSBilling version
    +
    {{ 'FOSSBilling version'|trans }}
    {{ FOSSBillingVersion }}
    -
    PHP version
    +
    {{ 'PHP version'|trans }}
    {{ constant('PHP_VERSION') }}
    -
    License
    +
    {{ 'Instance ID'|trans }}
    +
    {{ admin.system_instance_id }}
    +
    +
    +
    {{ 'License'|trans }}
    +
    +
    +

    {{ 'Error reporting'|trans }}

    +
    +
    + {% set last_change = admin.system_last_error_reporting_change %} + {% if admin.system_error_reporting_enabled %} + + {% else %} + + {% endif %} +

    {{ 'FOSSBilling optionally includes autoamted error reporting to help aid the project\'s development and stability. To find the most up-to-date information about it, you should review the links and information below.'|trans }}

    + + {{ 'The last applicable behavior change represents the most recent FOSSBilling version that changed error reporting which also applies to this current version. There may have been more recent changes than what\'s listed.'|trans }} +
    +
    + diff --git a/src/modules/Theme/Controller/Admin.php b/src/modules/Theme/Controller/Admin.php index 8f1d65db9..fbf004e40 100644 --- a/src/modules/Theme/Controller/Admin.php +++ b/src/modules/Theme/Controller/Admin.php @@ -58,7 +58,7 @@ class Admin implements \FOSSBilling\InjectionAwareInterface try { if (!$t->isAssetsPathWritable()) { - throw new \Box_Exception('Theme ":name" assets folder is not writable. Files can not be uploaded and settings can not be saved. Set folder permissions to 777', [':name' => $t->getName()]); + throw new \FOSSBilling\Exception('Theme ":name" assets folder is not writable. Files can not be uploaded and settings can not be saved. Set folder permissions to 777', [':name' => $t->getName()]); } $service->updateSettings($t, $preset, $_POST); $service->regenerateThemeCssAndJsFiles($t, $preset, $api); diff --git a/src/modules/Theme/Model/Theme.php b/src/modules/Theme/Model/Theme.php index 4c60e3dda..cd15a63a8 100644 --- a/src/modules/Theme/Model/Theme.php +++ b/src/modules/Theme/Model/Theme.php @@ -15,7 +15,7 @@ class Theme public function __construct(private $name) { if (!file_exists($this->getPath())) { - throw new \Box_Exception('Theme ":name" does not exist', [':name' => $name]); + throw new \FOSSBilling\Exception('Theme ":name" does not exist', [':name' => $name]); } } diff --git a/src/modules/Theme/Service.php b/src/modules/Theme/Service.php index 837d664f9..8135b9b9a 100644 --- a/src/modules/Theme/Service.php +++ b/src/modules/Theme/Service.php @@ -319,7 +319,7 @@ class Service implements InjectionAwareInterface $theme_path = $this->getThemesPath() . $theme; if (!file_exists($theme_path)) { - throw new \Box_Exception('Theme was not found in path :path', [':path' => $theme_path]); + throw new \FOSSBilling\Exception('Theme was not found in path :path', [':path' => $theme_path]); } $manifest = $theme_path . '/manifest.json'; @@ -336,7 +336,7 @@ class Service implements InjectionAwareInterface } if (!is_array($config)) { - throw new \Box_Exception('Unable to decode theme manifest file :file', [':file' => $manifest]); + throw new \FOSSBilling\Exception('Unable to decode theme manifest file :file', [':file' => $manifest]); } $paths = [$theme_path . '/html']; diff --git a/tests/integration/bb-library/Api/HandlerTest.php b/tests/integration/bb-library/Api/HandlerTest.php index a884880f8..17101cc60 100644 --- a/tests/integration/bb-library/Api/HandlerTest.php +++ b/tests/integration/bb-library/Api/HandlerTest.php @@ -32,7 +32,7 @@ class HandlerTest extends BBDbApiTestCase { $api = $this->di['api_guest']; $method = 'methodWithoutUnderscore'; - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(710); $api->$method(); } @@ -41,7 +41,7 @@ class HandlerTest extends BBDbApiTestCase { $api = $this->di['api_guest']; $moduleName = '__'; - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(714); $version = $api->$moduleName(); } @@ -50,7 +50,7 @@ class HandlerTest extends BBDbApiTestCase { $api = $this->di['api_guest']; $moduleName = 'notActiveModule_version'; - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(715); $version = $api->$moduleName(); } diff --git a/tests/integration/bb-modules/mod_activity/Api_AdminTest.php b/tests/integration/bb-modules/mod_activity/Api_AdminTest.php index 05d9c6f6c..0c77dde1c 100644 --- a/tests/integration/bb-modules/mod_activity/Api_AdminTest.php +++ b/tests/integration/bb-modules/mod_activity/Api_AdminTest.php @@ -23,14 +23,14 @@ class Api_AdminTest extends BBDbApiTestCase public function testLogDeleteIdNotSetException() { - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->api_admin->activity_log_delete(array()); } public function testLogNotFoundException() { - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->api_admin->activity_log_delete(array('id' => 100)); } diff --git a/tests/integration/bb-modules/mod_cart/Api_ClientTest.php b/tests/integration/bb-modules/mod_cart/Api_ClientTest.php index 5d8c3a06f..8a5313c79 100644 --- a/tests/integration/bb-modules/mod_cart/Api_ClientTest.php +++ b/tests/integration/bb-modules/mod_cart/Api_ClientTest.php @@ -45,7 +45,7 @@ class Box_Mod_Cart_Api_ClientTest extends BBDbApiTestCase 'quantity' => 2, ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Can not checkout empty cart.'); $this->api_client->cart_checkout(); diff --git a/tests/integration/bb-modules/mod_cart/Api_GuestTest.php b/tests/integration/bb-modules/mod_cart/Api_GuestTest.php index e6a72f4cf..62ef32f3a 100644 --- a/tests/integration/bb-modules/mod_cart/Api_GuestTest.php +++ b/tests/integration/bb-modules/mod_cart/Api_GuestTest.php @@ -81,7 +81,7 @@ class Box_Mod_Cart_Api_GuestTest extends BBDbApiTestCase ), ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Selected billing period is invalid for the selected addon'); $bool = $this->api_guest->cart_add_item($data); @@ -101,7 +101,7 @@ class Box_Mod_Cart_Api_GuestTest extends BBDbApiTestCase ), ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Addon period parameter not passed'); $bool = $this->api_guest->cart_add_item($data); @@ -126,7 +126,7 @@ class Box_Mod_Cart_Api_GuestTest extends BBDbApiTestCase } /** - * @expectedException \Box_Exception + * @expectedException \FOSSBilling\Exception */ public function testAddDisabledPeriod() { @@ -525,7 +525,7 @@ class Box_Mod_Cart_Api_GuestTest extends BBDbApiTestCase public function testApplyPromoForClient($discount, $clientGroupId, $ids, $shouldThrowException) { if ($shouldThrowException) { - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); } $this->api_guest->cart_reset(); diff --git a/tests/integration/bb-modules/mod_client/Api_GuestTest.php b/tests/integration/bb-modules/mod_client/Api_GuestTest.php index eb19d08d2..d1958d764 100644 --- a/tests/integration/bb-modules/mod_client/Api_GuestTest.php +++ b/tests/integration/bb-modules/mod_client/Api_GuestTest.php @@ -39,7 +39,7 @@ class Api_Guest_ClientTest extends BBDbApiTestCase } /** - * @expectedException \Box_Exception + * @expectedException \FOSSBilling\Exception */ public function testRequiredFields() { @@ -152,7 +152,7 @@ class Api_Guest_ClientTest extends BBDbApiTestCase } /** - * @expectedException \Box_Exception + * @expectedException \FOSSBilling\Exception */ public function testCreateWithCustomRequiredException() { diff --git a/tests/integration/bb-modules/mod_paidsupport/ServiceTest.php b/tests/integration/bb-modules/mod_paidsupport/ServiceTest.php index 85669d208..043f0bcff 100644 --- a/tests/integration/bb-modules/mod_paidsupport/ServiceTest.php +++ b/tests/integration/bb-modules/mod_paidsupport/ServiceTest.php @@ -168,7 +168,7 @@ class Box_Mod_Paidsupport_ServiceTest extends ApiTestCase $supportTickets = $this->di['db']->find('SupportTicket'); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage($errorMessage); $this->api_client->support_ticket_create($data); diff --git a/tests/integration/bb-modules/mod_product/Api_AdminTest.php b/tests/integration/bb-modules/mod_product/Api_AdminTest.php index cdf039cb0..4341700af 100644 --- a/tests/integration/bb-modules/mod_product/Api_AdminTest.php +++ b/tests/integration/bb-modules/mod_product/Api_AdminTest.php @@ -212,7 +212,7 @@ class Api_Admin_ProductTest extends ApiTestCase 'type' => Model_ProductTable::DOMAIN, ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(413); $this->expectExceptionMessage('You have already created domain product.'); diff --git a/tests/integration/bb-modules/mod_serviceboxbillinglicense/Api_ClientTest.php b/tests/integration/bb-modules/mod_serviceboxbillinglicense/Api_ClientTest.php index de0f5e345..755625430 100644 --- a/tests/integration/bb-modules/mod_serviceboxbillinglicense/Api_ClientTest.php +++ b/tests/integration/bb-modules/mod_serviceboxbillinglicense/Api_ClientTest.php @@ -38,7 +38,7 @@ class Api_Client_ServiceBoxBillinglicenseTest extends BBDbApiTestCase $clientApi = new Box\Mod\Serviceboxbillinglicense\Api\Client(); $clientApi->setDi($this->di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Order id is required'); $bool = $clientApi->reset($data); @@ -59,7 +59,7 @@ class Api_Client_ServiceBoxBillinglicenseTest extends BBDbApiTestCase $clientApi->setDi($this->di); $clientApi->setIdentity($client); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('FOSSBilling license order not found'); $bool = $clientApi->reset($data); @@ -79,7 +79,7 @@ class Api_Client_ServiceBoxBillinglicenseTest extends BBDbApiTestCase $clientApi->setDi($this->di); $clientApi->setIdentity($client); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Order is not activated'); $bool = $clientApi->reset($data); diff --git a/tests/integration/bb-modules/mod_serviceboxbillinglicense/ServiceTest.php b/tests/integration/bb-modules/mod_serviceboxbillinglicense/ServiceTest.php index 3d3f7f022..01f2487c4 100644 --- a/tests/integration/bb-modules/mod_serviceboxbillinglicense/ServiceTest.php +++ b/tests/integration/bb-modules/mod_serviceboxbillinglicense/ServiceTest.php @@ -35,7 +35,7 @@ class ServiceBoxBillinglicenseTest extends BBDbApiTestCase $this->assertInstanceOf('\RedBeanPHP\OODBBean', $model); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(7456); $this->expectExceptionMessage('Could not activate order. Service was not created'); $service->activate($order, null); @@ -44,7 +44,7 @@ class ServiceBoxBillinglicenseTest extends BBDbApiTestCase $this->assertTrue($result); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(7456); $this->expectExceptionMessage('Could not activate order. Service was not created'); $service->suspend($order, null); @@ -53,7 +53,7 @@ class ServiceBoxBillinglicenseTest extends BBDbApiTestCase $this->assertTrue($result); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(7456); $this->expectExceptionMessage('Could not activate order. Service was not created'); $service->unsuspend($order, null); diff --git a/tests/integration/bb-modules/mod_servicedownloadable/Api_ClientTest.php b/tests/integration/bb-modules/mod_servicedownloadable/Api_ClientTest.php index 48707df61..650dbff72 100644 --- a/tests/integration/bb-modules/mod_servicedownloadable/Api_ClientTest.php +++ b/tests/integration/bb-modules/mod_servicedownloadable/Api_ClientTest.php @@ -8,7 +8,7 @@ class Api_Client_ServiceDownloadableTest extends BBDbApiTestCase public function testServiceDownload() { - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $data = array( 'order_id' => 1, diff --git a/tests/integration/bb-modules/mod_staff/Api_AdminTest.php b/tests/integration/bb-modules/mod_staff/Api_AdminTest.php index e6fdf93c6..5e6ae7f20 100644 --- a/tests/integration/bb-modules/mod_staff/Api_AdminTest.php +++ b/tests/integration/bb-modules/mod_staff/Api_AdminTest.php @@ -50,7 +50,7 @@ class Api_Admin_StaffTest extends BBDbApiTestCase } public function testChangePasswordException(){ - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $data = array( 'id' => 1, diff --git a/tests/integration/bb-modules/mod_support/Api_ClientTest.php b/tests/integration/bb-modules/mod_support/Api_ClientTest.php index 10c6cb1ea..cc515c7b0 100644 --- a/tests/integration/bb-modules/mod_support/Api_ClientTest.php +++ b/tests/integration/bb-modules/mod_support/Api_ClientTest.php @@ -84,7 +84,7 @@ class Api_Client_SupportTest extends BBDbApiTestCase } /** - * @expectedException \Box_Exception + * @expectedException \FOSSBilling\Exception */ public function testCanSubmitTicketException() { diff --git a/tests/integration/bb-modules/mod_theme/ApiAdminTest.php b/tests/integration/bb-modules/mod_theme/ApiAdminTest.php index 42b015080..77c8cdf2f 100644 --- a/tests/integration/bb-modules/mod_theme/ApiAdminTest.php +++ b/tests/integration/bb-modules/mod_theme/ApiAdminTest.php @@ -25,7 +25,7 @@ class Api_Admin_ThemeTest extends BBDbApiTestCase } /** - * @expectedException \Box_Exception + * @expectedException \FOSSBilling\Exception */ public function testThemeNotFound() { diff --git a/tests/library/Box/Box_PeriodTest.php b/tests/library/Box/Box_PeriodTest.php index aa5ca4b6e..c4735d30e 100644 --- a/tests/library/Box/Box_PeriodTest.php +++ b/tests/library/Box/Box_PeriodTest.php @@ -8,14 +8,14 @@ class Box_PeriodTest extends PHPUnit\Framework\TestCase public function testException() { - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Invalid period code. Period definition must be 2 chars length'); $p = new Box_Period('1'); } public function testException2() { - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Period Error. Unit Z is not defined'); $p = new Box_Period('1Z'); } diff --git a/tests/library/Box/Box_ValidateTest.php b/tests/library/Box/Box_ValidateTest.php index 4a2912e2c..300cb1e84 100644 --- a/tests/library/Box/Box_ValidateTest.php +++ b/tests/library/Box/Box_ValidateTest.php @@ -52,7 +52,7 @@ class FOSSBilling_ValidateTest extends PHPUnit\Framework\TestCase 'id' => 'ID must be set' ); $v = new \FOSSBilling\Validate(); - $this->expectException(Box_Exception::class); + $this->expectException(FOSSBilling\Exception::class); $this->expectExceptionCode(0); $this->expectExceptionMessage('ID must be set'); $v->checkRequiredParamsForArray($required, $data); @@ -69,7 +69,7 @@ class FOSSBilling_ValidateTest extends PHPUnit\Framework\TestCase 'key' => 'KEY must be set' ); $v = new \FOSSBilling\Validate(); - $this->expectException(Box_Exception::class); + $this->expectException(FOSSBilling\Exception::class); $this->expectExceptionCode(0); $this->expectExceptionMessage('KEY must be set'); $v->checkRequiredParamsForArray($required, $data); @@ -87,7 +87,7 @@ class FOSSBilling_ValidateTest extends PHPUnit\Framework\TestCase $variables = array(':key' => 'placeholder_key'); $v = new \FOSSBilling\Validate(); - $this->expectException(Box_Exception::class); + $this->expectException(FOSSBilling\Exception::class); $this->expectExceptionCode(0); $this->expectExceptionMessage('KEY placeholder_key must be set'); $v->checkRequiredParamsForArray($required, $data, $variables); @@ -108,7 +108,7 @@ class FOSSBilling_ValidateTest extends PHPUnit\Framework\TestCase ':array' => 'config' ); $v = new \FOSSBilling\Validate(); - $this->expectException(Box_Exception::class); + $this->expectException(FOSSBilling\Exception::class); $this->expectExceptionCode(0); $this->expectExceptionMessage('KEY placeholder_key must be set for array config'); $v->checkRequiredParamsForArray($required, $data, $variables); @@ -127,7 +127,7 @@ class FOSSBilling_ValidateTest extends PHPUnit\Framework\TestCase $variables = array(':key' => 'placeholder_key'); $v = new \FOSSBilling\Validate(); - $this->expectException(Box_Exception::class); + $this->expectException(FOSSBilling\Exception::class); $this->expectExceptionCode(12345); $this->expectExceptionMessage('KEY placeholder_key must be set'); $v->checkRequiredParamsForArray($required, $data, $variables, 12345); @@ -144,7 +144,7 @@ class FOSSBilling_ValidateTest extends PHPUnit\Framework\TestCase ); $v = new \FOSSBilling\Validate(); - $this->expectException(Box_Exception::class); + $this->expectException(FOSSBilling\Exception::class); $this->expectExceptionCode(54321); $this->expectExceptionMessage('KEY must be set'); $v->checkRequiredParamsForArray($required, $data, array(), 54321); @@ -177,7 +177,7 @@ class FOSSBilling_ValidateTest extends PHPUnit\Framework\TestCase $v = new \FOSSBilling\Validate(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage($required['message']); $v->checkRequiredParamsForArray($required, $data); @@ -195,7 +195,7 @@ class FOSSBilling_ValidateTest extends PHPUnit\Framework\TestCase $v = new \FOSSBilling\Validate(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage($required['message']); $v->checkRequiredParamsForArray($required, $data); diff --git a/tests/library/Registrar/Adapter/Registrar_Adapter_ResellerclubTest.php b/tests/library/Registrar/Adapter/Registrar_Adapter_ResellerclubTest.php index 20ef39958..e96bd606a 100644 --- a/tests/library/Registrar/Adapter/Registrar_Adapter_ResellerclubTest.php +++ b/tests/library/Registrar/Adapter/Registrar_Adapter_ResellerclubTest.php @@ -18,7 +18,7 @@ class Registrar_Adapter_ResellerclubTest extends PHPUnit\Framework\TestCase $options = array(); $this->expectException(Registrar_Exception::class); - $this->expectExceptionMessage('Domain registrar "ResellerClub" is not configured properly. Please update configuration parameter "ResellerClub Reseller ID" at "Configuration -> Domain registration".'); + $this->expectExceptionMessage('ResellerClub" domain registrar is not fully configured. Please configure the ResellerClub Reseller ID'); $adapter = new \Registrar_Adapter_Resellerclub($options); } @@ -30,7 +30,7 @@ class Registrar_Adapter_ResellerclubTest extends PHPUnit\Framework\TestCase ); $this->expectException(Registrar_Exception::class); - $this->expectExceptionMessage('Domain registrar "ResellerClub" is not configured properly. Please update configuration parameter "ResellerClub API Key" at "Configuration -> Domain registration".'); + $this->expectExceptionMessage('The "ResellerClub" domain registrar is not fully configured. Please configure the ResellerClub API Key'); new \Registrar_Adapter_Resellerclub($options); } diff --git a/tests/modules/Cart/Api/GuestTest.php b/tests/modules/Cart/Api/GuestTest.php index 84cfe0340..57cbf4b27 100644 --- a/tests/modules/Cart/Api/GuestTest.php +++ b/tests/modules/Cart/Api/GuestTest.php @@ -116,7 +116,7 @@ class GuestTest extends \BBTestCase 'currency' => 'EUR' ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Currency not found'); $result = $this->guestApi->set_currency($data); $this->assertTrue($result); @@ -276,7 +276,7 @@ class GuestTest extends \BBTestCase 'promocode' => 'CODE' ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->guestApi->apply_promo($data); $this->assertTrue($result); } @@ -315,7 +315,7 @@ class GuestTest extends \BBTestCase 'promocode' => 'CODE' ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->guestApi->apply_promo($data); $this->assertTrue($result); @@ -353,7 +353,7 @@ class GuestTest extends \BBTestCase 'promocode' => 'CODE' ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->guestApi->apply_promo($data); $this->assertTrue($result); diff --git a/tests/modules/Cart/ServiceTest.php b/tests/modules/Cart/ServiceTest.php index b256ad201..145bbc0e7 100644 --- a/tests/modules/Cart/ServiceTest.php +++ b/tests/modules/Cart/ServiceTest.php @@ -281,7 +281,7 @@ class ServiceTest extends \BBTestCase $cart = new \Model_Cart(); $cart->loadBean(new \DummyBean()); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->service->removeProduct($cart, rand(1, 100)); $this->assertTrue($result); } @@ -435,7 +435,7 @@ class ServiceTest extends \BBTestCase $di['logger'] = $this->getMockBuilder('Box_Log')->getMock(); $serviceMock->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $serviceMock->applyPromo($cart, $promo); $this->assertTrue($result); } @@ -705,7 +705,7 @@ class ServiceTest extends \BBTestCase } /** - * @expectedException \Box_Exception + * @expectedException \FOSSBilling\Exception */ public function testCheckoutCartClientIsNotAbleToUsePromoException() { @@ -735,7 +735,7 @@ class ServiceTest extends \BBTestCase $di['logger'] = $this->getMockBuilder('Box_Log')->getMock(); $serviceMock->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $serviceMock->checkoutCart($cart, $client); $this->assertIsArray($result); @@ -812,12 +812,12 @@ class ServiceTest extends \BBTestCase $validatorMock = $this->getMockBuilder('\FOSSBilling\Validate')->disableOriginalConstructor()->getMock(); $validatorMock->expects($this->atLeastOnce()) ->method('checkRequiredParamsForArray') - ->willThrowException(new \Box_Exception('Period parameter not passed')); + ->willThrowException(new \FOSSBilling\Exception('Period parameter not passed')); $di['validator'] = $validatorMock; $serviceMock->setDi($di); $productModel->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Period parameter not passed'); $serviceMock->addItem($cartModel, $productModel, $data); } @@ -860,7 +860,7 @@ class ServiceTest extends \BBTestCase $serviceMock->setDi($di); $productModel->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Selected billing period is invalid'); $serviceMock->addItem($cartModel, $productModel, $data); } @@ -899,7 +899,7 @@ class ServiceTest extends \BBTestCase $serviceMock->setDi($di); $productModel->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage("This item is currently out of stock"); $serviceMock->addItem($cartModel, $productModel, $data); } diff --git a/tests/modules/Client/Api/AdminTest.php b/tests/modules/Client/Api/AdminTest.php index c2835eb65..c1b810684 100644 --- a/tests/modules/Client/Api/AdminTest.php +++ b/tests/modules/Client/Api/AdminTest.php @@ -196,7 +196,7 @@ class AdminTest extends \BBTestCase $admin_Client->setDi($di); $admin_Client->setService($serviceMock); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Email is already registered.'); $admin_Client->create($data); } @@ -402,7 +402,7 @@ class AdminTest extends \BBTestCase $admin_Client = new \Box\Mod\Client\Api\Admin(); $admin_Client->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Can not change email. It is already registered.'); $admin_Client->update($data); } @@ -417,7 +417,7 @@ class AdminTest extends \BBTestCase $di['validator'] = new \FOSSBilling\Validate(); $admin_Client->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Id required'); $admin_Client->update($data); } @@ -491,7 +491,7 @@ class AdminTest extends \BBTestCase $di['validator'] = $validatorMock; $admin_Client->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Passwords do not match'); $admin_Client->change_password($data); } diff --git a/tests/modules/Client/Api/GuestTest.php b/tests/modules/Client/Api/GuestTest.php index 8af426963..c4dd286ec 100644 --- a/tests/modules/Client/Api/GuestTest.php +++ b/tests/modules/Client/Api/GuestTest.php @@ -115,7 +115,7 @@ class GuestTest extends \BBTestCase $client->setDi($di); $client->setService($serviceMock); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Email is already registered. You may want to login instead of registering.'); $client->create($data); } @@ -140,7 +140,7 @@ class GuestTest extends \BBTestCase }); $client->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('New registrations are temporary disabled'); $client->create($data); } @@ -168,7 +168,7 @@ class GuestTest extends \BBTestCase $di['validator'] = $validatorMock; $client->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Passwords do not match.'); $client->create($data); } @@ -411,7 +411,7 @@ class GuestTest extends \BBTestCase $client->setDi($di); // Expect a Box_Exception to be thrown with a specific message - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('The link has expired or you have already reset your password.'); $client->update_password($data); } diff --git a/tests/modules/Client/ServiceBalanceTest.php b/tests/modules/Client/ServiceBalanceTest.php index c469f1c42..c2288eb59 100644 --- a/tests/modules/Client/ServiceBalanceTest.php +++ b/tests/modules/Client/ServiceBalanceTest.php @@ -68,7 +68,7 @@ class ServiceBalanceTest extends \BBTestCase 'rel_id' => 1, ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Funds description is invalid'); $service->deductFunds($clientModel, $amount, $description, $extra); } @@ -87,7 +87,7 @@ class ServiceBalanceTest extends \BBTestCase 'rel_id' => 1, ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Funds amount is invalid'); $service->deductFunds($clientModel, $amount, $description, $extra); } diff --git a/tests/modules/Client/ServiceTest.php b/tests/modules/Client/ServiceTest.php index 8693604c0..a84e98dc4 100644 --- a/tests/modules/Client/ServiceTest.php +++ b/tests/modules/Client/ServiceTest.php @@ -47,7 +47,7 @@ class ServiceTest extends \BBTestCase { $clientService = new \Box\Mod\Client\Service(); $clientService->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Invalid email confirmation link'); $clientService->approveClientEmailByHash(''); } @@ -427,7 +427,7 @@ class ServiceTest extends \BBTestCase { $clientService = new \Box\Mod\Client\Service(); $clientService->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Currency can not be changed. Client already have invoices issued.'); $clientService->canChangeCurrency($model, $currency); } @@ -541,7 +541,7 @@ class ServiceTest extends \BBTestCase { $clientService = new \Box\Mod\Client\Service(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Define clients currency before adding funds.'); $clientService->addFunds($modelClient, $amount, $description); @@ -559,7 +559,7 @@ class ServiceTest extends \BBTestCase { $clientService = new \Box\Mod\Client\Service(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Funds amount is invalid'); $clientService->addFunds($modelClient, $amount, $description); } @@ -577,7 +577,7 @@ class ServiceTest extends \BBTestCase { $clientService = new \Box\Mod\Client\Service(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Funds description is invalid'); $result = $clientService->addFunds($modelClient, $amount, $description); $this->assertTrue($result); @@ -757,7 +757,7 @@ class ServiceTest extends \BBTestCase { $service->setDi($di); $data = array('id' => 0); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Client not found'); $service->get($data); } @@ -993,7 +993,7 @@ class ServiceTest extends \BBTestCase { $model = new \Model_ClientGroup(); $model->loadBean(new \DummyBean()); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Can not remove group with clients'); $service->deleteGroup($model); } @@ -1166,7 +1166,7 @@ class ServiceTest extends \BBTestCase { $service = new \Box\Mod\Client\Service(); $service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Email can not be changed'); $service->canChangeEmail($clientModel, $email); } @@ -1184,7 +1184,7 @@ class ServiceTest extends \BBTestCase { $service = new \Box\Mod\Client\Service(); $service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Field Id cannot be empty'); $service->checkExtraRequiredFields($data); } @@ -1207,7 +1207,7 @@ class ServiceTest extends \BBTestCase { $data = array(); $service = new \Box\Mod\Client\Service(); $service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Field custom_field_title cannot be empty'); $service->checkCustomFields($data); diff --git a/tests/modules/Currency/Api/Api_AdminTest.php b/tests/modules/Currency/Api/Api_AdminTest.php index 863f1a8c5..fae939a69 100644 --- a/tests/modules/Currency/Api/Api_AdminTest.php +++ b/tests/modules/Currency/Api/Api_AdminTest.php @@ -342,8 +342,8 @@ class Api_AdminTest extends \BBTestCase $adminApi->setService($service); $adminApi->setDi($di); - $this->expectException(\Box_Exception::class); - $adminApi->create($data); //Expecting \Box_Exception every time + $this->expectException(\FOSSBilling\Exception::class); + $adminApi->create($data); //Expecting \FOSSBilling\Exception every time } public function testCreate() @@ -418,7 +418,7 @@ class Api_AdminTest extends \BBTestCase } /** - * @expectedException \Box_Exception + * @expectedException \FOSSBilling\Exception */ public function testDeleteException() { @@ -431,15 +431,15 @@ class Api_AdminTest extends \BBTestCase $validatorMock = $this->getMockBuilder('\FOSSBilling\Validate')->getMock(); $validatorMock->expects($this->atLeastOnce()) - ->method('checkRequiredParamsForArray')->willThrowException(new \Box_Exception('')); + ->method('checkRequiredParamsForArray')->willThrowException(new \FOSSBilling\Exception('')); $di = new \Pimple\Container(); $di['validator'] = $validatorMock; $adminApi->setDi($di); $adminApi->setService($service); - $this->expectException(\Box_Exception::class); - $adminApi->delete(array()); //Expecting \Box_Exception every time + $this->expectException(\FOSSBilling\Exception::class); + $adminApi->delete(array()); //Expecting \FOSSBilling\Exception every time } public function testDelete() @@ -494,7 +494,7 @@ class Api_AdminTest extends \BBTestCase } /** - * @expectedException \Box_Exception + * @expectedException \FOSSBilling\Exception * @dataProvider SetDefaultExceptionProvider */ public function testSetDefaultException($data, $getByCodeCalled, $getByCodeReturn) @@ -516,8 +516,8 @@ class Api_AdminTest extends \BBTestCase $adminApi->setDi($di); $adminApi->setService($service); - $this->expectException(\Box_Exception::class); - $adminApi->set_default($data); //Expecting \Box_Exception every time + $this->expectException(\FOSSBilling\Exception::class); + $adminApi->set_default($data); //Expecting \FOSSBilling\Exception every time } public function testSetDefault() diff --git a/tests/modules/Currency/Api/Api_GuestTest.php b/tests/modules/Currency/Api/Api_GuestTest.php index ed85c51ee..f274213a5 100644 --- a/tests/modules/Currency/Api/Api_GuestTest.php +++ b/tests/modules/Currency/Api/Api_GuestTest.php @@ -109,8 +109,8 @@ class Api_GuestTest extends \BBTestCase ->will($this->returnValue(null)); $guestApi->setService($service); - $this->expectException(\Box_Exception::class); - $result = $guestApi->get(array()); //Expecting \Box_Exception + $this->expectException(\FOSSBilling\Exception::class); + $result = $guestApi->get(array()); //Expecting \FOSSBilling\Exception } public function formatPriceFormatProvider() diff --git a/tests/modules/Currency/ServiceTest.php b/tests/modules/Currency/ServiceTest.php index e407f0e57..ebe2ee44c 100644 --- a/tests/modules/Currency/ServiceTest.php +++ b/tests/modules/Currency/ServiceTest.php @@ -58,7 +58,7 @@ class ServiceTest extends \BBTestCase $di['db'] = $db; $service->setDi($di); $code = 'EUR'; - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $service->getBaseCurrencyRate($code); //Expecting exception } @@ -314,8 +314,8 @@ class ServiceTest extends \BBTestCase $di['db'] = $db; $service->setDi($di); - $this->expectException(\Box_Exception::class); - $service->setAsDefault($model); //Currency code is null, should throw an \Box_Exception + $this->expectException(\FOSSBilling\Exception::class); + $service->setAsDefault($model); //Currency code is null, should throw an \FOSSBilling\Exception } public function testgetPairs() @@ -522,8 +522,8 @@ class ServiceTest extends \BBTestCase $di['db'] = $db; $service->setDi($di); - $this->expectException(\Box_Exception::class); - $service->rm($model); //will throw \Box_Exception because default currency can not be removed + $this->expectException(\FOSSBilling\Exception::class); + $service->rm($model); //will throw \FOSSBilling\Exception because default currency can not be removed } @@ -566,8 +566,8 @@ class ServiceTest extends \BBTestCase $di['db'] = $db; $service->setDi($di); - $this->expectException(\Box_Exception::class); - $service->rm($model); //will throw \Box_Exception because currency code is not set + $this->expectException(\FOSSBilling\Exception::class); + $service->rm($model); //will throw \FOSSBilling\Exception because currency code is not set } public function testToApiArray() @@ -687,9 +687,9 @@ class ServiceTest extends \BBTestCase $service->expects($this->atLeastOnce()) ->method('getByCode') ->will($this->returnValue(false)); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); - $service->updateCurrency($code, $format, $title, $price_format, $conversion_rate); //Expecting \Box_Exception every time + $service->updateCurrency($code, $format, $title, $price_format, $conversion_rate); //Expecting \FOSSBilling\Exception every time } public function testUpdateConversionRateException() @@ -714,8 +714,8 @@ class ServiceTest extends \BBTestCase ->method('getByCode') ->will($this->returnValue($model)); - $this->expectException(\Box_Exception::class); - $service->updateCurrency($code, $format, $title, $price_format, $conversion_rate); //Expecting \Box_Exception every time + $this->expectException(\FOSSBilling\Exception::class); + $service->updateCurrency($code, $format, $title, $price_format, $conversion_rate); //Expecting \FOSSBilling\Exception every time } public function testUpdateCurrencyRates() @@ -847,7 +847,7 @@ class ServiceTest extends \BBTestCase ->method('getByCode') ->will($this->returnValue(null)); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $service->deleteCurrencyByCode($code); $this->assertIsBool($result); diff --git a/tests/modules/Email/Api/Api_AdminTest.php b/tests/modules/Email/Api/Api_AdminTest.php index 37ba465c9..2df53ae2a 100644 --- a/tests/modules/Email/Api/Api_AdminTest.php +++ b/tests/modules/Email/Api/Api_AdminTest.php @@ -200,7 +200,7 @@ class Api_AdminTest extends \BBTestCase $di['validator'] = $validatorMock; $adminApi->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Email not found'); $adminApi->email_resend($data); } @@ -229,7 +229,7 @@ class Api_AdminTest extends \BBTestCase $di['validator'] = $validatorMock; $adminApi->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Email not found'); $adminApi->email_delete($data); } @@ -401,7 +401,7 @@ class Api_AdminTest extends \BBTestCase $di['validator'] = $validatorMock; $adminApi->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Email template not found'); $adminApi->template_delete($data); } @@ -453,7 +453,7 @@ class Api_AdminTest extends \BBTestCase $di = new \Pimple\Container(); $di['validator'] = $validatorMock; $adminApi->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $adminApi->template_send(array('code' => 'code')); } diff --git a/tests/modules/Email/Api/Api_ClientTest.php b/tests/modules/Email/Api/Api_ClientTest.php index 246e26e2b..12bf66cd0 100644 --- a/tests/modules/Email/Api/Api_ClientTest.php +++ b/tests/modules/Email/Api/Api_ClientTest.php @@ -100,7 +100,7 @@ class Api_ClientTest extends \BBTestCase $clientApi->setService($service); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $clientApi->get(array('id' => 1)); $this->assertIsArray($result); @@ -168,7 +168,7 @@ class Api_ClientTest extends \BBTestCase $clientApi->setService($service); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $clientApi->resend(array('id' => 1)); $this->assertIsArray($result); @@ -235,7 +235,7 @@ class Api_ClientTest extends \BBTestCase $clientApi->setService($service); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $clientApi->delete(array('id' => 1)); $this->assertIsArray($result); diff --git a/tests/modules/Email/ServiceTest.php b/tests/modules/Email/ServiceTest.php index 55c6e0188..ef3c8a13d 100644 --- a/tests/modules/Email/ServiceTest.php +++ b/tests/modules/Email/ServiceTest.php @@ -849,7 +849,7 @@ class ServiceTest extends \BBTestCase $di['db'] = $db; $service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $service->getEmailById(5); } @@ -1105,7 +1105,7 @@ class ServiceTest extends \BBTestCase $di['db'] = $db; $service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $service->resetTemplateByCode('mod_email_test'); } diff --git a/tests/modules/Extension/Api/AdminTest.php b/tests/modules/Extension/Api/AdminTest.php index 91c93216d..739b4103c 100644 --- a/tests/modules/Extension/Api/AdminTest.php +++ b/tests/modules/Extension/Api/AdminTest.php @@ -127,7 +127,7 @@ class AdminTest extends \BBTestCase { $this->api->setDi($di); $this->api->setService($serviceMock); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Extension not found'); $this->api->update($data); } diff --git a/tests/modules/Extension/Api/GuestTest.php b/tests/modules/Extension/Api/GuestTest.php index 7a7ce293b..9e6aa042f 100644 --- a/tests/modules/Extension/Api/GuestTest.php +++ b/tests/modules/Extension/Api/GuestTest.php @@ -103,7 +103,7 @@ class GuestTest extends \BBTestCase { { $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Parameter ext is missing'); $this->api->settings($data); diff --git a/tests/modules/Extension/ServiceTest.php b/tests/modules/Extension/ServiceTest.php index 605358f64..59405e28f 100644 --- a/tests/modules/Extension/ServiceTest.php +++ b/tests/modules/Extension/ServiceTest.php @@ -320,7 +320,7 @@ class ServiceTest extends \BBTestCase { $di['extension_manager'] = $extensionMock; $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(252); $this->expectExceptionMessage('Visit the extension directory for more information on updating this extension.'); $this->service->update($model); @@ -415,7 +415,7 @@ class ServiceTest extends \BBTestCase { $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('FOSSBilling core modules can not be managed'); $this->service->deactivate($ext); } @@ -436,14 +436,14 @@ class ServiceTest extends \BBTestCase { $modMock->expects($this->atLeastOnce()) ->method('uninstall') - ->willThrowException(new \Box_Exception($exceptionMessage)); + ->willThrowException(new \FOSSBilling\Exception($exceptionMessage)); $di = new \Pimple\Container(); $di['mod'] = $di->protect(function ($name) use($modMock) { return $modMock;}); $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage($exceptionMessage); $this->service->deactivate($ext); } diff --git a/tests/modules/Formbuilder/Api/AdminTest.php b/tests/modules/Formbuilder/Api/AdminTest.php index 0656c1e87..7c83b6058 100644 --- a/tests/modules/Formbuilder/Api/AdminTest.php +++ b/tests/modules/Formbuilder/Api/AdminTest.php @@ -76,7 +76,7 @@ class AdminTest extends \BBTestCase { $di = new \Pimple\Container(); $di['validator'] = $validatorMock; $this->api->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Form style was not found in predefined list', 3657); $this->api->create_form($data); } @@ -113,7 +113,7 @@ class AdminTest extends \BBTestCase { public function testadd_fieldMissingType() { $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(2684); $this->expectExceptionMessage('Form field type is invalid'); $this->api->add_field($data); @@ -127,7 +127,7 @@ class AdminTest extends \BBTestCase { ); $this->api->setService($this->service); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(3658); $this->expectExceptionMessage('This input type must have unique values'); $this->api->add_field($data); @@ -142,7 +142,7 @@ class AdminTest extends \BBTestCase { $this->api->setService($this->service); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(9846); $this->expectExceptionMessage('Form id was not passed'); $this->api->add_field($data); @@ -348,7 +348,7 @@ class AdminTest extends \BBTestCase { { $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(9958); $this->expectExceptionMessage('Form id was not passed'); $this->api->copy_form($data); @@ -358,7 +358,7 @@ class AdminTest extends \BBTestCase { { $data = array('form_id' => 1); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(9842); $this->expectExceptionMessage('Form name was not passed'); $this->api->copy_form($data); @@ -407,7 +407,7 @@ class AdminTest extends \BBTestCase { ); unset($data[ $missingField ]); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage($exceptionMessage, $exceptionCode); $this->api->update_form_settings($data); } diff --git a/tests/modules/Formbuilder/ServiceTest.php b/tests/modules/Formbuilder/ServiceTest.php index 6e3805ab3..2fc278b1b 100644 --- a/tests/modules/Formbuilder/ServiceTest.php +++ b/tests/modules/Formbuilder/ServiceTest.php @@ -234,7 +234,7 @@ class ServiceTest extends \BBTestCase { $serviceMock->expects($this->atLeastOnce()) ->method('getField'); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(7628); $this->expectExceptionMessage('Unfortunately field with this name exists in this form already. Form must have different field names.'); $serviceMock->updateField($data); @@ -263,7 +263,7 @@ class ServiceTest extends \BBTestCase { $serviceMock->expects($this->atLeastOnce()) ->method('getField'); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(1597); $this->expectExceptionMessage(ucfirst($data['type']).' values must be unique'); $serviceMock->updateField($data); @@ -292,7 +292,7 @@ class ServiceTest extends \BBTestCase { $serviceMock->expects($this->atLeastOnce()) ->method('getField'); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(1598); $this->expectExceptionMessage(ucfirst($data['type']).' labels must be unique'); $serviceMock->updateField($data); @@ -323,7 +323,7 @@ class ServiceTest extends \BBTestCase { $serviceMock->expects($this->atLeastOnce()) ->method('getField'); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(3510); $this->expectExceptionMessage('Textarea size options must be integer values'); $serviceMock->updateField($data); diff --git a/tests/modules/Hook/Api/AdminTest.php b/tests/modules/Hook/Api/AdminTest.php index 512e5f86f..11e338dc4 100644 --- a/tests/modules/Hook/Api/AdminTest.php +++ b/tests/modules/Hook/Api/AdminTest.php @@ -52,7 +52,7 @@ class AdminTest extends \BBTestCase { { $data['event'] = 'testEvent'; - $configMock = array('debug' => true); + $configMock = array('debug_and_monitoring' => ['debug' => true]); $logMock = $this->getMockBuilder('\Box_log')->getMock(); diff --git a/tests/modules/Invoice/Api/AdminTest.php b/tests/modules/Invoice/Api/AdminTest.php index 15497c914..17d241e59 100644 --- a/tests/modules/Invoice/Api/AdminTest.php +++ b/tests/modules/Invoice/Api/AdminTest.php @@ -386,7 +386,7 @@ class AdminTest extends \BBTestCase { $this->api->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage(sprintf('Order %d is free. No need to generate invoice.', $model->id)); $this->api->renewal_invoice($data); } @@ -1134,7 +1134,7 @@ class AdminTest extends \BBTestCase { $this->api->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Client currency must match subscription currency. Check if clients currency is defined.'); $this->api->subscription_create($data); } diff --git a/tests/modules/Invoice/Api/ClientTest.php b/tests/modules/Invoice/Api/ClientTest.php index 6439f5e83..e8d4c6d70 100644 --- a/tests/modules/Invoice/Api/ClientTest.php +++ b/tests/modules/Invoice/Api/ClientTest.php @@ -75,7 +75,7 @@ class ClientTest extends \BBTestCase { $this->api->setIdentity(new \Model_Admin()); $data['hash'] = md5(1); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Invoice was not found'); $this->api->get($data); } @@ -133,7 +133,7 @@ class ClientTest extends \BBTestCase { $this->api->setIdentity(new \Model_Admin()); $data['hash'] = md5(1); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Invoice was not found'); $this->api->update($data); } @@ -160,7 +160,7 @@ class ClientTest extends \BBTestCase { $this->api->setIdentity(new \Model_Admin()); $data['hash'] = md5(1); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Paid Invoice can not be modified'); $this->api->update($data); } @@ -238,7 +238,7 @@ class ClientTest extends \BBTestCase { $data['order_id'] = 1; - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage(sprintf('Order %d is free. No need to generate invoice.', $clientOrder->id)); $this->api->renewal_invoice($data); @@ -270,7 +270,7 @@ class ClientTest extends \BBTestCase { $data['order_id'] = 1; - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Order not found'); $this->api->renewal_invoice($data); } diff --git a/tests/modules/Invoice/Api/GuestTest.php b/tests/modules/Invoice/Api/GuestTest.php index ac2fb9391..1676eb932 100644 --- a/tests/modules/Invoice/Api/GuestTest.php +++ b/tests/modules/Invoice/Api/GuestTest.php @@ -75,7 +75,7 @@ class GuestTest extends \BBTestCase { $this->api->setIdentity(new \Model_Admin()); $data['hash'] = md5(1); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Invoice was not found'); $this->api->get($data); } @@ -133,7 +133,7 @@ class GuestTest extends \BBTestCase { $this->api->setIdentity(new \Model_Admin()); $data['hash'] = md5(1); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Invoice was not found'); $this->api->update($data); } @@ -160,7 +160,7 @@ class GuestTest extends \BBTestCase { $this->api->setIdentity(new \Model_Admin()); $data['hash'] = md5(1); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Paid Invoice can not be modified'); $this->api->update($data); } @@ -204,7 +204,7 @@ class GuestTest extends \BBTestCase { 'gateway_id' => '', ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(810); $this->expectExceptionMessage('Invoice hash not passed. Missing param hash'); $this->api->payment($data); @@ -216,7 +216,7 @@ class GuestTest extends \BBTestCase { 'hash' => '', ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(811); $this->expectExceptionMessage('Payment method not found. Missing param gateway_id'); $this->api->payment($data); diff --git a/tests/modules/Invoice/ServiceInvoiceItemTest.php b/tests/modules/Invoice/ServiceInvoiceItemTest.php index 095ed656a..73f51b382 100644 --- a/tests/modules/Invoice/ServiceInvoiceItemTest.php +++ b/tests/modules/Invoice/ServiceInvoiceItemTest.php @@ -95,7 +95,7 @@ class ServiceInvoiceItemTest extends \BBTestCase $di['db'] = $dbMock; $serviceMock->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage(sprintf('Could not activate proforma item. Order %d not found', $orderId)); $serviceMock->executeTask($invoiceItemModel); } diff --git a/tests/modules/Invoice/ServicePayGatewayTest.php b/tests/modules/Invoice/ServicePayGatewayTest.php index 7704ae39b..f362fd1c4 100644 --- a/tests/modules/Invoice/ServicePayGatewayTest.php +++ b/tests/modules/Invoice/ServicePayGatewayTest.php @@ -138,7 +138,7 @@ class ServicePayGatewayTest extends \BBTestCase { ->method('getAvailable') ->will($this->returnValue(array())); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Payment gateway is not available for installation.'); $serviceMock->install($code); } @@ -362,7 +362,7 @@ class ServicePayGatewayTest extends \BBTestCase { $di['url'] = $urlMock; $serviceMock->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Payment gateway was not found'); $serviceMock->getPaymentAdapter($payGatewayModel, $invoiceModel); } @@ -399,7 +399,7 @@ class ServicePayGatewayTest extends \BBTestCase { ->method('getAdapterClassName') ->will($this->returnValue($expected)); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage(sprintf("Payment gateway class %s was not found", $expected)); $serviceMock->getAdapterConfig($payGatewayModel); } @@ -416,7 +416,7 @@ class ServicePayGatewayTest extends \BBTestCase { $serviceMock->expects($this->atLeastOnce()) ->method('getAdapterClassName'); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage(sprintf("Payment gateway %s was not found", $payGatewayModel->gateway)); $serviceMock->getAdapterConfig($payGatewayModel); } diff --git a/tests/modules/Invoice/ServiceTest.php b/tests/modules/Invoice/ServiceTest.php index 77a84cf95..7d181d3e4 100644 --- a/tests/modules/Invoice/ServiceTest.php +++ b/tests/modules/Invoice/ServiceTest.php @@ -1001,7 +1001,7 @@ class ServiceTest extends \BBTestCase $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage(sprintf("Invoice is related to order #%d. Please cancel order first.", $rel_id)); $this->service->deleteInvoiceByClient($invoiceModel); } @@ -1161,7 +1161,7 @@ class ServiceTest extends \BBTestCase $clientOrder->loadBean(new \DummyBean()); $clientOrder->price = 0; - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Invoices are not generated for 0 amount orders'); $this->service->generateForOrder($clientOrder); } @@ -1261,7 +1261,7 @@ class ServiceTest extends \BBTestCase $itemInvoiceServiceMock->expects($this->atLeastOnce()) ->method('executeTask') ->with($invoiceItemModel) - ->willThrowException(new \Box_Exception('tesitng exception..')); + ->willThrowException(new \FOSSBilling\Exception('tesitng exception..')); $itemInvoiceServiceMock->expects($this->atLeastOnce()) ->method('getAllNotExecutePaidItems') ->willReturn(array(array())); @@ -1401,7 +1401,7 @@ class ServiceTest extends \BBTestCase $clientModel = new \Model_Client(); $clientModel->loadBean(new \DummyBean()); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('You must have at least one active order before you can add funds so you cannot proceed at the current time!'); $this->service->generateFundsInvoice($clientModel, 10); } @@ -1425,7 +1425,7 @@ class ServiceTest extends \BBTestCase $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(981); $this->expectExceptionMessage('Amount must be at least ' . $minAmount); $this->service->generateFundsInvoice($clientModel, $fundsAmount); @@ -1450,7 +1450,7 @@ class ServiceTest extends \BBTestCase $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(982); $this->expectExceptionMessage('Amount cannot exceed ' . $maxAmount); $this->service->generateFundsInvoice($clientModel, $fundsAmount); @@ -1525,7 +1525,7 @@ class ServiceTest extends \BBTestCase $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(812); $this->expectExceptionMessage('Invoice not found'); $this->service->processInvoice($data); @@ -1554,7 +1554,7 @@ class ServiceTest extends \BBTestCase $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(813); $this->expectExceptionMessage('Payment method not found'); $this->service->processInvoice($data); @@ -1586,7 +1586,7 @@ class ServiceTest extends \BBTestCase $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(814); $this->expectExceptionMessage('Payment method not enabled'); $this->service->processInvoice($data); diff --git a/tests/modules/Invoice/ServiceTransactionTest.php b/tests/modules/Invoice/ServiceTransactionTest.php index 72e89f536..71044b91d 100644 --- a/tests/modules/Invoice/ServiceTransactionTest.php +++ b/tests/modules/Invoice/ServiceTransactionTest.php @@ -156,7 +156,7 @@ class ServiceTransactionTest extends \BBTestCase 'bb_gateway_id' => 1, ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Transaction invoice id is missing'); $this->service->create($data); } @@ -177,7 +177,7 @@ class ServiceTransactionTest extends \BBTestCase 'bb_invoice_id' => 2, ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Payment gateway id is missing'); $this->service->create($data); } @@ -418,7 +418,7 @@ class ServiceTransactionTest extends \BBTestCase ->getMock(); $serviceMock->expects($this->atLeastOnce()) ->method('processTransaction') - ->will($this->throwException(new \Box_Exception($exceptionMessage))); + ->will($this->throwException(new \FOSSBilling\Exception($exceptionMessage))); $dbMock = $this->getMockBuilder('\Box_Database')->getMock(); $dbMock->expects($this->atLeastOnce()) @@ -428,7 +428,7 @@ class ServiceTransactionTest extends \BBTestCase $di['db'] = $dbMock; $serviceMock->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage($exceptionMessage); $serviceMock->preProcessTransaction($transactionModel); } diff --git a/tests/modules/Kb/Api/Api_AdminTest.php b/tests/modules/Kb/Api/Api_AdminTest.php index 362217ddb..1f8156ab4 100644 --- a/tests/modules/Kb/Api/Api_AdminTest.php +++ b/tests/modules/Kb/Api/Api_AdminTest.php @@ -87,7 +87,7 @@ class Api_AdminTest extends \BBTestCase ->will($this->returnValue(null)); $di['validator'] = $validatorMock; $adminApi->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $adminApi->article_get($data); } @@ -216,7 +216,7 @@ class Api_AdminTest extends \BBTestCase ->will($this->returnValue(true)); $adminApi->setService($kbService); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $adminApi->article_delete(array('id' => rand(1, 100))); $this->assertTrue($result); } @@ -299,7 +299,7 @@ class Api_AdminTest extends \BBTestCase $validatorMock = $this->getMockBuilder('\FOSSBilling\Validate')->disableOriginalConstructor()->getMock(); $validatorMock->expects($this->atLeastOnce()) ->method('checkRequiredParamsForArray') - ->willThrowException(new \Box_Exception('Category ID not passed')); + ->willThrowException(new \FOSSBilling\Exception('Category ID not passed')); $di['validator'] = $validatorMock; $adminApi->setDi($di); @@ -309,7 +309,7 @@ class Api_AdminTest extends \BBTestCase ->will($this->returnValue(array())); $adminApi->setService($kbService); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $adminApi->category_get(array()); $this->assertIsArray($result); } @@ -342,7 +342,7 @@ class Api_AdminTest extends \BBTestCase 'id' => rand(1, 100) ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $adminApi->category_get($data);; $this->assertIsArray($result); } @@ -436,14 +436,14 @@ class Api_AdminTest extends \BBTestCase $validatorMock = $this->getMockBuilder('\FOSSBilling\Validate')->disableOriginalConstructor()->getMock(); $validatorMock->expects($this->atLeastOnce()) ->method('checkRequiredParamsForArray') - ->willThrowException(new \Box_Exception('Category ID not passed')); + ->willThrowException(new \FOSSBilling\Exception('Category ID not passed')); $di['validator'] = $validatorMock; $adminApi->setDi($di); $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $adminApi->category_update($data); $this->assertIsArray($result); } @@ -481,7 +481,7 @@ class Api_AdminTest extends \BBTestCase 'description' => 'Description', ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $adminApi->category_update($data); $this->assertIsArray($result); } @@ -539,12 +539,12 @@ class Api_AdminTest extends \BBTestCase $validatorMock = $this->getMockBuilder('\FOSSBilling\Validate')->disableOriginalConstructor()->getMock(); $validatorMock->expects($this->atLeastOnce()) ->method('checkRequiredParamsForArray') - ->willThrowException(new \Box_Exception('Category ID not passed')); + ->willThrowException(new \FOSSBilling\Exception('Category ID not passed')); $di['validator'] = $validatorMock; $adminApi->setDi($di); $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $adminApi->category_delete($data); $this->assertIsArray($result); } @@ -578,7 +578,7 @@ class Api_AdminTest extends \BBTestCase 'id' => rand(1, 100) ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $adminApi->category_delete($data); $this->assertIsArray($result); } diff --git a/tests/modules/Kb/Api/Api_GuestTest.php b/tests/modules/Kb/Api/Api_GuestTest.php index 6eb49986e..df13b51a3 100644 --- a/tests/modules/Kb/Api/Api_GuestTest.php +++ b/tests/modules/Kb/Api/Api_GuestTest.php @@ -117,7 +117,7 @@ class Api_GuestTest extends \BBTestCase ->will($this->returnValue(array())); $guestApi->setService($kbService); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $guestApi->article_get(array()); $this->assertIsArray($result); } @@ -148,7 +148,7 @@ class Api_GuestTest extends \BBTestCase $di = new \Pimple\Container(); $guestApi->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $guestApi->article_get($data); $this->assertIsArray($result); } @@ -180,7 +180,7 @@ class Api_GuestTest extends \BBTestCase 'slug' => 'article-slug' ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $guestApi->article_get($data); $this->assertIsArray($result); } @@ -308,7 +308,7 @@ class Api_GuestTest extends \BBTestCase ->will($this->returnValue(array())); $guestApi->setService($kbService); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $guestApi->category_get(array()); $this->assertIsArray($result); } @@ -337,7 +337,7 @@ class Api_GuestTest extends \BBTestCase $guestApi->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $guestApi->category_get($data); $this->assertIsArray($result); } @@ -366,7 +366,7 @@ class Api_GuestTest extends \BBTestCase $guestApi->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $guestApi->category_get($data); $this->assertIsArray($result); } diff --git a/tests/modules/Kb/ServiceTest.php b/tests/modules/Kb/ServiceTest.php index 1c964b3d9..2adcb22ae 100644 --- a/tests/modules/Kb/ServiceTest.php +++ b/tests/modules/Kb/ServiceTest.php @@ -337,7 +337,7 @@ class ServiceTest extends \BBTestCase $di['logger'] = $this->getMockBuilder('Box_Log')->getMock(); $service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $service->updateArticle($randId, $kb_article_category_id, $title, $slug, $status, $content, $views); $this->assertIsBool($result); $this->assertTrue($result); @@ -497,7 +497,7 @@ class ServiceTest extends \BBTestCase $model->KbArticle = new \Model_KbArticle(); $model->KbArticle->loadBean(new \DummyBean()); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $service->categoryRm($model); $this->assertNull($result); } diff --git a/tests/modules/Order/Api/Api_AdminTest.php b/tests/modules/Order/Api/Api_AdminTest.php index 77b80cdc9..92a2aa5e1 100644 --- a/tests/modules/Order/Api/Api_AdminTest.php +++ b/tests/modules/Order/Api/Api_AdminTest.php @@ -273,7 +273,7 @@ class Api_AdminTest extends \BBTestCase $apiMock->setService($serviceMock); $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $apiMock->unsuspend($data); $this->assertTrue($result); @@ -348,7 +348,7 @@ class Api_AdminTest extends \BBTestCase $apiMock->setService($serviceMock); $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $apiMock->uncancel($data); $this->assertTrue($result); @@ -479,7 +479,7 @@ class Api_AdminTest extends \BBTestCase $apiMock->setService($serviceMock); $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $apiMock->update_config($data); $this->assertTrue($result); diff --git a/tests/modules/Order/Api/Api_ClientTest.php b/tests/modules/Order/Api/Api_ClientTest.php index dfe681646..5d6918434 100644 --- a/tests/modules/Order/Api/Api_ClientTest.php +++ b/tests/modules/Order/Api/Api_ClientTest.php @@ -268,7 +268,7 @@ class Api_ClientTest extends PHPUnit\Framework\TestCase 'id' => rand(1, 100) ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $apiMock->delete($data); $this->assertTrue($result); @@ -341,7 +341,7 @@ class Api_ClientTest extends PHPUnit\Framework\TestCase 'id' => rand(1, 100) ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->api->get($data); } } diff --git a/tests/modules/Order/ServiceTest.php b/tests/modules/Order/ServiceTest.php index f9d0a6d7a..5b1ad3d49 100644 --- a/tests/modules/Order/ServiceTest.php +++ b/tests/modules/Order/ServiceTest.php @@ -1301,7 +1301,7 @@ class ServiceTest extends \BBTestCase }); $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Currency could not be determined for order'); $this->service->createOrder($modelClient, $modelProduct, array()); } @@ -1347,7 +1347,7 @@ class ServiceTest extends \BBTestCase $di['events_manager'] = $eventMock; $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(831); $this->expectExceptionMessage('Product 1 is out of stock.'); $this->service->createOrder($modelClient, $modelProduct, array()); @@ -1395,7 +1395,7 @@ class ServiceTest extends \BBTestCase $di['events_manager'] = $eventMock; $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(832); $this->expectExceptionMessage('Group ID parameter is missing for addon product order'); $this->service->createOrder($modelClient, $modelProduct, array()); @@ -1449,7 +1449,7 @@ class ServiceTest extends \BBTestCase ->willReturn(null); $serviceMock->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Parent order 1 was not found'); $serviceMock->createOrder($modelClient, $modelProduct, array('group_id' => 1)); } @@ -1550,7 +1550,7 @@ class ServiceTest extends \BBTestCase $clientOrderModel = new \Model_ClientOrder(); $clientOrderModel->loadBean(new \DummyBean()); $clientOrderModel->status = \Model_ClientOrder::STATUS_CANCELED; - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Only pending setup or failed orders can be activated'); $this->service->activateOrder($clientOrderModel); } @@ -1782,7 +1782,7 @@ class ServiceTest extends \BBTestCase $di['events_manager'] = $eventMock; $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Only active orders can be suspended'); $this->service->suspendFromOrder($clientOrderModel); } diff --git a/tests/modules/Paidsupport/ServiceTest.php b/tests/modules/Paidsupport/ServiceTest.php index 1cefa3610..05312946f 100644 --- a/tests/modules/Paidsupport/ServiceTest.php +++ b/tests/modules/Paidsupport/ServiceTest.php @@ -90,7 +90,7 @@ class ServiceTest extends \BBTestCase { $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage($paidSupportConfig['error_msg']); $this->service->enoughInBalanceToOpenTicket($clientModel); } diff --git a/tests/modules/Product/Api/AdminTest.php b/tests/modules/Product/Api/AdminTest.php index b150d5628..85cde0a83 100644 --- a/tests/modules/Product/Api/AdminTest.php +++ b/tests/modules/Product/Api/AdminTest.php @@ -129,7 +129,7 @@ class AdminTest extends \BBTestCase { $this->api->setService($serviceMock); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(413); $this->expectExceptionMessage('You have already created domain product'); $this->api->prepare($data); @@ -163,7 +163,7 @@ class AdminTest extends \BBTestCase { $this->api->setService($serviceMock); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(413); $this->expectExceptionMessage(sprintf('Product type %s is not registered', $data['type'])); $this->api->prepare($data); @@ -241,7 +241,7 @@ class AdminTest extends \BBTestCase { { $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('priority params is missing'); $this->api->update_priority($data); } @@ -648,7 +648,7 @@ class AdminTest extends \BBTestCase { { $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Promo id is missing'); $this->api->promo_get($data); } diff --git a/tests/modules/Product/Api/GuestTest.php b/tests/modules/Product/Api/GuestTest.php index 67ce26a5a..d18b1b25e 100644 --- a/tests/modules/Product/Api/GuestTest.php +++ b/tests/modules/Product/Api/GuestTest.php @@ -64,7 +64,7 @@ class GuestTest extends \BBTestCase { { $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Product ID or slug is missing'); $this->api->get($data); } @@ -134,7 +134,7 @@ class GuestTest extends \BBTestCase { $this->api->setDi($di); $this->api->setService($serviceMock); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Product not found'); $this->api->get($data); } diff --git a/tests/modules/Product/ServiceTest.php b/tests/modules/Product/ServiceTest.php index 2c1046ece..6ee8a88f7 100644 --- a/tests/modules/Product/ServiceTest.php +++ b/tests/modules/Product/ServiceTest.php @@ -247,7 +247,7 @@ class ServiceTest extends \BBTestCase $modelProduct = new \Model_Product(); $modelProduct->loadBean(new \DummyBean()); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Pricing type is required'); $serviceMock->updateProduct($modelProduct, $data); } @@ -471,7 +471,7 @@ class ServiceTest extends \BBTestCase $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Can not remove product which has active orders.'); $this->service->deleteProduct($model); } @@ -576,7 +576,7 @@ class ServiceTest extends \BBTestCase $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Can not remove product category with products'); $this->service->removeProductCategory($modelProductCategory); diff --git a/tests/modules/Profile/Api/AdminTest.php b/tests/modules/Profile/Api/AdminTest.php index b772631bd..f76103448 100644 --- a/tests/modules/Profile/Api/AdminTest.php +++ b/tests/modules/Profile/Api/AdminTest.php @@ -97,7 +97,7 @@ class AdminTest extends \BBTestCase $adminApi = new \Box\Mod\Profile\Api\Admin(); $adminApi->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $adminApi->change_password(array()); $this->fail('password should be passed'); diff --git a/tests/modules/Profile/ServiceTest.php b/tests/modules/Profile/ServiceTest.php index 8d2008633..a1bcd53df 100644 --- a/tests/modules/Profile/ServiceTest.php +++ b/tests/modules/Profile/ServiceTest.php @@ -256,7 +256,7 @@ class ServiceTest extends \BBTestCase $service = new Service(); $service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $service->updateClient($model, $data); $this->assertTrue($result); } @@ -311,7 +311,7 @@ class ServiceTest extends \BBTestCase $service = new Service(); $service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $service->updateClient($model, $data); $this->assertTrue($result); } diff --git a/tests/modules/Servicedomain/Api/Api_AdminTest.php b/tests/modules/Servicedomain/Api/Api_AdminTest.php index a044e6f2a..723206f53 100644 --- a/tests/modules/Servicedomain/Api/Api_AdminTest.php +++ b/tests/modules/Servicedomain/Api/Api_AdminTest.php @@ -271,7 +271,7 @@ class Api_AdminTest extends \BBTestCase $data = array( 'tld' => '.com' ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->adminApi->tld_get($data); } @@ -337,7 +337,7 @@ class Api_AdminTest extends \BBTestCase 'tld' => '.com' ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->adminApi->tld_delete($data); } @@ -394,7 +394,7 @@ class Api_AdminTest extends \BBTestCase 'tld' => '.com' ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->adminApi->tld_create($data); $this->assertIsInt($result); } @@ -452,7 +452,7 @@ class Api_AdminTest extends \BBTestCase 'tld' => '.com' ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->adminApi->tld_update($data); } @@ -571,7 +571,7 @@ class Api_AdminTest extends \BBTestCase 'code' => 'ResellerClub' ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->adminApi->registrar_install($data); $this->assertTrue($result); @@ -618,7 +618,7 @@ class Api_AdminTest extends \BBTestCase // Test case 2: Servicedomains associated with the registrar $serviceMock->expects($this->never())->method('registrarRm'); // Since there are servicedomains, registrarRm should not be called $dbMock->expects($this->once())->method('find')->will($this->returnValue([new \Model_ServiceDomain()])); // Mocking the find() method to return servicedomains - $this->expectException('\Box_Exception'); // Expecting an exception to be thrown + $this->expectException('\FOSSBilling\Exception'); // Expecting an exception to be thrown $this->expectExceptionCode(707); // Expecting the exception code to be 707 $result = $this->adminApi->registrar_delete($data); // This should throw an exception } @@ -642,7 +642,7 @@ class Api_AdminTest extends \BBTestCase $validatorMock = $this->getMockBuilder('\FOSSBilling\Validate')->disableOriginalConstructor()->getMock(); $validatorMock->expects($this->atLeastOnce()) ->method('checkRequiredParamsForArray') - ->willThrowException(new \Box_Exception('Registrar ID is missing')); + ->willThrowException(new \FOSSBilling\Exception('Registrar ID is missing')); $di['validator'] = $validatorMock; $this->adminApi->setDi($di); @@ -650,7 +650,7 @@ class Api_AdminTest extends \BBTestCase $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->adminApi->registrar_delete($data); $this->assertTrue($result); @@ -708,7 +708,7 @@ class Api_AdminTest extends \BBTestCase $validatorMock = $this->getMockBuilder('\FOSSBilling\Validate')->disableOriginalConstructor()->getMock(); $validatorMock->expects($this->atLeastOnce()) ->method('checkRequiredParamsForArray') - ->willThrowException(new \Box_Exception('Registrar ID is missing')); + ->willThrowException(new \FOSSBilling\Exception('Registrar ID is missing')); $di['validator'] = $validatorMock; $this->adminApi->setDi($di); @@ -716,7 +716,7 @@ class Api_AdminTest extends \BBTestCase $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->adminApi->registrar_copy($data); $this->assertTrue($result); @@ -774,7 +774,7 @@ class Api_AdminTest extends \BBTestCase $validatorMock = $this->getMockBuilder('\FOSSBilling\Validate')->disableOriginalConstructor()->getMock(); $validatorMock->expects($this->atLeastOnce()) ->method('checkRequiredParamsForArray') - ->willThrowException(new \Box_Exception('Registrar ID is missing')); + ->willThrowException(new \FOSSBilling\Exception('Registrar ID is missing')); $di['validator'] = $validatorMock; $this->adminApi->setDi($di); @@ -782,7 +782,7 @@ class Api_AdminTest extends \BBTestCase $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->adminApi->registrar_get($data); $this->assertIsArray($result); @@ -853,7 +853,7 @@ class Api_AdminTest extends \BBTestCase $validatorMock = $this->getMockBuilder('\FOSSBilling\Validate')->disableOriginalConstructor()->getMock(); $validatorMock->expects($this->atLeastOnce()) ->method('checkRequiredParamsForArray') - ->willThrowException(new \Box_Exception('Registrar ID is missing')); + ->willThrowException(new \FOSSBilling\Exception('Registrar ID is missing')); $di['validator'] = $validatorMock; $this->adminApi->setDi($di); @@ -861,7 +861,7 @@ class Api_AdminTest extends \BBTestCase $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->adminApi->registrar_update($data); $this->assertTrue($result); @@ -931,13 +931,13 @@ class Api_AdminTest extends \BBTestCase $validatorMock = $this->getMockBuilder('\FOSSBilling\Validate')->disableOriginalConstructor()->getMock(); $validatorMock->expects($this->atLeastOnce()) ->method('checkRequiredParamsForArray') - ->willThrowException(new \Box_Exception('Registrar ID is missing')); + ->willThrowException(new \FOSSBilling\Exception('Registrar ID is missing')); $di['validator'] = $validatorMock; $this->adminApi->setDi($di); $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->adminApi->update($data); $this->assertTrue($result); @@ -977,7 +977,7 @@ class Api_AdminTest extends \BBTestCase 'order_id' => rand(1, 100) ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->adminApi->update($data); $this->assertTrue($result); diff --git a/tests/modules/Servicedomain/Api/Api_ClientTest.php b/tests/modules/Servicedomain/Api/Api_ClientTest.php index 3f04f129a..032cfe76f 100644 --- a/tests/modules/Servicedomain/Api/Api_ClientTest.php +++ b/tests/modules/Servicedomain/Api/Api_ClientTest.php @@ -241,7 +241,7 @@ class Api_ClientTest extends \BBTestCase $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->clientApi->lock($data); $this->assertTrue($result); @@ -275,7 +275,7 @@ class Api_ClientTest extends \BBTestCase 'order_id' => rand(1, 100) ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->clientApi->lock($data); $this->assertTrue($result); @@ -309,7 +309,7 @@ class Api_ClientTest extends \BBTestCase 'order_id' => rand(1, 100) ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->clientApi->lock($data); $this->assertTrue($result); diff --git a/tests/modules/Servicedomain/Api/Api_GuestTest.php b/tests/modules/Servicedomain/Api/Api_GuestTest.php index b37e0a538..b968220ca 100644 --- a/tests/modules/Servicedomain/Api/Api_GuestTest.php +++ b/tests/modules/Servicedomain/Api/Api_GuestTest.php @@ -88,7 +88,7 @@ class Api_GuestTest extends \BBTestCase 'tld' => '.com' ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->guestApi->pricing($data); $this->assertIsArray($result); } @@ -139,7 +139,7 @@ class Api_GuestTest extends \BBTestCase 'sld' => 'example' ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->guestApi->check($data); } @@ -170,7 +170,7 @@ class Api_GuestTest extends \BBTestCase 'sld' => 'example' ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->guestApi->check($data); } @@ -201,7 +201,7 @@ class Api_GuestTest extends \BBTestCase 'sld' => 'example' ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->guestApi->check($data); } @@ -258,7 +258,7 @@ class Api_GuestTest extends \BBTestCase 'sld' => 'example' ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->guestApi->can_be_transferred($data); } @@ -286,7 +286,7 @@ class Api_GuestTest extends \BBTestCase 'sld' => 'example' ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->guestApi->can_be_transferred($data); } diff --git a/tests/modules/Servicedomain/ServiceTest.php b/tests/modules/Servicedomain/ServiceTest.php index 7f4d825b3..f92c18c00 100644 --- a/tests/modules/Servicedomain/ServiceTest.php +++ b/tests/modules/Servicedomain/ServiceTest.php @@ -154,7 +154,7 @@ class ServiceTest extends \BBTestCase $di['validator'] = $validatorMock; $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->service->validateOrderData($data); $this->assertNull($result); } @@ -199,7 +199,7 @@ class ServiceTest extends \BBTestCase $di['validator'] = $validatorMock; $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->service->validateOrderData($data); $this->assertNull($result); } @@ -275,7 +275,7 @@ class ServiceTest extends \BBTestCase $di['validator'] = $validatorMock; $serviceMock->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $serviceMock->validateOrderData($data); $this->assertNull($result); } @@ -373,7 +373,7 @@ class ServiceTest extends \BBTestCase $di['validator'] = $validatorMock; $serviceMock->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $serviceMock->validateOrderData($data); $this->assertNull($result); } @@ -502,7 +502,7 @@ class ServiceTest extends \BBTestCase $order = new \Model_ClientOrder(); $order->loadBean(new \DummyBean()); $order->client_id = rand(1, 100); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $serviceMock->action_create($order); } @@ -591,7 +591,7 @@ class ServiceTest extends \BBTestCase $order->loadBean(new \DummyBean()); $order->client_id = rand(1, 100); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->service->action_activate($order); } @@ -669,7 +669,7 @@ class ServiceTest extends \BBTestCase $order->id = rand(1, 100); $order->client_id = rand(1, 100); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->service->action_renew($order); $this->assertTrue($result); @@ -750,7 +750,7 @@ class ServiceTest extends \BBTestCase $order->id = rand(1, 100); $order->client_id = rand(1, 100); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->service->action_cancel($order); $this->assertTrue($result); @@ -875,7 +875,7 @@ class ServiceTest extends \BBTestCase $serviceDomainModel = new \Model_ServiceDomain(); $serviceDomainModel->loadBean(new \DummyBean()); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->service->updateNameservers($serviceDomainModel, $data); } @@ -1107,7 +1107,7 @@ class ServiceTest extends \BBTestCase public function testcanBeTransferredEmptySldException() { - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->service->canBeTransferred(new \Model_Tld(), ''); } @@ -1117,7 +1117,7 @@ class ServiceTest extends \BBTestCase $tldModel->loadBean(new \DummyBean()); $tldModel->allow_transfer = false; - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->service->canBeTransferred($tldModel, 'example'); } @@ -1166,7 +1166,7 @@ class ServiceTest extends \BBTestCase { $tldModel = new \Model_Tld(); $tldModel->loadBean(new \DummyBean()); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->service->isDomainAvailable($tldModel, ''); } @@ -1182,7 +1182,7 @@ class ServiceTest extends \BBTestCase $tldModel = new \Model_Tld(); $tldModel->loadBean(new \DummyBean()); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->service->isDomainAvailable($tldModel, 'example'); } @@ -1200,7 +1200,7 @@ class ServiceTest extends \BBTestCase $model->loadBean(new \DummyBean()); $model->allow_register = false; - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->service->isDomainAvailable($model, 'example'); } @@ -1793,7 +1793,7 @@ class ServiceTest extends \BBTestCase $model->loadBean(new \DummyBean()); $model->registrar = 'Non-Existing'; - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->service->registrarGetRegistrarAdapterConfig($model); $this->assertIsArray($result); } @@ -1804,7 +1804,7 @@ class ServiceTest extends \BBTestCase $model->loadBean(new \DummyBean()); $model->registrar = 'Non-Existing'; - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->service->registrarGetRegistrarAdapterConfig($model); } @@ -1837,7 +1837,7 @@ class ServiceTest extends \BBTestCase $model->loadBean(new \DummyBean()); $model->registrar = 'Non-Existing'; - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $serviceMock->registrarGetRegistrarAdapter($model); $this->assertInstanceOf('Registrar_Adapter_' . $model->registrar, $result); } @@ -1887,7 +1887,7 @@ class ServiceTest extends \BBTestCase $model->loadBean(new \DummyBean()); $model->id = rand(1, 100); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->service->registrarRm($model); } diff --git a/tests/modules/Servicedownloadable/Api/AdminTest.php b/tests/modules/Servicedownloadable/Api/AdminTest.php index fa599bdf7..7ab88a8db 100644 --- a/tests/modules/Servicedownloadable/Api/AdminTest.php +++ b/tests/modules/Servicedownloadable/Api/AdminTest.php @@ -44,7 +44,7 @@ class AdminTest extends \BBTestCase $di['validator'] = $validatorMock; $this->api->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('File was not uploaded'); $this->api->upload($data); } @@ -105,7 +105,7 @@ class AdminTest extends \BBTestCase $di['validator'] = $validatorMock; $this->api->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Order is not activated'); $this->api->update($data); } diff --git a/tests/modules/Servicedownloadable/Api/ClientTest.php b/tests/modules/Servicedownloadable/Api/ClientTest.php index 5e92d5601..542b227e4 100644 --- a/tests/modules/Servicedownloadable/Api/ClientTest.php +++ b/tests/modules/Servicedownloadable/Api/ClientTest.php @@ -27,7 +27,7 @@ class ClientTest extends \BBTestCase { { $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Order id is required'); $this->api->send_file($data); } @@ -51,7 +51,7 @@ class ClientTest extends \BBTestCase { $this->api->setIdentity($modelClient); $this->api->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Order not found'); $this->api->send_file($data); } @@ -81,7 +81,7 @@ class ClientTest extends \BBTestCase { $this->api->setDi($di); $this->api->setIdentity($modelClient); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Order is not activated'); $this->api->send_file($data); } diff --git a/tests/modules/Servicedownloadable/ServiceTest.php b/tests/modules/Servicedownloadable/ServiceTest.php index da13b2a12..cab410612 100644 --- a/tests/modules/Servicedownloadable/ServiceTest.php +++ b/tests/modules/Servicedownloadable/ServiceTest.php @@ -159,7 +159,7 @@ class ServiceTest extends \BBTestCase $di['request'] = $requestMock; $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Error uploading file'); $this->service->uploadProductFile($productModel); @@ -268,7 +268,7 @@ class ServiceTest extends \BBTestCase $di['request'] = $requestMock; $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Error uploading file'); $this->service->updateProductFile($serviceDownloadableModel, $orderModel); } @@ -293,7 +293,7 @@ class ServiceTest extends \BBTestCase $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(404); $this->expectExceptionMessage('File can not be downloaded at the moment. Please contact support'); $this->service->sendFile($serviceDownloadableModel); diff --git a/tests/modules/Servicehosting/Api/AdminTest.php b/tests/modules/Servicehosting/Api/AdminTest.php index 230c1aca3..b5f7fe79c 100644 --- a/tests/modules/Servicehosting/Api/AdminTest.php +++ b/tests/modules/Servicehosting/Api/AdminTest.php @@ -65,7 +65,7 @@ class AdminTest extends \BBTestCase { $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('plan_id is missing'); $this->api->change_plan($data); } @@ -379,7 +379,7 @@ class AdminTest extends \BBTestCase $this->api->setDi($di); // Now, we expect an exception to be thrown because the server is used by service_hostings - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(704); $this->api->server_delete($data); @@ -518,7 +518,7 @@ class AdminTest extends \BBTestCase // If the function doesn't throw an exception, then the test should assert the result $this->assertIsBool($result); $this->assertTrue($result); - } catch (\Box_Exception $e) { + } catch (\FOSSBilling\Exception $e) { // If the function throws an exception, the test should fail $this->fail("Exception thrown: " . $e->getMessage()); } @@ -695,7 +695,7 @@ class AdminTest extends \BBTestCase $this->api->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Order is not activated'); $this->api->_getService($data); } diff --git a/tests/modules/Servicehosting/Api/ClientTest.php b/tests/modules/Servicehosting/Api/ClientTest.php index fbdf9f2b4..880cc1c26 100644 --- a/tests/modules/Servicehosting/Api/ClientTest.php +++ b/tests/modules/Servicehosting/Api/ClientTest.php @@ -169,7 +169,7 @@ class ClientTest extends \BBTestCase { $clientModel->id = 1; $this->api->setIdentity($clientModel); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Order is not activated'); $this->api->_getService($data); } @@ -196,7 +196,7 @@ class ClientTest extends \BBTestCase { $clientModel->id = 1; $this->api->setIdentity($clientModel); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Order not found'); $this->api->_getService($data); @@ -206,7 +206,7 @@ class ClientTest extends \BBTestCase { { $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Order id is required'); $this->api->_getService($data); } diff --git a/tests/modules/Servicehosting/Api/GuestTest.php b/tests/modules/Servicehosting/Api/GuestTest.php index 26c932abf..928eeba0b 100644 --- a/tests/modules/Servicehosting/Api/GuestTest.php +++ b/tests/modules/Servicehosting/Api/GuestTest.php @@ -73,7 +73,7 @@ class GuestTest extends \BBTestCase $this->api->setService($serviceMock); $this->api->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Product type is invalid'); $this->api->free_tlds(array('product_id' => 1)); } diff --git a/tests/modules/Servicehosting/ServiceTest.php b/tests/modules/Servicehosting/ServiceTest.php index 9c1a58300..4180f3ad4 100644 --- a/tests/modules/Servicehosting/ServiceTest.php +++ b/tests/modules/Servicehosting/ServiceTest.php @@ -48,7 +48,7 @@ class ServiceTest extends \BBTestCase { unset ($data [ $field ]); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage($exceptionMessage, $excCode); $this->service->validateOrderData($data); } @@ -199,7 +199,7 @@ class ServiceTest extends \BBTestCase { $di['mod_service'] = $di->protect(function() use ($orderServiceMock) {return $orderServiceMock;}); $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage(sprintf('Order %d has no active service', $orderModel->id)); $this->service->action_renew($orderModel); @@ -257,7 +257,7 @@ class ServiceTest extends \BBTestCase { $di['mod_service'] = $di->protect(function() use ($orderServiceMock) {return $orderServiceMock;}); $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage(sprintf('Order %d has no active service', $orderModel->id)); $this->service->action_suspend($orderModel); @@ -315,7 +315,7 @@ class ServiceTest extends \BBTestCase { $di['mod_service'] = $di->protect(function() use ($orderServiceMock) {return $orderServiceMock;}); $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage(sprintf('Order %d has no active service', $orderModel->id)); $this->service->action_unsuspend($orderModel); @@ -372,7 +372,7 @@ class ServiceTest extends \BBTestCase { $di['mod_service'] = $di->protect(function() use ($orderServiceMock) {return $orderServiceMock;}); $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage(sprintf('Order %d has no active service', $orderModel->id)); $this->service->action_cancel($orderModel); } @@ -559,7 +559,7 @@ class ServiceTest extends \BBTestCase { $model->loadBean(new \DummyBean()); $data = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Account username is missing or is invalid'); $this->service->changeAccountUsername($orderModel, $model, $data); } @@ -612,7 +612,7 @@ class ServiceTest extends \BBTestCase { $model = new \Model_ServiceHosting(); $model->loadBean(new \DummyBean()); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Account ip is missing or is invalid'); $this->service->changeAccountIp($orderModel, $model, $data); } @@ -666,7 +666,7 @@ class ServiceTest extends \BBTestCase { $model = new \Model_ServiceHosting(); $model->loadBean(new \DummyBean()); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Domain sld or tld is missing'); $this->service->changeAccountDomain($orderModel, $model, $data); } @@ -720,7 +720,7 @@ class ServiceTest extends \BBTestCase { $model = new \Model_ServiceHosting(); $model->loadBean(new \DummyBean()); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Account password is missing or is invalid'); $this->service->changeAccountPassword($orderModel, $model, $data); } @@ -1000,7 +1000,7 @@ class ServiceTest extends \BBTestCase { $hostingServerModel = new \Model_ServiceHostingServer(); $hostingServerModel->loadBean(new \DummyBean()); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(654); $this->expectExceptionMessage('Invalid server manager. Server was not configured properly'); $this->service->getServerManager($hostingServerModel); @@ -1018,7 +1018,7 @@ class ServiceTest extends \BBTestCase { }); $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage(sprintf('Server manager %s is invalid', $hostingServerModel->manager)); $this->service->getServerManager($hostingServerModel); } diff --git a/tests/modules/Servicelicense/Api/AdminTest.php b/tests/modules/Servicelicense/Api/AdminTest.php index 7ea799fbc..ef324dedd 100644 --- a/tests/modules/Servicelicense/Api/AdminTest.php +++ b/tests/modules/Servicelicense/Api/AdminTest.php @@ -151,7 +151,7 @@ class AdminTest extends \BBTestCase { $this->api->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Order is not activated'); $this->api->_getService($data); } diff --git a/tests/modules/Servicelicense/Api/ClientTest.php b/tests/modules/Servicelicense/Api/ClientTest.php index 22d8b2f8b..d6a84c266 100644 --- a/tests/modules/Servicelicense/Api/ClientTest.php +++ b/tests/modules/Servicelicense/Api/ClientTest.php @@ -112,7 +112,7 @@ class ClientTest extends \BBTestCase { $clientModel->loadBean(new \DummyBean()); $this->api->setIdentity($clientModel); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Order is not activated'); $this->api->_getService($data); } diff --git a/tests/modules/Servicelicense/ServiceTest.php b/tests/modules/Servicelicense/ServiceTest.php index 6ab267719..57c5ceac6 100644 --- a/tests/modules/Servicelicense/ServiceTest.php +++ b/tests/modules/Servicelicense/ServiceTest.php @@ -179,7 +179,7 @@ class ServiceTest extends \BBTestCase $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->service->action_activate($clientOrderModel); $this->assertTrue($result); } @@ -206,7 +206,7 @@ class ServiceTest extends \BBTestCase $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage(sprintf('License plugin %s was not found', $serviceLicenseModel->plugin)); $this->service->action_activate($clientOrderModel); } @@ -229,7 +229,7 @@ class ServiceTest extends \BBTestCase $this->service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Could not activate order. Service was not created'); $this->service->action_activate($clientOrderModel); } @@ -667,7 +667,7 @@ class ServiceTest extends \BBTestCase $di = new \Pimple\Container(); $di['logger'] = $loggerMock; $di['license_server'] = $licenseServerMock; - $di['config'] = array('debug' => false); + $di['config'] = array('debug_and_monitoring' => ['debug' => false]); $this->service->setDi($di); $result = $this->service->checkLicenseDetails($data); @@ -696,7 +696,7 @@ class ServiceTest extends \BBTestCase $di = new \Pimple\Container(); $di['logger'] = $loggerMock; $di['license_server'] = $licenseServerMock; - $di['config'] = array('debug' => false); + $di['config'] = array('debug_and_monitoring' => ['debug' => false]); $this->service->setDi($di); $result = $this->service->checkLicenseDetails($data); diff --git a/tests/modules/Spamchecker/ServiceTest.php b/tests/modules/Spamchecker/ServiceTest.php index d4749156e..694225caf 100644 --- a/tests/modules/Spamchecker/ServiceTest.php +++ b/tests/modules/Spamchecker/ServiceTest.php @@ -94,7 +94,7 @@ class ServiceTest extends \BBTestCase { ->method('getDi') ->willReturn($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage(sprintf("Your IP address (%s) is blocked. Please contact our support to lift your block.", $clientIp), 403); $this->service->isBlockedIp($boxEventMock); } diff --git a/tests/modules/Staff/Api/AdminTest.php b/tests/modules/Staff/Api/AdminTest.php index b05aa3f21..2df2c0092 100644 --- a/tests/modules/Staff/Api/AdminTest.php +++ b/tests/modules/Staff/Api/AdminTest.php @@ -200,7 +200,7 @@ class AdminTest extends \BBTestCase { $di['validator'] = $validatorMock; $this->api->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Passwords do not match'); $this->api->change_password($data); } diff --git a/tests/modules/Staff/Api/GuestTest.php b/tests/modules/Staff/Api/GuestTest.php index eba433bcc..5e499a052 100644 --- a/tests/modules/Staff/Api/GuestTest.php +++ b/tests/modules/Staff/Api/GuestTest.php @@ -82,14 +82,14 @@ class GuestTest extends \BBTestCase 'password' => 'EasyToGuess', ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(55); $this->expectExceptionMessage('Administrator account already exists'); $this->api->create($data); } /** - * @expectedException \Box_Exception + * @expectedException \FOSSBilling\Exception */ public function testLoginWithoutEmail() { @@ -99,12 +99,12 @@ class GuestTest extends \BBTestCase $di['validator'] = new \FOSSBilling\Validate(); $guestApi->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $guestApi->login(array()); } /** - * @expectedException \Box_Exception + * @expectedException \FOSSBilling\Exception */ public function testLoginWithoutPassword() { @@ -114,7 +114,7 @@ class GuestTest extends \BBTestCase $di['validator'] = new \FOSSBilling\Validate(); $guestApi->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $guestApi->login(array('email'=>'email@domain.com')); } @@ -182,7 +182,7 @@ class GuestTest extends \BBTestCase $ip = '192.168.0.1'; $guestApi->setIp($ip); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(403); $this->expectExceptionMessage(sprintf('You are not allowed to login to admin area from %s address', $ip)); diff --git a/tests/modules/Staff/ServiceTest.php b/tests/modules/Staff/ServiceTest.php index 3daf88ef7..39e72d806 100644 --- a/tests/modules/Staff/ServiceTest.php +++ b/tests/modules/Staff/ServiceTest.php @@ -101,7 +101,7 @@ class ServiceTest extends \BBTestCase $service = new \Box\Mod\Staff\Service(); $service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(403); $this->expectExceptionMessage('Check your login details'); $service->login($email, $password, $ip); @@ -1002,7 +1002,7 @@ class ServiceTest extends \BBTestCase $service = new \Box\Mod\Staff\Service(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('This administrator account is protected and can not be removed'); $service->delete($adminModel); } @@ -1147,7 +1147,7 @@ class ServiceTest extends \BBTestCase $service = new \Box\Mod\Staff\Service(); $service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionCode(788954); $this->expectExceptionMessage(sprintf('Staff member with email %s is already registered', $data['email'])); $service->create($data); @@ -1332,7 +1332,7 @@ class ServiceTest extends \BBTestCase $service = new \Box\Mod\Staff\Service(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Administrators group can not be removed'); $service->deleteGroup($adminGroupModel); } @@ -1353,7 +1353,7 @@ class ServiceTest extends \BBTestCase $service = new \Box\Mod\Staff\Service(); $service->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Can not remove group which has staff members'); $service->deleteGroup($adminGroupModel); } diff --git a/tests/modules/Support/Api/Api_ClientTest.php b/tests/modules/Support/Api/Api_ClientTest.php index af481293e..d4c51f87f 100644 --- a/tests/modules/Support/Api/Api_ClientTest.php +++ b/tests/modules/Support/Api/Api_ClientTest.php @@ -222,7 +222,7 @@ class Api_ClientTest extends \BBTestCase 'content' => 'Content', 'id' => rand(1, 100), ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->clientApi->ticket_reply($data); $this->assertIsInt($result); diff --git a/tests/modules/Support/Api/Api_GuestTest.php b/tests/modules/Support/Api/Api_GuestTest.php index 471fa21e8..09867e160 100644 --- a/tests/modules/Support/Api/Api_GuestTest.php +++ b/tests/modules/Support/Api/Api_GuestTest.php @@ -72,7 +72,7 @@ class Api_GuestTest extends \BBTestCase 'message' => '', ); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->guestApi->ticket_create($data); $this->assertIsString($result); diff --git a/tests/modules/Support/ServiceTest.php b/tests/modules/Support/ServiceTest.php index 35a6fed55..c8a54bd55 100644 --- a/tests/modules/Support/ServiceTest.php +++ b/tests/modules/Support/ServiceTest.php @@ -438,7 +438,7 @@ class ServiceTest extends \BBTestCase $client->loadBean(new \DummyBean()); $client->id = rand(1, 100); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->service->findOneByClient($client, rand(1, 100)); $this->assertInstanceOf('Model_SupportTicket', $result); } @@ -1090,7 +1090,7 @@ class ServiceTest extends \BBTestCase $helpdesk = new \Model_SupportHelpdesk(); $helpdesk->loadBean(new \DummyBean()); $helpdesk->id = rand(1, 100); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->service->helpdeskRm($helpdesk); $this->assertTrue($result); } @@ -1541,7 +1541,7 @@ class ServiceTest extends \BBTestCase $serviceMock->setDi($di); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $serviceMock->ticketCreateForClient($client, $helpdesk, $data); } @@ -1617,7 +1617,7 @@ class ServiceTest extends \BBTestCase $ticket = new \Model_SupportTicket(); $ticket->loadBean(new \DummyBean()); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->service->messageCreateForTicket($ticket, null, 'Content'); $this->assertIsInt($result); $this->assertEquals($result, $randId); @@ -1663,7 +1663,7 @@ class ServiceTest extends \BBTestCase $client->loadBean(new \DummyBean()); $client->id = rand(1, 100); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $result = $this->service->publicFindOneByHash(sha1(uniqid())); $this->assertInstanceOf('Model_SupportPTicket', $result); } @@ -2581,7 +2581,7 @@ class ServiceTest extends \BBTestCase public function testCanClientSubmitNewTicket($ticket, $hours, $expected) { if (!$expected) { - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); } $dbMock = $this->getMockBuilder('\Box_Database')->disableOriginalConstructor()->getMock(); $dbMock->expects($this->atLeastOnce()) diff --git a/tests/modules/System/ServiceTest.php b/tests/modules/System/ServiceTest.php index 8da85a58a..031552357 100644 --- a/tests/modules/System/ServiceTest.php +++ b/tests/modules/System/ServiceTest.php @@ -19,7 +19,7 @@ class ServiceTest extends \BBTestCase public function testgetParamValueMissingKeyParam() { $param = array(); - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage('Parameter key is missing'); $this->service->getParamValue($param); diff --git a/tests/modules/Theme/Model/ThemeTest.php b/tests/modules/Theme/Model/ThemeTest.php index 1c7b9a176..a033cc3b3 100644 --- a/tests/modules/Theme/Model/ThemeTest.php +++ b/tests/modules/Theme/Model/ThemeTest.php @@ -17,7 +17,7 @@ class ThemeTest extends \BBTestCase { public function testNotExistingTheme() { $themeName = 'not existing theme'; - $this->expectException(\Box_Exception::class); + $this->expectException(\FOSSBilling\Exception::class); $this->expectExceptionMessage(sprintf('Theme "%s" does not exist', $themeName)); new \Box\Mod\Theme\Model\Theme($themeName); }