Skip to content

Commit

Permalink
fix(formanswer): PHP 8.1 compatbility, error message if invalid JSON …
Browse files Browse the repository at this point in the history
…detected
  • Loading branch information
btry committed Oct 5, 2022
1 parent abed861 commit 8ff7ff9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion inc/targetproblem.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function save(PluginFormcreatorFormAnswer $formanswer): ?CommonDBTM {
];
foreach ($problemFields as $problemFields) {
$data[$problemFields] = $this->prepareTemplate(
$this->fields[$problemFields],
$this->fields[$problemFields] ?? '',
$formanswer,
$problemFields == 'content' // only content supports rich text
);
Expand Down
2 changes: 1 addition & 1 deletion inc/targetticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ public function save(PluginFormcreatorFormAnswer $formanswer): ?CommonDBTM {
$data['date'] = $_SESSION['glpi_currenttime'];

$data['content'] = $this->prepareTemplate(
$this->fields['content'],
$this->fields['content'] ?? '',
$formanswer,
$richText
);
Expand Down
9 changes: 8 additions & 1 deletion js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,14 @@ var plugin_formcreator = new function() {
window.location = data.redirect;
}
}).fail(function (xhr, data) {
if (xhr.responseText == '' || typeof(xhr.responseJSON.message) == 'undefined') {
if (xhr.responseText == '') {
displayAjaxMessageAfterRedirect();
return;
}
if (typeof(xhr.responseJSON) == 'undefined') {
alert(i18n.textdomain('formcreator').__('An internal error occurred. Please report it to administrator.', 'formcreator'));
}
if (typeof(xhr.responseJSON.message) == 'undefined') {
displayAjaxMessageAfterRedirect();
return;
}
Expand Down

0 comments on commit 8ff7ff9

Please sign in to comment.