From 627a83bc0099b093f8065fba85de048886e97f75 Mon Sep 17 00:00:00 2001 From: mbressy Date: Mon, 28 Sep 2026 10:02:03 +0000 Subject: [PATCH 1/4] clarify mandatory field error --- inc/container.class.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/inc/container.class.php b/inc/container.class.php index 45afb6ed..52c21586 100644 --- a/inc/container.class.php +++ b/inc/container.class.php @@ -1669,10 +1669,11 @@ private static function isMandatoryCheckBypassed(array $data): bool * @param array $data Data send by form * @param string $itemtype Item type * @param boolean $massiveaction ? + * @param boolean $not_submitted True when the source submitted none of the fields * * @return boolean */ - public static function validateValues($data, $itemtype, $massiveaction) + public static function validateValues($data, $itemtype, $massiveaction, $not_submitted = false) { /** @var DBmysql $DB */ global $DB; @@ -1775,6 +1776,13 @@ public static function validateValues($data, $itemtype, $massiveaction) if ($empty_errors !== []) { Session::AddMessageAfterRedirect(__('Some mandatory fields are empty', 'fields') . ' : ' . implode(', ', $empty_errors), false, ERROR); + if ($not_submitted) { + Session::AddMessageAfterRedirect( + __('The form or source creating this item does not provide the mandatory fields above: map them to it, or make them optional.', 'fields'), + false, + ERROR, + ); + } } if ($number_errors !== []) { @@ -2061,7 +2069,7 @@ private static function checkContainerMandatory(CommonDBTM $item, PluginFieldsCo } } - if (self::validateValues($data, $item::getType(), isset($_REQUEST['massiveaction'])) === false) { + if (self::validateValues($data, $item::getType(), isset($_REQUEST['massiveaction']), true) === false) { return false; } From 8cc16cd6f444db4976c29c1796a1bb468a68ba85 Mon Sep 17 00:00:00 2001 From: mbressy Date: Mon, 28 Sep 2026 10:07:05 +0000 Subject: [PATCH 2/4] update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c48cc26..3982e895 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fix dependency conflict with GLPI core by no longer vendoring symfony/deprecation-contracts and symfony/polyfill-ctype. - Fix default field values not being applied when fields are empty on creation - Fix mandatory fields blocking automated item creation +- Fix unclear mandatory field error when a GLPI form creating a ticket does not provide the field. ## [1.24.5] - 2026-09-11 From 0c04d1e1f09c0951ee93b29f73adcdec098de8aa Mon Sep 17 00:00:00 2001 From: mbressy Date: Mon, 28 Sep 2026 10:27:17 +0000 Subject: [PATCH 3/4] fix CI --- inc/container.class.php | 2 +- tests/Units/ContainerItemUpdateTest.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/inc/container.class.php b/inc/container.class.php index 52c21586..5e934b7a 100644 --- a/inc/container.class.php +++ b/inc/container.class.php @@ -2069,7 +2069,7 @@ private static function checkContainerMandatory(CommonDBTM $item, PluginFieldsCo } } - if (self::validateValues($data, $item::getType(), isset($_REQUEST['massiveaction']), true) === false) { + if (self::validateValues($data, $item::getType(), isset($_REQUEST['massiveaction']), $item->isNewItem()) === false) { return false; } diff --git a/tests/Units/ContainerItemUpdateTest.php b/tests/Units/ContainerItemUpdateTest.php index 760ce33e..90367905 100644 --- a/tests/Units/ContainerItemUpdateTest.php +++ b/tests/Units/ContainerItemUpdateTest.php @@ -355,6 +355,10 @@ public function testCreateIsBlockedWhenMandatoryDomFieldIsMissing(): void __('Some mandatory fields are empty', 'fields'), ERROR, ); + $this->hasSessionMessageThatContains( + __('The form or source creating this item does not provide the mandatory fields above: map them to it, or make them optional.', 'fields'), + ERROR, + ); // Creation with the mandatory field filled must succeed. $ticket = new Ticket(); From 1b4e6822161859603ed087e5a7cb567af5bd3e1c Mon Sep 17 00:00:00 2001 From: mbressy Date: Wed, 30 Sep 2026 08:01:05 +0000 Subject: [PATCH 4/4] rename ambiguous validateValues parameter --- inc/container.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inc/container.class.php b/inc/container.class.php index 5e934b7a..9969c275 100644 --- a/inc/container.class.php +++ b/inc/container.class.php @@ -1669,11 +1669,11 @@ private static function isMandatoryCheckBypassed(array $data): bool * @param array $data Data send by form * @param string $itemtype Item type * @param boolean $massiveaction ? - * @param boolean $not_submitted True when the source submitted none of the fields + * @param boolean $is_creation True when validating a new item with nothing submitted * * @return boolean */ - public static function validateValues($data, $itemtype, $massiveaction, $not_submitted = false) + public static function validateValues($data, $itemtype, $massiveaction, $is_creation = false) { /** @var DBmysql $DB */ global $DB; @@ -1776,7 +1776,7 @@ public static function validateValues($data, $itemtype, $massiveaction, $not_sub if ($empty_errors !== []) { Session::AddMessageAfterRedirect(__('Some mandatory fields are empty', 'fields') . ' : ' . implode(', ', $empty_errors), false, ERROR); - if ($not_submitted) { + if ($is_creation) { Session::AddMessageAfterRedirect( __('The form or source creating this item does not provide the mandatory fields above: map them to it, or make them optional.', 'fields'), false,