Skip to content

Commit

Permalink
fix(form): php warning in import
Browse files Browse the repository at this point in the history
if no file was uploaded, the code fails with a warning

Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Jun 12, 2020
1 parent 89b1ed9 commit db49e89
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,14 @@ public function showImportForm() {
* @param array $params GET/POST data that need to contain the filename(s) in _json_file key
*/
public function importJson($params = []) {
if (!isset($params['_json_file'])) {
Session::addMessageAfterRedirect(
__("No file uploaded", 'formcreator'),
false, ERROR
);
return;
}

// parse json file(s)
foreach ($params['_json_file'] as $filename) {
if (!$json = file_get_contents(GLPI_TMP_DIR."/".$filename)) {
Expand Down

0 comments on commit db49e89

Please sign in to comment.