Skip to content

Commit

Permalink
MDL-65605 core_question: Fix the issue when get_draft_files returns nul
Browse files Browse the repository at this point in the history
  • Loading branch information
rezaies committed May 20, 2019
1 parent a01edef commit 159f904
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion question/import_form.php
Expand Up @@ -112,6 +112,7 @@ protected function definition() {
* @param array $data the submitted data.
* @param array $errors the errors so far.
* @return array the updated errors.
* @throws moodle_exception
*/
protected function validate_uploaded_file($data, $errors) {
if (empty($data['newfile'])) {
Expand All @@ -120,7 +121,7 @@ protected function validate_uploaded_file($data, $errors) {
}

$files = $this->get_draft_files('newfile');
if (count($files) < 1) {
if (!is_array($files) || count($files) < 1) {
$errors['newfile'] = get_string('required');
return $errors;
}
Expand Down

0 comments on commit 159f904

Please sign in to comment.