diff --git a/CHANGELOG.md b/CHANGELOG.md index 738978cb0d..4d72424b22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Faster order form, reception, bills and budget tabs on large volumes (missing indexes, budget check and prices read in one query) +- An order can no longer be locked by picking, from its form, a status that only the validation workflow should set +- Default order status labels are no longer stored HTML-escaped ## [2.12.12] - 2026-10-06 diff --git a/inc/order.class.php b/inc/order.class.php index 56a30ff073..fa358d6303 100644 --- a/inc/order.class.php +++ b/inc/order.class.php @@ -997,9 +997,17 @@ public function showForm($ID, $options = []) echo ""; $state = $this->getID() ? $this->fields["plugin_order_orderstates_id"] : $config->getDraftState(); if ($canedit) { + // Other states lock the order and must only be reached through the validation workflow + $editable_states = [$config->getDraftState()]; + if ($config->useValidation()) { + $editable_states[] = $config->getWaitingForApprovalState(); + } + PluginOrderOrderState::Dropdown([ - 'name' => "plugin_order_orderstates_id", - 'value' => $state, + 'name' => "plugin_order_orderstates_id", + 'value' => $state, + 'display_emptychoice' => false, + 'condition' => ['id' => $editable_states], ]); } else { echo Dropdown::getDropdownName("glpi_plugin_order_orderstates", $this->getState()); diff --git a/inc/orderstate.class.php b/inc/orderstate.class.php index 8f39b80338..132678a865 100644 --- a/inc/orderstate.class.php +++ b/inc/orderstate.class.php @@ -102,13 +102,13 @@ public static function install(Migration $migration) $state = new self(); foreach ( [ - 1 => __s("Draft", "order"), - 2 => __s("Waiting for approval", "order"), - 3 => __s("Validated", "order"), - 4 => __s("Being delivered", "order"), - 5 => __s("Delivered", "order"), - 6 => __s("Canceled", "order"), - 7 => __s("Paid", "order"), + 1 => __("Draft", "order"), + 2 => __("Waiting for approval", "order"), + 3 => __("Validated", "order"), + 4 => __("Being delivered", "order"), + 5 => __("Delivered", "order"), + 6 => __("Canceled", "order"), + 7 => __("Paid", "order"), ] as $id => $label ) { if (!countElementsInTable($table, ['id' => $id])) { @@ -118,6 +118,23 @@ public static function install(Migration $migration) ]); } } + + // Default labels used to be stored HTML-escaped + $escaped_states = $DB->request([ + 'SELECT' => ['id', 'name'], + 'FROM' => $table, + 'WHERE' => [ + 'id' => range(self::DRAFT, self::PAID), + 'name' => ['LIKE', '%&%'], + ], + ]); + foreach ($escaped_states as $data) { + $DB->update( + $table, + ['name' => htmlspecialchars_decode($data['name'], ENT_QUOTES)], + ['id' => $data['id']], + ); + } }