diff --git a/core/modules/file/file.module b/core/modules/file/file.module index 20282ca..9c1a2f2 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -1157,27 +1157,12 @@ function file_managed_file_save_upload($element, FormStateInterface $form_state) $files_uploaded = $element['#multiple'] && count(array_filter($file_upload)) > 0; $files_uploaded |= !$element['#multiple'] && !empty($file_upload); if ($files_uploaded) { - // Temporarily store the current error messages. - // This is needed to be able to intercept errors generated during file save, - // while keeping all other errors intact. - $error_messages = drupal_get_messages('error'); if (!$files = file_save_upload($upload_name, $element['#upload_validators'], $destination)) { \Drupal::logger('file')->notice('The file upload failed. %upload', array('%upload' => $upload_name)); $form_state->setError($element, t('Files in the !name field were unable to be uploaded.', array('!name' => $element['#title']))); return array(); } - // Intercept possible new errors, to be able to create inline errors. - if ($errors = drupal_get_messages('error')) { - // File errors are aggregated into one item, so only get the first. - $form_state->setError($element, reset($errors['error'])); - } - - // Restore earlier error messages. - foreach($error_messages['error'] as $error) { - drupal_set_message($error, 'error'); - } - // Value callback expects FIDs to be keys. $files = array_filter($files); $fids = array_map(function($file) { return $file->id(); }, $files);