Unverified Commit b6c78e32 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 2d67d387)
parent a1b29b60
Loading
Loading
Loading
Loading
Loading
+4 −1
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
@@ -326,6 +326,10 @@ private function assertContentWasImported(AccountInterface $account): void {
    $workspaces = Workspace::loadMultiple();
    $this->assertArrayHasKey('test_workspace', $workspaces);
    $this->assertSame('test_workspace', $workspaces['inner_test']?->parent->entity->id());

    // 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:');
  }

  /**