From cfd4b7635f6fc7396512735137c7ec4175fcf75a Mon Sep 17 00:00:00 2001 From: Stephan de Wit Date: Wed, 20 Apr 2022 10:05:26 +0200 Subject: [PATCH] Phalcon5 migration: provide compatibility layer between v4 and v5 (#5711) * phalcon5: update namespaces * phalcon5 Autoload: rename registerDirs() to setDirectories() * phalcon5: remove trailing slash * phalcon5: default to php74-phalcon * phalcon5: provide 4/5 compatibility layer except for AbstractValidator * MVC - Phalcon 5 migration and options to lose dependency of phalcon validation classes. Since Validation() in 5 moves to Filter\Validation (https://docs.phalcon.io/5.0/en/upgrade#general-notes) and the class is used in strict parameter passing, it will be difficult to import a situation which works both on 4 and 5. To prevent future issues, but keep the current situation functional with minimal changes, we wrapped Validation() into a class of our own. When validators inherit from BaseValidator, these are assumed to be less strict and bound to our own handling. Phalcon validations will follow the old path for now. Migrating existing validations on our end, should be as simple as changing the following lines: -use Phalcon\Validation\AbstractValidator; -use Phalcon\Validation\ValidatorInterface; -use Phalcon\Validation; +use OPNsense\Base\BaseValidator; -class CallbackValidator extends AbstractValidator implements ValidatorInterface +class CallbackValidator extends BaseValidator - public function validate(Validation $validator, $attribute): bool + public function validate($validator, $attribute): bool Todo: choose the "correct" Validation() based on phalcon version. * phalcon5: complete migration to compatibility layer. uses https://github.com/opnsense/core/commit/bc881b9c11500ee57a7448e94794c5e9827d7afe to remove the need for AbstractValidator and Validator(Interface). This commit changes the relevant includes and provides some changes to make the unit tests run correctly. * MVC - Phalcon 5 migration and options to lose dependency of phalcon validation classes. part duex Although our previous strategy should work according to how bind() and validation() are being implemented (https://github.com/phalcon/cphalcon/blob/4.2.x/phalcon/Validation.zep), in reality it seems they aren't the same. Our previous attempt failed some validations (such as booleans) for no valid reasons. Long term we should remove the phalcon dependency as these effects are highly unpredictable. phalcon5: update Validation class to now pick the right Phalcon Validation based on version * MVC - Phalcon 5 migration and options to lose dependency of phalcon validation classes. Minor regression in previous commit, performValidation()'s return type didn't match. Ideally we would rather switch to plain array's, but since performValidation() is used in multiple areas (including plugins) we better opt for compatiblity now. ref https://github.com/opnsense/core/pull/5711 * phalcon5: switch back to using count() on Messages object, adjust unit tests as needed See https://github.com/opnsense/core/commit/6814f32755f239a362a6153abdf287bac8f9cc33 as to why this is the case. * phalcon5: remove PhalconGenerator and references, use checked-in files instead * Update Makefile Co-authored-by: Franco Fichtner Co-authored-by: Ad Schellevis Co-authored-by: Franco Fichtner --- Makefile | 3 +- src/opnsense/mvc/app/config/config.php | 7 +++- src/opnsense/mvc/app/config/loader.php | 4 +-- src/opnsense/mvc/app/config/services.php | 2 +- src/opnsense/mvc/app/config/services_api.php | 3 +- .../Base/ApiMutableModelControllerBase.php | 14 ++++---- .../OPNsense/Base/ControllerRoot.php | 2 +- .../OPNsense/Core/Api/FirmwareController.php | 16 ++++----- .../OPNsense/Cron/Api/SettingsController.php | 6 ++-- .../Diagnostics/Api/FirewallController.php | 2 +- .../Diagnostics/Api/LogController.php | 2 +- .../Diagnostics/Api/NetflowController.php | 2 +- .../OPNsense/Firewall/Api/AliasController.php | 8 ++--- .../Firewall/Api/CategoryController.php | 6 ++-- .../OPNsense/IDS/Api/ServiceController.php | 4 +-- .../OPNsense/IDS/Api/SettingsController.php | 34 +++++++++---------- .../OPNsense/Monit/Api/SettingsController.php | 22 ++++++------ .../OPNsense/Proxy/Api/SettingsController.php | 8 ++--- .../OPNsense/Proxy/Api/TemplateController.php | 2 +- .../OPNsense/Routes/Api/RoutesController.php | 8 ++--- .../Syslog/Api/SettingsController.php | 10 +++--- .../TrafficShaper/Api/SettingsController.php | 22 ++++++------ .../mvc/app/library/OPNsense/Core/Backend.php | 2 +- .../mvc/app/library/OPNsense/Core/Config.php | 4 +-- .../mvc/app/library/OPNsense/Core/Shell.php | 2 +- .../OPNsense/Phalcon/Autoload/Loader.php | 26 ++++++++++++++ .../OPNsense/Phalcon/Config/Config.php | 17 ++++++++++ .../app/library/OPNsense/Phalcon/Di/Di.php | 17 ++++++++++ .../Phalcon/Encryption/Security/Random.php | 17 ++++++++++ .../OPNsense/Phalcon/Filter/Filter.php | 17 ++++++++++ .../Phalcon/Filter/Validation/Exception.php | 17 ++++++++++ .../Filter/Validation/Validator/Email.php | 17 ++++++++++ .../Validation/Validator/ExclusionIn.php | 17 ++++++++++ .../Validation/Validator/InclusionIn.php | 17 ++++++++++ .../Validation/Validator/Numericality.php | 17 ++++++++++ .../Validation/Validator/PresenceOf.php | 17 ++++++++++ .../Filter/Validation/Validator/Regex.php | 17 ++++++++++ .../OPNsense/Phalcon/Logger/Logger.php | 17 ++++++++++ .../app/models/OPNsense/Base/BaseModel.php | 9 ++--- .../models/OPNsense/Base/BaseValidator.php | 12 ++++++- .../Base/Constraints/AllOrNoneConstraint.php | 4 +-- .../Base/Constraints/BaseConstraint.php | 9 +++-- .../Constraints/ComparedToFieldConstraint.php | 4 +-- .../Base/Constraints/DependConstraint.php | 4 +-- .../Base/Constraints/SetIfConstraint.php | 4 +-- .../Constraints/SingleSelectConstraint.php | 4 +-- .../Base/Constraints/UniqueConstraint.php | 4 +-- .../OPNsense/Base/FieldTypes/BaseField.php | 2 +- .../Base/FieldTypes/BaseListField.php | 2 +- .../OPNsense/Base/FieldTypes/BooleanField.php | 2 +- .../OPNsense/Base/FieldTypes/CSVListField.php | 2 +- .../OPNsense/Base/FieldTypes/CountryField.php | 2 +- .../OPNsense/Base/FieldTypes/EmailField.php | 2 +- .../Base/FieldTypes/ModelRelationField.php | 2 +- .../OPNsense/Base/FieldTypes/NumericField.php | 2 +- .../OPNsense/Base/FieldTypes/PortField.php | 2 +- .../OPNsense/Base/FieldTypes/TextField.php | 4 +-- .../Base/FieldTypes/UniqueIdField.php | 2 +- .../Base/FieldTypes/UpdateOnlyTextField.php | 4 +-- .../OPNsense/Base/FieldTypes/UrlField.php | 2 +- .../models/OPNsense/Base/Menu/MenuSystem.php | 2 +- .../app/models/OPNsense/Base/Validation.php | 12 ++++++- .../Base/Validators/CallbackValidator.php | 8 ++--- .../Base/Validators/CsvListValidator.php | 9 +++-- .../Base/Validators/HostValidator.php | 9 +++-- .../Base/Validators/IntegerValidator.php | 9 +++-- .../Base/Validators/MinMaxValidator.php | 9 +++-- .../Base/Validators/NetworkValidator.php | 9 +++-- .../Firewall/FieldTypes/AliasContentField.php | 4 +-- .../Firewall/FieldTypes/AliasNameField.php | 4 +-- src/opnsense/mvc/script/load_phalcon.php | 7 ++-- src/opnsense/mvc/tests/app/config/config.php | 5 ++- .../models/OPNsense/Base/BaseModelTest.php | 4 +-- .../ComparedToFieldConstraintTest.php | 12 +++---- .../Base/FieldTypes/AuthGroupFieldTest.php | 6 ++-- .../AuthenticationServerFieldTest.php | 6 ++-- .../Base/FieldTypes/Base64FieldTest.php | 2 +- .../Base/FieldTypes/BooleanFieldTest.php | 6 ++-- .../Base/FieldTypes/CertificateFieldTest.php | 6 ++-- .../Base/FieldTypes/CountryFieldTest.php | 6 ++-- .../FieldTypes/Field_Framework_TestCase.php | 8 ++--- .../Base/FieldTypes/IntegerFieldTest.php | 6 ++-- .../Base/FieldTypes/InterfaceFieldTest.php | 8 ++--- .../FieldTypes/ModelRelationFieldTest.php | 10 +++--- .../Base/FieldTypes/NetworkAliasFieldTest.php | 2 +- .../Base/FieldTypes/OptionFieldTest.php | 2 +- .../Base/FieldTypes/PortFieldTest.php | 2 +- .../Base/FieldTypes/ProtocolFieldTest.php | 2 +- .../Base/FieldTypes/VirtualIPFieldTest.php | 2 +- src/opnsense/mvc/tests/setup.php | 2 +- src/www/csrf.inc | 2 +- 91 files changed, 469 insertions(+), 221 deletions(-) create mode 100644 src/opnsense/mvc/app/library/OPNsense/Phalcon/Autoload/Loader.php create mode 100644 src/opnsense/mvc/app/library/OPNsense/Phalcon/Config/Config.php create mode 100644 src/opnsense/mvc/app/library/OPNsense/Phalcon/Di/Di.php create mode 100644 src/opnsense/mvc/app/library/OPNsense/Phalcon/Encryption/Security/Random.php create mode 100644 src/opnsense/mvc/app/library/OPNsense/Phalcon/Filter/Filter.php create mode 100644 src/opnsense/mvc/app/library/OPNsense/Phalcon/Filter/Validation/Exception.php create mode 100644 src/opnsense/mvc/app/library/OPNsense/Phalcon/Filter/Validation/Validator/Email.php create mode 100644 src/opnsense/mvc/app/library/OPNsense/Phalcon/Filter/Validation/Validator/ExclusionIn.php create mode 100644 src/opnsense/mvc/app/library/OPNsense/Phalcon/Filter/Validation/Validator/InclusionIn.php create mode 100644 src/opnsense/mvc/app/library/OPNsense/Phalcon/Filter/Validation/Validator/Numericality.php create mode 100644 src/opnsense/mvc/app/library/OPNsense/Phalcon/Filter/Validation/Validator/PresenceOf.php create mode 100644 src/opnsense/mvc/app/library/OPNsense/Phalcon/Filter/Validation/Validator/Regex.php create mode 100644 src/opnsense/mvc/app/library/OPNsense/Phalcon/Logger/Logger.php diff --git a/Makefile b/Makefile index 0f4a91d82..5ffe05af3 100644 --- a/Makefile +++ b/Makefile @@ -130,9 +130,8 @@ CORE_DEPENDS_amd64?= beep \ suricata-devel # transition helpers for PHP 8/Phalcon 5 migration -CORE_DEPENDS_PHP74= php74-json php74-openssl php74-phalcon${CORE_PHALCON} +CORE_DEPENDS_PHP74= php74-json php74-openssl php74-phalcon CORE_DEPENDS_PHP80= php80-phalcon -CORE_PHALCON?= 4 CORE_DEPENDS?= ca_root_nss \ choparp \ diff --git a/src/opnsense/mvc/app/config/config.php b/src/opnsense/mvc/app/config/config.php index 3893138b3..ca525ae2b 100644 --- a/src/opnsense/mvc/app/config/config.php +++ b/src/opnsense/mvc/app/config/config.php @@ -1,6 +1,10 @@ array( 'controllersDir' => __DIR__ . '/../../app/controllers/', 'modelsDir' => __DIR__ . '/../../app/models/', @@ -17,3 +21,4 @@ return new \Phalcon\Config(array( 'simulate_mode' => false ) )); + diff --git a/src/opnsense/mvc/app/config/loader.php b/src/opnsense/mvc/app/config/loader.php index 27eb63330..4edf6ed71 100644 --- a/src/opnsense/mvc/app/config/loader.php +++ b/src/opnsense/mvc/app/config/loader.php @@ -1,11 +1,11 @@ registerDirs( +$loader->setDirectories( array( $config->application->controllersDir, $config->application->modelsDir, diff --git a/src/opnsense/mvc/app/config/services.php b/src/opnsense/mvc/app/config/services.php index 0ffc72345..ac0b27e90 100644 --- a/src/opnsense/mvc/app/config/services.php +++ b/src/opnsense/mvc/app/config/services.php @@ -1,6 +1,6 @@ sessionClose(); // long running action, close session - $filter = new \Phalcon\Filter([ + $filter = new \OPNsense\Phalcon\Filter\Filter([ 'version' => function ($value) { return preg_replace('/[^0-9a-zA-Z\.]/', '', $value); } @@ -383,7 +383,7 @@ class FirmwareController extends ApiControllerBase if ($this->request->isPost()) { // sanitize package name - $filter = new \Phalcon\Filter([ + $filter = new \OPNsense\Phalcon\Filter\Filter([ 'scrub' => function ($value) { return preg_replace('/[^0-9a-zA-Z._-]/', '', $value); } @@ -554,7 +554,7 @@ class FirmwareController extends ApiControllerBase if ($this->request->isPost()) { $response['status'] = 'ok'; // sanitize package name - $filter = new \Phalcon\Filter([ + $filter = new \OPNsense\Phalcon\Filter\Filter([ 'pkgname' => function ($value) { return preg_replace('/[^0-9a-zA-Z._-]/', '', $value); } @@ -624,7 +624,7 @@ class FirmwareController extends ApiControllerBase if ($this->request->isPost()) { $response['status'] = 'ok'; // sanitize package name - $filter = new \Phalcon\Filter([ + $filter = new \OPNsense\Phalcon\Filter\Filter([ 'pkgname' => function ($value) { return preg_replace('/[^0-9a-zA-Z._-]/', '', $value); } @@ -654,7 +654,7 @@ class FirmwareController extends ApiControllerBase if ($this->request->isPost()) { $response['status'] = 'ok'; // sanitize package name - $filter = new \Phalcon\Filter([ + $filter = new \OPNsense\Phalcon\Filter\Filter([ 'pkgname' => function ($value) { return preg_replace('/[^0-9a-zA-Z._-]/', '', $value); } @@ -682,7 +682,7 @@ class FirmwareController extends ApiControllerBase $response = array(); if ($this->request->isPost()) { - $filter = new \Phalcon\Filter([ + $filter = new \OPNsense\Phalcon\Filter\Filter([ 'pkgname' => function ($value) { return preg_replace('/[^0-9a-zA-Z._-]/', '', $value); } @@ -715,7 +715,7 @@ class FirmwareController extends ApiControllerBase $response = array(); if ($this->request->isPost()) { - $filter = new \Phalcon\Filter([ + $filter = new \OPNsense\Phalcon\Filter\Filter([ 'pkgname' => function ($value) { return preg_replace('/[^0-9a-zA-Z._-]/', '', $value); } @@ -786,7 +786,7 @@ class FirmwareController extends ApiControllerBase if ($this->request->isPost()) { // sanitize package name - $filter = new \Phalcon\Filter([ + $filter = new \OPNsense\Phalcon\Filter\Filter([ 'scrub' => function ($value) { return preg_replace('/[^0-9a-zA-Z._-]/', '', $value); } diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Cron/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/Cron/Api/SettingsController.php index 1d94338f7..f4b1d3103 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Cron/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Cron/Api/SettingsController.php @@ -103,7 +103,7 @@ class SettingsController extends ApiMutableModelControllerBase * add new job and set with attributes from post * @return array save result + validation output * @throws \OPNsense\Base\ModelException when not bound to model - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException */ public function addJobAction() @@ -116,7 +116,7 @@ class SettingsController extends ApiMutableModelControllerBase * delete job by uuid ( only if origin is cron) * @param string $uuid item unique id * @return array status - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model * @throws \OPNsense\Base\ModelException when not bound to model */ @@ -136,7 +136,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $uuid item unique id * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array status - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function toggleJobAction($uuid, $enabled = null) diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/FirewallController.php b/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/FirewallController.php index a165bcdc4..8d84a44de 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/FirewallController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/FirewallController.php @@ -28,7 +28,7 @@ namespace OPNsense\Diagnostics\Api; -use Phalcon\Filter; +use OPNsense\Phalcon\Filter\Filter; use OPNsense\Base\ApiControllerBase; use OPNsense\Core\Backend; use OPNsense\Core\Config; diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/LogController.php b/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/LogController.php index d6dd70e82..178a6eb70 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/LogController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/LogController.php @@ -30,7 +30,7 @@ namespace OPNsense\Diagnostics\Api; use OPNsense\Base\ApiControllerBase; use OPNsense\Core\Backend; -use Phalcon\Filter; +use OPNsense\Phalcon\Filter\Filter; /** * @inherit diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/NetflowController.php b/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/NetflowController.php index 56206a7f3..3553b9b05 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/NetflowController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/NetflowController.php @@ -74,7 +74,7 @@ class NetflowController extends ApiControllerBase /** * update netflow configuration fields * @return array - * @throws \Phalcon\Validation\Exception + * @throws \Phalcon\Filter\Validation\Exception */ public function setconfigAction() { diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php b/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php index 639c6f3c0..561707ff3 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php @@ -69,7 +69,7 @@ class AliasController extends ApiMutableModelControllerBase * Update alias with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function setItemAction($uuid) @@ -90,7 +90,7 @@ class AliasController extends ApiMutableModelControllerBase * Add new alias and set with attributes from post * @return array save result + validation output * @throws \OPNsense\Base\ModelException when not bound to model - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function addItemAction() @@ -141,7 +141,7 @@ class AliasController extends ApiMutableModelControllerBase * Delete alias by uuid, save contents to tmp for removal on apply * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model * @throws \OPNsense\Base\UserException when unable to delete */ @@ -168,7 +168,7 @@ class AliasController extends ApiMutableModelControllerBase * @param string $uuid id to toggled * @param string|null $enabled set enabled by default * @return array status - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function toggleItemAction($uuid, $enabled = null) diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/CategoryController.php b/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/CategoryController.php index d20d4e63e..7c7c8f035 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/CategoryController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/CategoryController.php @@ -69,7 +69,7 @@ class CategoryController extends ApiMutableModelControllerBase * Update category with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function setItemAction($uuid) @@ -90,7 +90,7 @@ class CategoryController extends ApiMutableModelControllerBase * Add new category and set with attributes from post * @return array save result + validation output * @throws \OPNsense\Base\ModelException when not bound to model - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function addItemAction() @@ -113,7 +113,7 @@ class CategoryController extends ApiMutableModelControllerBase * Delete alias by uuid, save contents to tmp for removal on apply * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model * @throws \OPNsense\Base\UserException when unable to delete */ diff --git a/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/ServiceController.php b/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/ServiceController.php index 083f215c5..b723ac2bb 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/ServiceController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/ServiceController.php @@ -33,7 +33,7 @@ use OPNsense\Core\Backend; use OPNsense\Core\Config; use OPNsense\Cron\Cron; use OPNsense\IDS\IDS; -use Phalcon\Filter; +use OPNsense\Phalcon\Filter\Filter; use Phalcon\Filter\FilterFactory; /** @@ -52,7 +52,7 @@ class ServiceController extends ApiMutableServiceControllerBase * @return array result status * @throws \Exception when configd action fails * @throws \OPNsense\Base\ModelException when unable to construct model - * @throws \Phalcon\Validation\Exception when one or more model validations fail + * @throws \Phalcon\Filter\Validation\Exception when one or more model validations fail */ public function reconfigureAction() { diff --git a/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php index bd444862b..68f06a9d8 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php @@ -298,7 +298,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update ruleset properties * @return array result status * @throws \Exception when config action fails - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function setRulesetpropertiesAction() @@ -387,7 +387,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $filename rule filename (key) * @return array result status * @throws \Exception when configd action fails - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function setRulesetAction($filename) @@ -424,7 +424,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array status 0/1 or error * @throws \Exception - * @throws \Phalcon\Validation\Exception + * @throws \Phalcon\Filter\Validation\Exception */ public function toggleRulesetAction($filenames, $enabled = null) { @@ -467,7 +467,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param string|int $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array empty * @throws \Exception when configd action fails - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function toggleRuleAction($sids, $enabled = null) @@ -522,7 +522,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $sid item unique id * @return array result status * @throws \Exception when configd action fails - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function setRuleAction($sid) @@ -563,7 +563,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update user defined rules * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function setUserRuleAction($uuid) @@ -574,7 +574,7 @@ class SettingsController extends ApiMutableModelControllerBase /** * Add new user defined rule * @return array save result + validation output - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function addUserRuleAction() @@ -597,7 +597,7 @@ class SettingsController extends ApiMutableModelControllerBase * Delete user rule item * @param string $uuid user rule internal id * @return array save status - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function delUserRuleAction($uuid) @@ -610,7 +610,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $uuid user defined rule internal id * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array save result - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function toggleUserRuleAction($uuid, $enabled = null) @@ -632,7 +632,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update policy * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function setPolicyAction($uuid) @@ -643,7 +643,7 @@ class SettingsController extends ApiMutableModelControllerBase /** * Add new policy * @return array save result + validation output - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function addPolicyAction() @@ -666,7 +666,7 @@ class SettingsController extends ApiMutableModelControllerBase * Delete policy item * @param string $uuid user rule internal id * @return array save status - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function delPolicyAction($uuid) @@ -679,7 +679,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $uuid user defined rule internal id * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array save result - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function togglePolicyAction($uuid, $enabled = null) @@ -701,7 +701,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update policy rule adjustment * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function setPolicyRuleAction($uuid) @@ -712,7 +712,7 @@ class SettingsController extends ApiMutableModelControllerBase /** * Add new policy rule adjustment * @return array save result + validation output - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function addPolicyRuleAction() @@ -735,7 +735,7 @@ class SettingsController extends ApiMutableModelControllerBase * Delete policy rule adjustment item * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function delPolicyRuleAction($uuid) @@ -748,7 +748,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $uuid user internal id * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array save result - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function togglePolicyRuleAction($uuid, $enabled = null) diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Monit/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/Monit/Api/SettingsController.php index 935f61e21..6bfca3b66 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Monit/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Monit/Api/SettingsController.php @@ -69,7 +69,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update alert with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function setAlertAction($uuid) @@ -80,7 +80,7 @@ class SettingsController extends ApiMutableModelControllerBase /** * Add alert with given properties * @return array save result + validation output - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function addAlertAction() @@ -92,7 +92,7 @@ class SettingsController extends ApiMutableModelControllerBase * Delete alert by uuid * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function delAlertAction($uuid) @@ -119,7 +119,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $uuid alert internal id * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array save result - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function toggleAlertAction($uuid, $enabled = null) @@ -142,7 +142,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update service with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function setServiceAction($uuid) @@ -153,7 +153,7 @@ class SettingsController extends ApiMutableModelControllerBase /** * Add service with given properties * @return array save result + validation output - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function addServiceAction() @@ -165,7 +165,7 @@ class SettingsController extends ApiMutableModelControllerBase * Delete service by uuid * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function delServiceAction($uuid) @@ -188,7 +188,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $uuid service internal id * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array save result - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function toggleServiceAction($uuid, $enabled = null) @@ -211,7 +211,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update test with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function setTestAction($uuid) @@ -222,7 +222,7 @@ class SettingsController extends ApiMutableModelControllerBase /** * Add test with given properties * @return array save result + validation output - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function addTestAction() @@ -234,7 +234,7 @@ class SettingsController extends ApiMutableModelControllerBase * Delete test by uuid * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function delTestAction($uuid) diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/SettingsController.php index 4fdeb1623..386c117f4 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/SettingsController.php @@ -74,7 +74,7 @@ class SettingsController extends ApiMutableModelControllerBase * update remote blacklist item * @param string $uuid * @return array result status - * @throws \Phalcon\Validation\Exception + * @throws \Phalcon\Filter\Validation\Exception */ public function setRemoteBlacklistAction($uuid) { @@ -182,7 +182,7 @@ class SettingsController extends ApiMutableModelControllerBase * update PAC Rule * @param string $uuid * @return array result status - * @throws \Phalcon\Validation\Exception + * @throws \Phalcon\Filter\Validation\Exception */ public function setPACRuleAction($uuid) { @@ -246,7 +246,7 @@ class SettingsController extends ApiMutableModelControllerBase * update PAC Proxy * @param string $uuid * @return array result status - * @throws \Phalcon\Validation\Exception + * @throws \Phalcon\Filter\Validation\Exception */ public function setPACProxyAction($uuid) { @@ -299,7 +299,7 @@ class SettingsController extends ApiMutableModelControllerBase * update PAC Rule * @param string $uuid * @return array result status - * @throws \Phalcon\Validation\Exception + * @throws \Phalcon\Filter\Validation\Exception */ public function setPACMatchAction($uuid) { diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/TemplateController.php b/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/TemplateController.php index f1d67e240..d6f5c04d3 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/TemplateController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/TemplateController.php @@ -43,7 +43,7 @@ class TemplateController extends ApiMutableModelControllerBase /** * save template * @return array status - * @throws \Phalcon\Validation\Exception on validation issues + * @throws \Phalcon\Filter\Validation\Exception on validation issues * @throws \ReflectionException when binding to the model class fails * @throws UserException when denied write access */ diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Routes/Api/RoutesController.php b/src/opnsense/mvc/app/controllers/OPNsense/Routes/Api/RoutesController.php index e9853d0c3..86ec39e67 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Routes/Api/RoutesController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Routes/Api/RoutesController.php @@ -60,7 +60,7 @@ class RoutesController extends ApiMutableModelControllerBase * Update route with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function setrouteAction($uuid) @@ -80,7 +80,7 @@ class RoutesController extends ApiMutableModelControllerBase * Add new route and set with attributes from post * @return array save result + validation output * @throws \OPNsense\Base\ModelException when not bound to model - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException */ public function addrouteAction() @@ -103,7 +103,7 @@ class RoutesController extends ApiMutableModelControllerBase * Delete route by uuid, save contents to tmp for removal on apply * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model * @throws \OPNsense\Base\ModelException when not bound to model */ @@ -123,7 +123,7 @@ class RoutesController extends ApiMutableModelControllerBase * @param string $uuid id to toggled * @param string|null $disabled set disabled by default * @return array status - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model * @throws \OPNsense\Base\ModelException when not bound to model */ diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Syslog/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/Syslog/Api/SettingsController.php index 62c2c716f..4f0dea501 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Syslog/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Syslog/Api/SettingsController.php @@ -28,7 +28,7 @@ namespace OPNsense\Syslog\Api; -use Phalcon\Filter; +use OPNsense\Phalcon\Filter\Filter; use OPNsense\Base\ApiMutableModelControllerBase; use OPNsense\Core\Backend; use OPNsense\Core\Config; @@ -72,7 +72,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update destination with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function setDestinationAction($uuid) @@ -84,7 +84,7 @@ class SettingsController extends ApiMutableModelControllerBase * Add new destination and set with attributes from post * @return array save result + validation output * @throws \OPNsense\Base\ModelException when not bound to model - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail */ public function addDestinationAction() { @@ -94,7 +94,7 @@ class SettingsController extends ApiMutableModelControllerBase * Delete destination by uuid * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function delDestinationAction($uuid) @@ -107,7 +107,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $uuid user defined rule internal id * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array save result - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function toggleDestinationAction($uuid, $enabled = null) diff --git a/src/opnsense/mvc/app/controllers/OPNsense/TrafficShaper/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/TrafficShaper/Api/SettingsController.php index 1f0000ad8..2054cf361 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/TrafficShaper/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/TrafficShaper/Api/SettingsController.php @@ -59,7 +59,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update pipe with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function setPipeAction($uuid) @@ -71,7 +71,7 @@ class SettingsController extends ApiMutableModelControllerBase * Add new pipe and set with attributes from post * @return array save result + validation output * @throws \OPNsense\Base\ModelException when not bound to model - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail */ public function addPipeAction() { @@ -85,7 +85,7 @@ class SettingsController extends ApiMutableModelControllerBase * Delete pipe by uuid * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function delPipeAction($uuid) @@ -99,7 +99,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $uuid user defined rule internal id * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array save result - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function togglePipeAction($uuid, $enabled = null) @@ -151,7 +151,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update queue with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function setQueueAction($uuid) @@ -175,7 +175,7 @@ class SettingsController extends ApiMutableModelControllerBase * Delete queue by uuid * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function delQueueAction($uuid) @@ -188,7 +188,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $uuid user defined rule internal id * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array save result - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function toggleQueueAction($uuid, $enabled = null) @@ -232,7 +232,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update rule with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function setRuleAction($uuid) @@ -244,7 +244,7 @@ class SettingsController extends ApiMutableModelControllerBase * Add new rule and set with attributes from post * @return array save result + validation output * @throws \OPNsense\Base\ModelException when not bound to model - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail */ public function addRuleAction() { @@ -254,7 +254,7 @@ class SettingsController extends ApiMutableModelControllerBase * Delete rule by uuid * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function delRuleAction($uuid) @@ -267,7 +267,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $uuid user defined rule internal id * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array save result - * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \Phalcon\Filter\Validation\Exception when field validations fail * @throws \ReflectionException when not bound to model */ public function toggleRuleAction($uuid, $enabled = null) diff --git a/src/opnsense/mvc/app/library/OPNsense/Core/Backend.php b/src/opnsense/mvc/app/library/OPNsense/Core/Backend.php index 45dda663a..850e15ef9 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Core/Backend.php +++ b/src/opnsense/mvc/app/library/OPNsense/Core/Backend.php @@ -28,7 +28,7 @@ namespace OPNsense\Core; -use Phalcon\Logger; +use OPNsense\Phalcon\Logger\Logger; use Phalcon\Logger\Adapter\Syslog; use Phalcon\Logger\Formatter\Line; diff --git a/src/opnsense/mvc/app/library/OPNsense/Core/Config.php b/src/opnsense/mvc/app/library/OPNsense/Core/Config.php index d2e072c4e..68426b437 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Core/Config.php +++ b/src/opnsense/mvc/app/library/OPNsense/Core/Config.php @@ -28,8 +28,8 @@ namespace OPNsense\Core; -use Phalcon\DI\FactoryDefault; -use Phalcon\Logger; +use Phalcon\Di\FactoryDefault; +use OPNsense\Phalcon\Logger\Logger; use Phalcon\Logger\Adapter\Syslog; /** diff --git a/src/opnsense/mvc/app/library/OPNsense/Core/Shell.php b/src/opnsense/mvc/app/library/OPNsense/Core/Shell.php index c067ff8d1..a9b9ee547 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Core/Shell.php +++ b/src/opnsense/mvc/app/library/OPNsense/Core/Shell.php @@ -28,7 +28,7 @@ namespace OPNsense\Core; -use Phalcon\DI\FactoryDefault; +use Phalcon\Di\FactoryDefault; /** * Class Shell shell/command handling routines diff --git a/src/opnsense/mvc/app/library/OPNsense/Phalcon/Autoload/Loader.php b/src/opnsense/mvc/app/library/OPNsense/Phalcon/Autoload/Loader.php new file mode 100644 index 000000000..e9d5647c5 --- /dev/null +++ b/src/opnsense/mvc/app/library/OPNsense/Phalcon/Autoload/Loader.php @@ -0,0 +1,26 @@ +fName(...$args); + } elseif ($fName == 'setDirectories') { + /* Phalcon5 renamed registerDirs to setDirectories */ + return $this->registerDirs(...$args); + } + } + +} \ No newline at end of file diff --git a/src/opnsense/mvc/app/library/OPNsense/Phalcon/Config/Config.php b/src/opnsense/mvc/app/library/OPNsense/Phalcon/Config/Config.php new file mode 100644 index 000000000..a7fdbef82 --- /dev/null +++ b/src/opnsense/mvc/app/library/OPNsense/Phalcon/Config/Config.php @@ -0,0 +1,17 @@ +internalData->getFlatNodes(); @@ -570,7 +571,7 @@ abstract class BaseModel $logger->error($exception_msg_part); } if (!$disable_validation) { - throw new Phalcon\Validation\Exception($exception_msg); + throw new \OPNsense\Phalcon\Filter\Validation\Exception($exception_msg); } } $this->internalSerializeToConfig(); diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/BaseValidator.php b/src/opnsense/mvc/app/models/OPNsense/Base/BaseValidator.php index 52940111c..797cdfa63 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/BaseValidator.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/BaseValidator.php @@ -31,15 +31,25 @@ namespace OPNsense\Base; abstract class BaseValidator { private $options = []; - public function __construct($options) + + public function __construct($options = []) { $this->options = $options; } + public function getOption($option, $default = null) { return isset($this->options[$option]) ? $this->options[$option] : $default; } + /** + * Only used by tests + */ + public function setOption($key, $value) + { + $this->options[$key] = $value; + } + abstract public function validate($validator, $attribute): bool; } diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/AllOrNoneConstraint.php b/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/AllOrNoneConstraint.php index 694e36655..ea1d6ae2d 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/AllOrNoneConstraint.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/AllOrNoneConstraint.php @@ -39,11 +39,11 @@ class AllOrNoneConstraint extends BaseConstraint /** * Executes validation * - * @param \Phalcon\Validation $validator + * @param $validator * @param string $attribute * @return boolean */ - public function validate(\Phalcon\Validation $validator, $attribute): bool + public function validate($validator, $attribute): bool { $node = $this->getOption('node'); if ($node) { diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/BaseConstraint.php b/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/BaseConstraint.php index 81cacec47..c704f858b 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/BaseConstraint.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/BaseConstraint.php @@ -28,11 +28,10 @@ namespace OPNsense\Base\Constraints; -use Phalcon\Validation\AbstractValidator; -use Phalcon\Validation\ValidatorInterface; +use OPNsense\Base\BaseValidator; use Phalcon\Messages\Message; -abstract class BaseConstraint extends AbstractValidator implements ValidatorInterface +abstract class BaseConstraint extends BaseValidator { /** * check if field is empty (either boolean field as false or an empty field) @@ -51,10 +50,10 @@ abstract class BaseConstraint extends AbstractValidator implements ValidatorInte } /** - * @param \Phalcon\Validation $validator + * @param $validator * @param $attribute */ - protected function appendMessage(\Phalcon\Validation $validator, $attribute) + protected function appendMessage($validator, $attribute) { $message = $this->getOption('ValidationMessage'); $name = $this->getOption('name'); diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraint.php b/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraint.php index 8d82b423d..c8d91d555 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraint.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraint.php @@ -45,11 +45,11 @@ class ComparedToFieldConstraint extends BaseConstraint * <field>name of another field which has the same parent node</field> * <operator>operator to check; one of gt|gte|lt|lte|eq|neq</operator> * - * @param \Phalcon\Validation $validator + * @param $validator * @param string $attribute * @return boolean */ - public function validate(\Phalcon\Validation $validator, $attribute): bool + public function validate($validator, $attribute): bool { $node = $this->getOption('node'); $field_name = $this->getOption('field'); diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/DependConstraint.php b/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/DependConstraint.php index b35d33247..0388daa84 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/DependConstraint.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/DependConstraint.php @@ -41,11 +41,11 @@ class DependConstraint extends BaseConstraint * Executes validation, expects a list of fields in "addFields" which to check for content. * Fields are concerned empty if boolean false or containing an empty string * - * @param \Phalcon\Validation $validator + * @param $validator * @param string $attribute * @return boolean */ - public function validate(\Phalcon\Validation $validator, $attribute): bool + public function validate($validator, $attribute): bool { $node = $this->getOption('node'); if ($node) { diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/SetIfConstraint.php b/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/SetIfConstraint.php index d02479cec..0d63cded9 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/SetIfConstraint.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/SetIfConstraint.php @@ -45,11 +45,11 @@ class SetIfConstraint extends BaseConstraint * <field>name of another field which has the same parent node</field> * <check>the value to check for as a string (for example the value of a OptionField)</check> * - * @param \Phalcon\Validation $validator + * @param $validator * @param string $attribute * @return boolean */ - public function validate(\Phalcon\Validation $validator, $attribute): bool + public function validate($validator, $attribute): bool { $node = $this->getOption('node'); $field_name = $this->getOption('field'); diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/SingleSelectConstraint.php b/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/SingleSelectConstraint.php index d9789e1bb..80f5192fe 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/SingleSelectConstraint.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/SingleSelectConstraint.php @@ -40,11 +40,11 @@ class SingleSelectConstraint extends BaseConstraint /** * Executes validation * - * @param \Phalcon\Validation $validator + * @param $validator * @param string $attribute * @return boolean */ - public function validate(\Phalcon\Validation $validator, $attribute): bool + public function validate($validator, $attribute): bool { $node = $this->getOption('node'); if ($node) { diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/UniqueConstraint.php b/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/UniqueConstraint.php index e1d0bf041..2c194d6e1 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/UniqueConstraint.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/UniqueConstraint.php @@ -39,11 +39,11 @@ class UniqueConstraint extends BaseConstraint /** * Executes validation * - * @param \Phalcon\Validation $validator + * @param $validator * @param string $attribute * @return boolean */ - public function validate(\Phalcon\Validation $validator, $attribute): bool + public function validate($validator, $attribute): bool { $node = $this->getOption('node'); $fieldSeparator = chr(10) . chr(0); diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php index b98c88cdb..b95318867 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php @@ -31,7 +31,7 @@ namespace OPNsense\Base\FieldTypes; use Exception; use Generator; use InvalidArgumentException; -use Phalcon\Validation\Validator\PresenceOf; +use OPNsense\Phalcon\Filter\Validation\Validator\PresenceOf; use ReflectionClass; use ReflectionException; use SimpleXMLElement; diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseListField.php b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseListField.php index f211e9562..b4a0dbfdf 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseListField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseListField.php @@ -28,7 +28,7 @@ namespace OPNsense\Base\FieldTypes; -use Phalcon\Validation\Validator\InclusionIn; +use OPNsense\Phalcon\Filter\Validation\Validator\InclusionIn; use OPNsense\Base\Validators\CsvListValidator; /** diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BooleanField.php b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BooleanField.php index ec503dd89..e92bc285c 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BooleanField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BooleanField.php @@ -28,7 +28,7 @@ namespace OPNsense\Base\FieldTypes; -use Phalcon\Validation\Validator\Regex; +use OPNsense\Phalcon\Filter\Validation\Validator\Regex; /** * Class TextField diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/CSVListField.php b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/CSVListField.php index 47855951e..edecea260 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/CSVListField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/CSVListField.php @@ -28,7 +28,7 @@ namespace OPNsense\Base\FieldTypes; -use Phalcon\Validation\Validator\Regex; +use OPNsense\Phalcon\Filter\Validation\Validator\Regex; /** * Class CSVListField diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/CountryField.php b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/CountryField.php index c5bd58ab7..cb28d70ae 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/CountryField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/CountryField.php @@ -28,7 +28,7 @@ namespace OPNsense\Base\FieldTypes; -use Phalcon\Validation\Validator\InclusionIn; +use OPNsense\Phalcon\Filter\Validation\Validator\InclusionIn; use OPNsense\Base\Validators\CsvListValidator; /** diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/EmailField.php b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/EmailField.php index 343593507..d23a157e1 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/EmailField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/EmailField.php @@ -28,7 +28,7 @@ namespace OPNsense\Base\FieldTypes; -use Phalcon\Validation\Validator\Email; +use OPNsense\Phalcon\Filter\Validation\Validator\Email; /** * Class EmailField diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/ModelRelationField.php b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/ModelRelationField.php index d75ff4722..2f923675f 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/ModelRelationField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/ModelRelationField.php @@ -28,7 +28,7 @@ namespace OPNsense\Base\FieldTypes; -use Phalcon\Validation\Validator\InclusionIn; +use OPNsense\Phalcon\Filter\Validation\Validator\InclusionIn; use OPNsense\Base\Validators\CsvListValidator; /** diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/NumericField.php b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/NumericField.php index 4c2b9a12e..133afaffe 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/NumericField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/NumericField.php @@ -29,7 +29,7 @@ namespace OPNsense\Base\FieldTypes; use OPNsense\Base\Validators\MinMaxValidator; -use Phalcon\Validation\Validator\Numericality; +use OPNsense\Phalcon\Filter\Validation\Validator\Numericality; /** * Class NumericField diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/PortField.php b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/PortField.php index 6b7d008c3..d74d2c87e 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/PortField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/PortField.php @@ -28,7 +28,7 @@ namespace OPNsense\Base\FieldTypes; -use Phalcon\Validation\Validator\InclusionIn; +use OPNsense\Phalcon\Filter\Validation\Validator\InclusionIn; /** * Class PortField field type for ports, includes validation for services in /etc/services or valid number ranges. diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/TextField.php b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/TextField.php index 25e058380..38406f8fe 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/TextField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/TextField.php @@ -28,8 +28,8 @@ namespace OPNsense\Base\FieldTypes; -use Phalcon\Validation\Validator\Regex; -use Phalcon\Validation\Validator\PresenceOf; +use OPNsense\Phalcon\Filter\Validation\Validator\Regex; +use OPNsense\Phalcon\Filter\Validation\Validator\PresenceOf; /** * Class TextField diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/UniqueIdField.php b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/UniqueIdField.php index b5b76f34f..f50ff1cc0 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/UniqueIdField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/UniqueIdField.php @@ -28,7 +28,7 @@ namespace OPNsense\Base\FieldTypes; -use Phalcon\Validation\Validator\InclusionIn; +use OPNsense\Phalcon\Filter\Validation\Validator\InclusionIn; /** * Class UniqueIdField diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/UpdateOnlyTextField.php b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/UpdateOnlyTextField.php index adef9f924..153bd4006 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/UpdateOnlyTextField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/UpdateOnlyTextField.php @@ -28,8 +28,8 @@ namespace OPNsense\Base\FieldTypes; -use Phalcon\Validation\Validator\Regex; -use Phalcon\Validation\Validator\PresenceOf; +use OPNsense\Phalcon\Filter\Validation\Validator\Regex; +use OPNsense\Phalcon\Filter\Validation\Validator\PresenceOf; /** * Class update only TextField (can be practical for password type fields) diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/UrlField.php b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/UrlField.php index ba3cdea98..1ba138ce9 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/UrlField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/UrlField.php @@ -28,7 +28,7 @@ namespace OPNsense\Base\FieldTypes; -use Phalcon\Validation\Validator\Url as UrlValidator; +use OPNsense\Phalcon\Filter\Validation\Validator\Url as UrlValidator; /** * Class EmailField diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/Menu/MenuSystem.php b/src/opnsense/mvc/app/models/OPNsense/Base/Menu/MenuSystem.php index 67275527c..2ce13a0c0 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/Menu/MenuSystem.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/Menu/MenuSystem.php @@ -30,7 +30,7 @@ namespace OPNsense\Base\Menu; use OPNsense\Core\Config; -use Phalcon\DI\FactoryDefault; +use Phalcon\Di\FactoryDefault; /** * Class MenuSystem diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/Validation.php b/src/opnsense/mvc/app/models/OPNsense/Base/Validation.php index 558eb7365..8403cddb8 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/Validation.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/Validation.php @@ -37,7 +37,9 @@ class Validation public function __construct($validators = []) { $this->validators = $validators; - $this->phalcon_validation = new \Phalcon\Validation(); + $this->phalcon_validation = explode('.', phpversion("phalcon"))[0] < 5 + ? new \Phalcon\Validation() + : new \Phalcon\Filter\Validation(); $this->messages = new Messages(); $this->data = []; } @@ -101,4 +103,12 @@ class Validation { return isset($this->data[$attribute]) ? $this->data[$attribute] : null; } + + /** + * Only used by tests + */ + public function getMessages() + { + return $this->messages; + } } diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/Validators/CallbackValidator.php b/src/opnsense/mvc/app/models/OPNsense/Base/Validators/CallbackValidator.php index dfcb2b2ab..9ccbb2c43 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/Validators/CallbackValidator.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/Validators/CallbackValidator.php @@ -30,16 +30,14 @@ namespace OPNsense\Base\Validators; -use Phalcon\Validation\AbstractValidator; -use Phalcon\Validation\ValidatorInterface; -use Phalcon\Validation; +use OPNsense\Base\BaseValidator; use Phalcon\Messages\Message; /** * Class CallbackValidator * @package OPNsense\Base\Validators */ -class CallbackValidator extends AbstractValidator implements ValidatorInterface +class CallbackValidator extends BaseValidator { /** * Executes callback validator, which should return validation messages on failure @@ -48,7 +46,7 @@ class CallbackValidator extends AbstractValidator implements ValidatorInterface * @param string $attribute * @return boolean */ - public function validate(Validation $validator, $attribute): bool + public function validate($validator, $attribute): bool { $callback = $this->getOption('callback'); if ($callback) { diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/Validators/CsvListValidator.php b/src/opnsense/mvc/app/models/OPNsense/Base/Validators/CsvListValidator.php index e60d96af8..d30485262 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/Validators/CsvListValidator.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/Validators/CsvListValidator.php @@ -30,24 +30,23 @@ namespace OPNsense\Base\Validators; -use Phalcon\Validation\AbstractValidator; -use Phalcon\Validation\ValidatorInterface; +use OPNsense\Base\BaseValidator; use Phalcon\Messages\Message; /** * Class CsvListValidator validate a string list against a list of options * @package OPNsense\Base\Validators */ -class CsvListValidator extends AbstractValidator implements ValidatorInterface +class CsvListValidator extends BaseValidator { /** * Executes validation * - * @param \Phalcon\Validation $validator + * @param $validator * @param string $attribute * @return boolean */ - public function validate(\Phalcon\Validation $validator, $attribute): bool + public function validate($validator, $attribute): bool { $value = $validator->getValue($attribute); $domain = $this->getOption('domain'); diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/Validators/HostValidator.php b/src/opnsense/mvc/app/models/OPNsense/Base/Validators/HostValidator.php index 97ccbb816..a2f360a46 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/Validators/HostValidator.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/Validators/HostValidator.php @@ -30,23 +30,22 @@ namespace OPNsense\Base\Validators; -use Phalcon\Validation\AbstractValidator; -use Phalcon\Validation\ValidatorInterface; +use OPNsense\Base\BaseValidator; use Phalcon\Messages\Message; /** * Class NetworkValidator validate domain and hostnames * @package OPNsense\Base\Validators */ -class HostValidator extends AbstractValidator implements ValidatorInterface +class HostValidator extends BaseValidator { /** * - * @param \Phalcon\Validation $validator + * @param $validator * @param string $attribute * @return boolean */ - public function validate(\Phalcon\Validation $validator, $attribute): bool + public function validate($validator, $attribute): bool { $result = true; $msg = $this->getOption('message'); diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/Validators/IntegerValidator.php b/src/opnsense/mvc/app/models/OPNsense/Base/Validators/IntegerValidator.php index c204c4d45..63cf8cf64 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/Validators/IntegerValidator.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/Validators/IntegerValidator.php @@ -30,24 +30,23 @@ namespace OPNsense\Base\Validators; -use Phalcon\Validation\AbstractValidator; -use Phalcon\Validation\ValidatorInterface; +use OPNsense\Base\BaseValidator; use Phalcon\Messages\Message; /** * Class IntegerValidator * @package OPNsense\Base\Validators */ -class IntegerValidator extends AbstractValidator implements ValidatorInterface +class IntegerValidator extends BaseValidator { /** * Executes Integer validation * - * @param \Phalcon\Validation $validator + * @param $validator * @param string $attribute * @return boolean */ - public function validate(\Phalcon\Validation $validator, $attribute): bool + public function validate($validator, $attribute): bool { $value = $validator->getValue($attribute); $msg = $this->getOption('message'); diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/Validators/MinMaxValidator.php b/src/opnsense/mvc/app/models/OPNsense/Base/Validators/MinMaxValidator.php index 5d8517aec..5bf90bdef 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/Validators/MinMaxValidator.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/Validators/MinMaxValidator.php @@ -30,24 +30,23 @@ namespace OPNsense\Base\Validators; -use Phalcon\Validation\AbstractValidator; -use Phalcon\Validation\ValidatorInterface; +use OPNsense\Base\BaseValidator; use Phalcon\Messages\Message; /** * Class MinMaxValidator * @package OPNsense\Base\Validators */ -class MinMaxValidator extends AbstractValidator implements ValidatorInterface +class MinMaxValidator extends BaseValidator { /** * Executes MinMax validation * - * @param \Phalcon\Validation $validator + * @param $validator * @param string $attribute * @return boolean */ - public function validate(\Phalcon\Validation $validator, $attribute): bool + public function validate($validator, $attribute): bool { $value = $validator->getValue($attribute); diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/Validators/NetworkValidator.php b/src/opnsense/mvc/app/models/OPNsense/Base/Validators/NetworkValidator.php index e2d5fe1b5..7127533a6 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/Validators/NetworkValidator.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/Validators/NetworkValidator.php @@ -30,15 +30,14 @@ namespace OPNsense\Base\Validators; -use Phalcon\Validation\AbstractValidator; -use Phalcon\Validation\ValidatorInterface; +use OPNsense\Base\BaseValidator; use Phalcon\Messages\Message; /** * Class NetworkValidator validate networks and ip addresses * @package OPNsense\Base\Validators */ -class NetworkValidator extends AbstractValidator implements ValidatorInterface +class NetworkValidator extends BaseValidator { /** * Executes network / ip validation, accepts the following parameters as attributes: @@ -49,11 +48,11 @@ class NetworkValidator extends AbstractValidator implements ValidatorInterface * netMaskRequired : true, false (default) * * - * @param \Phalcon\Validation $validator + * @param $validator * @param string $attribute * @return boolean */ - public function validate(\Phalcon\Validation $validator, $attribute): bool + public function validate($validator, $attribute): bool { $result = true; $msg = $this->getOption('message'); diff --git a/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/AliasContentField.php b/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/AliasContentField.php index 7c8f3f6b4..ac2e1b8af 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/AliasContentField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/AliasContentField.php @@ -32,8 +32,8 @@ namespace OPNsense\Firewall\FieldTypes; use OPNsense\Base\FieldTypes\BaseField; use OPNsense\Base\Validators\CallbackValidator; -use Phalcon\Validation\Validator\Regex; -use Phalcon\Validation\Validator\ExclusionIn; +use OPNsense\Phalcon\Filter\Validation\Validator\Regex; +use OPNsense\Phalcon\Filter\Validation\Validator\ExclusionIn; use Phalcon\Messages\Message; use OPNsense\Firewall\Util; diff --git a/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/AliasNameField.php b/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/AliasNameField.php index a055ea617..266ce07e3 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/AliasNameField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/AliasNameField.php @@ -32,8 +32,8 @@ namespace OPNsense\Firewall\FieldTypes; use OPNsense\Base\FieldTypes\BaseField; use OPNsense\Base\Validators\CallbackValidator; -use Phalcon\Validation\Validator\Regex; -use Phalcon\Validation\Validator\ExclusionIn; +use OPNsense\Phalcon\Filter\Validation\Validator\Regex; +use OPNsense\Phalcon\Filter\Validation\Validator\ExclusionIn; /** * Class AliasNameField diff --git a/src/opnsense/mvc/script/load_phalcon.php b/src/opnsense/mvc/script/load_phalcon.php index edaf54157..9cc381191 100644 --- a/src/opnsense/mvc/script/load_phalcon.php +++ b/src/opnsense/mvc/script/load_phalcon.php @@ -26,14 +26,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -use Phalcon\DI\FactoryDefault; -use Phalcon\Loader; +use Phalcon\Di\FactoryDefault; $di = new FactoryDefault(); $phalcon_config = include("/usr/local/opnsense/mvc/app/config/config.php"); -$loader = new Loader(); -$loader->registerDirs( +$loader = new OPNsense\Phalcon\Autoload\Loader(); +$loader->setDirectories( array( $phalcon_config->application->controllersDir, $phalcon_config->application->modelsDir, diff --git a/src/opnsense/mvc/tests/app/config/config.php b/src/opnsense/mvc/tests/app/config/config.php index a9444b5f2..281fb1cfd 100644 --- a/src/opnsense/mvc/tests/app/config/config.php +++ b/src/opnsense/mvc/tests/app/config/config.php @@ -1,6 +1,9 @@ array( 'controllersDir' => __DIR__ . '/../../../app/controllers/', 'modelsDir' => __DIR__ . '/../../../app/models/', diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/BaseModelTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/BaseModelTest.php index 034331198..aeb7e03cd 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/BaseModelTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/BaseModelTest.php @@ -170,7 +170,7 @@ class BaseModelTest extends \PHPUnit\Framework\TestCase */ public function testValidationNOK() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("not a valid number"); // replace all numbers foreach (BaseModelTest::$model->arraytypes->item->iterateItems() as $nodeid => $node) { @@ -244,7 +244,7 @@ class BaseModelTest extends \PHPUnit\Framework\TestCase */ public function testConstraintsNok() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("number should be unique"); $count = 2; foreach (BaseModelTest::$model->arraytypes->item->iterateItems() as $nodeid => $node) { diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraintTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraintTest.php index 655d3354b..7db2ed0bb 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraintTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraintTest.php @@ -40,17 +40,17 @@ class ComparedToFieldConstraintTest extends \PHPUnit\Framework\TestCase // lesser then public function test_if_it_validates_number_ranges_correctly_with_lt_and_no_error() { - $validator = new \Phalcon\Validation(); + $validator = new \OPNsense\Base\Validation(); $validate = $this->make_validator(2, 3, 'test', 'lt'); $ret = $validate->validate($validator, ''); $messages = $validator->getMessages(); - $this->assertEquals(null, $messages); + $this->assertEquals(0, $messages->count()); $this->assertEquals(true, $ret); } public function test_if_it_validates_number_ranges_correctly_with_lt_and_error() { - $validator = new \Phalcon\Validation(); + $validator = new \OPNsense\Base\Validation(); $validate = $this->make_validator(3, 3, 'test', 'lt'); $ret = $validate->validate($validator, ''); $messages = $validator->getMessages(); @@ -60,17 +60,17 @@ class ComparedToFieldConstraintTest extends \PHPUnit\Framework\TestCase // greater then public function test_if_it_validates_number_ranges_correctly_with_gt_and_no_error() { - $validator = new \Phalcon\Validation(); + $validator = new \OPNsense\Base\Validation(); $validate = $this->make_validator(5, 3, 'test', 'gt'); $ret = $validate->validate($validator, ''); $messages = $validator->getMessages(); - $this->assertEquals(null, $messages); + $this->assertEquals(0, $messages->count()); $this->assertEquals(true, $ret); } public function test_if_it_validates_number_ranges_correctly_with_gt_and_error() { - $validator = new \Phalcon\Validation(); + $validator = new \OPNsense\Base\Validation(); $validate = $this->make_validator(2, 3, 'test', 'gt'); $ret = $validate->validate($validator, ''); $messages = $validator->getMessages(); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/AuthGroupFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/AuthGroupFieldTest.php index e6956d674..b5fe65d70 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/AuthGroupFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/AuthGroupFieldTest.php @@ -35,7 +35,7 @@ require_once 'Field_Framework_TestCase.php'; // @CodingStandardsIgnoreEnd use OPNsense\Base\FieldTypes\AuthGroupField; -use Phalcon\DI\FactoryDefault; +use Phalcon\Di\FactoryDefault; use OPNsense\Core\Config; class AuthGroupFieldTest extends Field_Framework_TestCase @@ -70,7 +70,7 @@ class AuthGroupFieldTest extends Field_Framework_TestCase */ public function testSelectSetWithUnknownValue() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("CsvListValidator"); // init field $field = new AuthGroupField(); @@ -99,7 +99,7 @@ class AuthGroupFieldTest extends Field_Framework_TestCase */ public function testSelectSetOnSingleValue() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("InclusionIn"); // init field $field = new AuthGroupField(); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/AuthenticationServerFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/AuthenticationServerFieldTest.php index 26d80aeb1..9410cf373 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/AuthenticationServerFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/AuthenticationServerFieldTest.php @@ -35,7 +35,7 @@ require_once 'Field_Framework_TestCase.php'; // @CodingStandardsIgnoreEnd use OPNsense\Base\FieldTypes\AuthenticationServerField; -use Phalcon\DI\FactoryDefault; +use Phalcon\Di\FactoryDefault; use OPNsense\Core\Config; class AuthenticationServerFieldTest extends Field_Framework_TestCase @@ -83,7 +83,7 @@ class AuthenticationServerFieldTest extends Field_Framework_TestCase */ public function testSelectSetWithUnknownValue() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("CsvListValidator"); // init field $field = new AuthenticationServerField(); @@ -112,7 +112,7 @@ class AuthenticationServerFieldTest extends Field_Framework_TestCase */ public function testSelectSetOnSingleValue() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("InclusionIn"); // init field $field = new AuthenticationServerField(); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/Base64FieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/Base64FieldTest.php index dcf39925d..7b916ef33 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/Base64FieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/Base64FieldTest.php @@ -45,7 +45,7 @@ class Base64FieldTest extends Field_Framework_TestCase public function testRequiredEmpty() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("PresenceOf"); $field = new Base64Field(); $field->setRequired("Y"); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/BooleanFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/BooleanFieldTest.php index fb573496b..476913847 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/BooleanFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/BooleanFieldTest.php @@ -50,7 +50,7 @@ class BooleanFieldTest extends Field_Framework_TestCase */ public function testShouldNotBeANumber() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("Regex"); $field = new BooleanField(); $field->setValue("90"); @@ -61,7 +61,7 @@ class BooleanFieldTest extends Field_Framework_TestCase */ public function testShouldNotBeAString() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("Regex"); $field = new BooleanField(); $field->setValue("xx"); @@ -73,7 +73,7 @@ class BooleanFieldTest extends Field_Framework_TestCase */ public function testRequiredEmpty() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("PresenceOf"); $field = new BooleanField(); $field->setRequired("Y"); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/CertificateFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/CertificateFieldTest.php index 513211adc..191a5fc43 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/CertificateFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/CertificateFieldTest.php @@ -35,7 +35,7 @@ require_once 'Field_Framework_TestCase.php'; // @CodingStandardsIgnoreEnd use OPNsense\Base\FieldTypes\CertificateField; -use Phalcon\DI\FactoryDefault; +use Phalcon\Di\FactoryDefault; use OPNsense\Core\Config; class CertificateFieldTest extends Field_Framework_TestCase @@ -83,7 +83,7 @@ class CertificateFieldTest extends Field_Framework_TestCase */ public function testSelectSetWithUnknownValue() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("CsvListValidator"); // init field $field = new CertificateField(); @@ -112,7 +112,7 @@ class CertificateFieldTest extends Field_Framework_TestCase */ public function testSelectSetOnSingleValue() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("InclusionIn"); // init field $field = new CertificateField(); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/CountryFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/CountryFieldTest.php index ce9b76260..cc00afc82 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/CountryFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/CountryFieldTest.php @@ -50,7 +50,7 @@ class CountryFieldTest extends Field_Framework_TestCase */ public function testRequiredEmpty() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("PresenceOf"); $field = new CountryField(); $field->eventPostLoading(); @@ -101,7 +101,7 @@ class CountryFieldTest extends Field_Framework_TestCase */ public function testSelectSetWithUnknownValue() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("CsvListValidator"); // init field $field = new CountryField(); @@ -144,7 +144,7 @@ class CountryFieldTest extends Field_Framework_TestCase */ public function testSelectSetOnSingleValue() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("InclusionIn"); // init field $field = new CountryField(); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/Field_Framework_TestCase.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/Field_Framework_TestCase.php index 9d17ecf6d..e53809ff4 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/Field_Framework_TestCase.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/Field_Framework_TestCase.php @@ -37,11 +37,11 @@ class Field_Framework_TestCase extends \PHPUnit\Framework\TestCase /** * Validate and throw exception * @param string $field field type - * @throws \Phalcon\Validation\Exception + * @throws \Phalcon\Filter\Validation\Exception */ public function validateThrow($field) { - $validation = new \Phalcon\Validation(); + $validation = new \OPNsense\Base\Validation(); foreach ($field->getValidators() as $validator) { $validation->add("testfield", $validator); } @@ -49,7 +49,7 @@ class Field_Framework_TestCase extends \PHPUnit\Framework\TestCase $messages = $validation->validate(array("testfield" => (string)$field)); if (count($messages)) { foreach ($messages as $message) { - throw new \Phalcon\Validation\Exception($message->getType()); + throw new \OPNsense\Phalcon\Filter\Validation\Exception($message->getType()); } } return; @@ -63,7 +63,7 @@ class Field_Framework_TestCase extends \PHPUnit\Framework\TestCase public function validate($field) { $result = array(); - $validation = new \Phalcon\Validation(); + $validation = new \OPNsense\Base\Validation(); foreach ($field->getValidators() as $validator) { $validation->add("testfield", $validator); } diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/IntegerFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/IntegerFieldTest.php index d6349d148..8fefd2c8f 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/IntegerFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/IntegerFieldTest.php @@ -50,7 +50,7 @@ class IntegerFieldTest extends Field_Framework_TestCase */ public function testValueLargerThenMax() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("MinMaxValidator"); $field = new IntegerField(); $field->setMaximumValue(100); @@ -64,7 +64,7 @@ class IntegerFieldTest extends Field_Framework_TestCase */ public function testValueSmallerThenMin() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("MinMaxValidator"); $field = new IntegerField(); $field->setMaximumValue(100); @@ -104,7 +104,7 @@ class IntegerFieldTest extends Field_Framework_TestCase */ public function testRequiredEmpty() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("PresenceOf"); $field = new IntegerField(); $field->setRequired("Y"); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/InterfaceFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/InterfaceFieldTest.php index 03a9d8ac8..d65333c66 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/InterfaceFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/InterfaceFieldTest.php @@ -35,7 +35,7 @@ require_once 'Field_Framework_TestCase.php'; // @CodingStandardsIgnoreEnd use OPNsense\Base\FieldTypes\InterfaceField; -use Phalcon\DI\FactoryDefault; +use Phalcon\Di\FactoryDefault; use OPNsense\Core\Config; class InterfaceFieldTest extends Field_Framework_TestCase @@ -70,7 +70,7 @@ class InterfaceFieldTest extends Field_Framework_TestCase */ public function testSelectHasNoParents() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("InclusionIn"); // init field $field = new InterfaceField(); @@ -111,7 +111,7 @@ class InterfaceFieldTest extends Field_Framework_TestCase */ public function testSelectSetWithUnknownValue() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("CsvListValidator"); // init field $field = new InterfaceField(); @@ -140,7 +140,7 @@ class InterfaceFieldTest extends Field_Framework_TestCase */ public function testSelectSetOnSingleValue() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("InclusionIn"); // init field $field = new InterfaceField(); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/ModelRelationFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/ModelRelationFieldTest.php index 71500eb72..95db6da84 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/ModelRelationFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/ModelRelationFieldTest.php @@ -34,7 +34,7 @@ require_once __DIR__ . '/../BaseModel/TestModel.php'; // @CodingStandardsIgnoreEnd use OPNsense\Base\FieldTypes\ModelRelationField; -use Phalcon\DI\FactoryDefault; +use Phalcon\Di\FactoryDefault; use OPNsense\Core\Config; class ModelRelationFieldTest extends Field_Framework_TestCase @@ -86,7 +86,7 @@ class ModelRelationFieldTest extends Field_Framework_TestCase )); $field->eventPostLoading(); $field->setValue("5ea2a35c-b02b-485a-912b-d077e639bf9f,60e1bc02-6817-4940-bbd3-61d0cf439a8a"); - $this->assertEquals($this->validate($field), ['Phalcon\Validation\Validator\InclusionIn']); + $this->assertEquals($this->validate($field), ['OPNsense\Phalcon\Filter\Validation\Validator\InclusionIn']); } /** @@ -123,7 +123,7 @@ class ModelRelationFieldTest extends Field_Framework_TestCase )); $field->eventPostLoading(); $field->setValue(""); - $this->assertEquals($this->validate($field), ['Phalcon\Validation\Validator\PresenceOf']); + $this->assertEquals($this->validate($field), ['OPNsense\Phalcon\Filter\Validation\Validator\PresenceOf']); } /** @@ -267,7 +267,7 @@ class ModelRelationFieldTest extends Field_Framework_TestCase )); $field->eventPostLoading(); $field->setValue("XX5ea2a35c-b02b-485a-912b-d077e639bf9f"); - $this->assertEquals($this->validate($field), ['Phalcon\Validation\Validator\InclusionIn']); + $this->assertEquals($this->validate($field), ['OPNsense\Phalcon\Filter\Validation\Validator\InclusionIn']); } /** @@ -324,7 +324,7 @@ class ModelRelationFieldTest extends Field_Framework_TestCase )); $field->eventPostLoading(); $field->setValue("4d0e2835-7a19-4a19-8c23-e12383827594,5ea2a35c-b02b-485a-912b-d077e639bf9f"); - $this->assertEquals($this->validate($field), ['Phalcon\Validation\Validator\InclusionIn']); + $this->assertEquals($this->validate($field), ['OPNsense\Phalcon\Filter\Validation\Validator\InclusionIn']); } /** diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/NetworkAliasFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/NetworkAliasFieldTest.php index 79ec39c9b..bbdd449a2 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/NetworkAliasFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/NetworkAliasFieldTest.php @@ -35,7 +35,7 @@ require_once 'Field_Framework_TestCase.php'; // @CodingStandardsIgnoreEnd use OPNsense\Base\FieldTypes\NetworkAliasField; -use Phalcon\DI\FactoryDefault; +use Phalcon\Di\FactoryDefault; use OPNsense\Core\Config; class NetworkAliasFieldTest extends Field_Framework_TestCase diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/OptionFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/OptionFieldTest.php index 6b96c0af4..06fa07999 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/OptionFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/OptionFieldTest.php @@ -50,7 +50,7 @@ class OptionFieldTest extends Field_Framework_TestCase */ public function testRequiredEmpty() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("PresenceOf"); $field = new OptionField(); $field->setRequired("Y"); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/PortFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/PortFieldTest.php index 03d2be560..79e729b85 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/PortFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/PortFieldTest.php @@ -50,7 +50,7 @@ class PortFieldTest extends Field_Framework_TestCase */ public function testRequiredEmpty() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("PresenceOf"); $field = new PortField(); $field->setRequired("Y"); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/ProtocolFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/ProtocolFieldTest.php index dc4f12625..442d3bf7d 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/ProtocolFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/ProtocolFieldTest.php @@ -50,7 +50,7 @@ class ProtocolFieldTest extends Field_Framework_TestCase */ public function testRequiredEmpty() { - $this->expectException(\Phalcon\Validation\Exception::class); + $this->expectException(\OPNsense\Phalcon\Filter\Validation\Exception::class); $this->expectExceptionMessage("PresenceOf"); $field = new ProtocolField(); $field->eventPostLoading(); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/VirtualIPFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/VirtualIPFieldTest.php index 9077cb100..918c3bfe5 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/VirtualIPFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/VirtualIPFieldTest.php @@ -35,7 +35,7 @@ require_once 'Field_Framework_TestCase.php'; // @CodingStandardsIgnoreEnd use OPNsense\Base\FieldTypes\VirtualIPField; -use Phalcon\DI\FactoryDefault; +use Phalcon\Di\FactoryDefault; use OPNsense\Core\Config; class VirtualIPFieldTest extends Field_Framework_TestCase diff --git a/src/opnsense/mvc/tests/setup.php b/src/opnsense/mvc/tests/setup.php index cb3e8c8ff..0d786980a 100644 --- a/src/opnsense/mvc/tests/setup.php +++ b/src/opnsense/mvc/tests/setup.php @@ -26,7 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -use Phalcon\Di; +use OPNsense\Phalcon\Di\Di; use Phalcon\Di\FactoryDefault; ini_set('display_errors', 1); diff --git a/src/www/csrf.inc b/src/www/csrf.inc index 05e781e95..afc0e7da8 100644 --- a/src/www/csrf.inc +++ b/src/www/csrf.inc @@ -71,7 +71,7 @@ class LegacyCSRF private function newToken() { - $random = new \Phalcon\Security\Random(); + $random = new \OPNsense\Phalcon\Encryption\Security\Random(); // only request new token when session has none if (empty($_SESSION['$PHALCON/CSRF/KEY$']) || empty($_SESSION['$PHALCON/CSRF$'])) { $_SESSION['$PHALCON/CSRF$'] = $random->base64Safe(16);