Skip to content

Commit cf8f56f

Browse files
committed
fix(question): better error handling
Signed-off-by: Thierry Bugier <[email protected]>
1 parent 48a0098 commit cf8f56f

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

ajax/question_add.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@
4141
}
4242

4343
if (!$question->add($_REQUEST)) {
44-
http_response_code(500);
45-
echo array_shift($_SESSION['MESSAGE_AFTER_REDIRECT'][ERROR]);
46-
unset($_SESSION['MESSAGE_AFTER_REDIRECT'][ERROR]);
44+
http_response_code(400);
4745
exit;
4846
}
4947
$json = [

js/scripts.js.php

+3-7
Original file line numberDiff line numberDiff line change
@@ -817,13 +817,9 @@ function buildTiles(list) {
817817
data: form.serializeArray(),
818818
dataType: 'json'
819819
}).fail(function(data) {
820-
// Closing and opening the modal workarounds
821-
// the whole modal being disabled when alert is shown
822-
// modalWindow.dialog('close');
823-
// alert(data.responseText);
824-
// modalWindow.dialog('open');
825-
$('#plugin_formcreator_error').text(data.responseText);
826-
$('#plugin_formcreator_error').show();
820+
// fix for GLPI <= 9.5.2
821+
$('[id^="message_after_redirect_"]').remove();
822+
displayAjaxMessageAfterRedirect();
827823
}).done(function(data) {
828824
var sectionId = form.find('select[name="plugin_formcreator_sections_id"]').val();
829825
var container = $('[data-itemtype="PluginFormcreatorSection"][data-id="' + sectionId + '"] .grid-stack');

0 commit comments

Comments
 (0)