diff --git a/filefield_paths.inc b/filefield_paths.inc index 5254399..c90a1d9 100644 --- a/filefield_paths.inc +++ b/filefield_paths.inc @@ -67,8 +67,14 @@ function filefield_paths_filefield_paths_process_file(ContentEntityInterface $en /** @var \Drupal\file\Entity\File $file */ foreach ($field->referencedEntities() as $file) { - /** @var \Drupal\Core\StreamWrapper\StreamWrapperInterface $source_scheme */ + /** @var \Drupal\Core\StreamWrapper\StreamWrapperInterface|null $source_scheme */ $source_scheme = $stream_wrapper_manager->getViaUri($file->getFileUri()); + + // Protect the loop from errors related to the entity's origin. + if (!$source_scheme instanceof StreamWrapperInterface) { + continue; + } + $source_scheme_name = key($stream_wrapper_manager->getWrappers($source_scheme->getType())); if (in_array($source_scheme_name, $schemas) && !empty($wrappers[$destination_scheme_name])) { // Process file if this is a new entity, 'Active updating' is set or