From 83955b2028858f8cb5517da81946f79f458571b1 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Fri, 30 Jun 2017 09:31:49 +0000 Subject: [PATCH] dblayeroo: verify foreign keys are skipped if update and the value is not provided git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3793 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- dblayeroo.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dblayeroo.php b/dblayeroo.php index 9c89deb..d6497ff 100644 --- a/dblayeroo.php +++ b/dblayeroo.php @@ -2532,7 +2532,7 @@ class dblayeroo // Do not test in update if the field is not provided as it was already // recorded if ($update === true && ! array_key_exists ($field, $values)) - continue; + continue 2; if (! array_key_exists ($field, $values)) { $errors[$field] = sprintf (dgettext ("domframework", @@ -2554,7 +2554,12 @@ class dblayeroo $objTmp->displayAdd ($objTmp->primary); $parentField = explode (",", $params[1]); foreach (explode (",", $fields) as $key=>$field) + { + if (! key_exists ($field, $values)) + $this->DBException (sprintf (dgettext ("domframework", + "Can't check the foreign value for '%s': not provided"), $field)); $objTmp->whereAdd ($parentField[$key], "=", $values[$field]); + } if (count ($objTmp->execute ()) === 0) $errors[$field] = sprintf (dgettext ("domframework", "The value of the foreign key '%s' doesn't exists in foreign table"),