From 7088c16a8b9be56b78b139e408e2e1b67278acdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Nowacki?= Date: Wed, 24 Oct 2018 17:10:47 +0200 Subject: [PATCH 1/4] Update Model.php Fixes #1326 - passing DBGroup do Validation. --- system/Model.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/Model.php b/system/Model.php index 5b413ad79ad7..429ac86b9463 100644 --- a/system/Model.php +++ b/system/Model.php @@ -1233,7 +1233,7 @@ public function validate($data): bool // or an array of rules. if (is_string($this->validationRules)) { - $valid = $this->validation->run($data, $this->validationRules); + $valid = $this->validation->run($data, $this->validationRules, $this->DBGroup); } else { @@ -1241,7 +1241,7 @@ public function validate($data): bool // the value found in $data, if exists. $rules = $this->fillPlaceholders($this->validationRules, $data); - $this->validation->setRules($rules, $this->validationMessages); + $this->validation->setRules($rules, $this->validationMessages, $this->DBGroup); $valid = $this->validation->run($data); } From 7a30a8f47d84fc8dcadf70316a822555f950babb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Nowacki?= Date: Wed, 24 Oct 2018 17:13:50 +0200 Subject: [PATCH 2/4] Update Validation.php Adding DBGroup to $data and passing it to processRules. #1326 --- system/Validation/Validation.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/system/Validation/Validation.php b/system/Validation/Validation.php index 25bf46818cc4..8ef3f9b299e6 100644 --- a/system/Validation/Validation.php +++ b/system/Validation/Validation.php @@ -123,10 +123,13 @@ public function __construct($config, RendererInterface $view) * * @return bool */ - public function run(array $data = null, string $group = null): bool + public function run(array $data = null, string $group = null, ?string $db_group = null): bool { $data = $data ?? $this->data; + // i.e. is_unique + $data['DBGroup'] = $db_group; + $this->loadRuleSets(); $this->loadRuleGroup($group); From 37a7f665ee3935c639ddfdded1ff689595681a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Nowacki?= Date: Wed, 24 Oct 2018 17:17:07 +0200 Subject: [PATCH 3/4] Update Rules.php Finally passing correct DBGroup to Database::connect; #1326 --- system/Validation/Rules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Validation/Rules.php b/system/Validation/Rules.php index bcf1a83f52fb..8e259436695d 100644 --- a/system/Validation/Rules.php +++ b/system/Validation/Rules.php @@ -157,7 +157,7 @@ public function is_unique(string $str = null, string $field, array $data): bool // Break the table and field apart sscanf($field, '%[^.].%[^.]', $table, $field); - $db = Database::connect(); + $db = Database::connect($data['DBGroup'] ?? null); $row = $db->table($table) ->select('1') From 1cb4732fcebe4c094165d449b930c71fc3b25eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Nowacki?= Date: Sun, 28 Oct 2018 14:18:30 +0100 Subject: [PATCH 4/4] Update Validation.php optional signifier has been removed. --- system/Validation/Validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Validation/Validation.php b/system/Validation/Validation.php index 8ef3f9b299e6..5f10cb34ab0d 100644 --- a/system/Validation/Validation.php +++ b/system/Validation/Validation.php @@ -123,7 +123,7 @@ public function __construct($config, RendererInterface $view) * * @return bool */ - public function run(array $data = null, string $group = null, ?string $db_group = null): bool + public function run(array $data = null, string $group = null, string $db_group = null): bool { $data = $data ?? $this->data;