From fdb3a8fffe5924f2222fdbcbc318533b0b994908 Mon Sep 17 00:00:00 2001 From: Ant Brown Date: Wed, 17 Nov 2021 09:34:07 +1300 Subject: [PATCH] Check we're not trying to delete default media thumbnails before saying they're inaccessible --- src/Form/ConfirmDeleteMediaAndFile.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Form/ConfirmDeleteMediaAndFile.php b/src/Form/ConfirmDeleteMediaAndFile.php index 64c1bff3c..154d45cc0 100644 --- a/src/Form/ConfirmDeleteMediaAndFile.php +++ b/src/Form/ConfirmDeleteMediaAndFile.php @@ -134,6 +134,15 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $file = File::load($target_id); if ($file) { if (!$file->access('delete', $this->currentUser)) { + // May not be allowed access because it is a default thumbnail for media type. + if ($field->getName() == 'thumbnail') { + $default_thumbnail_filename = $entity->getSource()->getPluginDefinition()['default_thumbnail_filename']; + $default_thumbnail_uri = \Drupal::config('media.settings') + ->get('icon_base_uri') . '/' . $default_thumbnail_filename; + if ($default_thumbnail_uri == $file->getFileUri()) { + continue; + } + } $inaccessible_entities[] = $file; continue; }