Commit c8e34b18 authored by Kevin's avatar Kevin Committed by Hans van Wezenbeek
Browse files

Issue #3207649 by Kevin.-: No error message shown if moving file from temp directory fails

parent ecf17510
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ use Drupal\Component\Utility\Bytes;
use Drupal\Component\Utility\Environment;
use Drupal\Core\Entity\EntityStorageException;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\File\Exception\FileException;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
@@ -483,13 +484,12 @@ class MediaBulkUploadForm extends FormBase {

    try {
      $fileEntity->save();
      $this->fileRepository->move($fileEntity, $destination, FileSystemInterface::EXISTS_RENAME);
    }
    catch (EntityStorageException $e) {
    catch (EntityStorageException | FileException $e) {
      $this->messenger()->addError($this->t('File :filename could not be created.', [':filename' => $filename]), 'error');
    }

    $this->fileRepository->move($fileEntity, $destination, FileSystemInterface::EXISTS_RENAME);

    $values = $this->getNewMediaValues($mediaType, $fileInfo, $fileEntity);
    /** @var \Drupal\media\MediaInterface $media */