Unverified Commit ab303a00 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3554133 by pameeela, phenaproxima, darren oh: Default content importer...

Issue #3554133 by pameeela, phenaproxima, darren oh: Default content importer creates a `public:` directory in the web root when copying certain files

(cherry picked from commit 2d67d38712f5f201aa9ea3d8118407e85d93e6c5)
parent 20b6597c
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -184,8 +184,11 @@ private function copyFileAssociatedWithEntity(string $path, FileInterface &$enti
      }
    }

    $scheme = parse_url($destination, PHP_URL_SCHEME);
    $target_directory = dirname($destination);
    if (!isset($scheme) || rtrim($target_directory, ':') !== $scheme) {
      $this->fileSystem->prepareDirectory($target_directory, FileSystemInterface::CREATE_DIRECTORY);
    }
    if ($copy_file) {
      $uri = $this->fileSystem->copy($source, $destination);
      $entity->setFileUri($uri);
+4 −0
Original line number Diff line number Diff line
@@ -309,6 +309,10 @@ private function assertContentWasImported(AccountInterface $account): void {
    $term = $entity_repository->loadEntityByUuid('taxonomy_term', '9dfe4733-1347-4566-9340-27a9b22a1f64');
    $this->assertInstanceOf(TermInterface::class, $term);
    $this->assertSame('Default Content', $term->parent->entity?->label());

    // When importing files that have URIs like `public://foo.png`, the `public`
    // part should not have been treated as a directory name.
    $this->assertDirectoryDoesNotExist($this->getDrupalRoot() . '/public:');
  }

  /**