Skip to content
Snippets Groups Projects

Resolve #3408835 "Sqlitedatabaseexcluder accidentally includes"

1 unresolved thread

Closes #3408835

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
50 48 * The event object.
51 49 */
52 50 public function excludeDatabaseFiles(CollectPathsToExcludeEvent $event): void {
53 // If the database is SQLite, it might be located in the active directory
54 // and we should exclude it. Always treat it as relative to the project root.
51 // If the database is SQLite, it might be located in the project directory
52 // and we should exclude it.
55 53 if ($this->database->driver() === 'sqlite') {
56 $options = $this->database->getConnectionOptions();
57 // Nothing to exclude if the database lives outside the project root.
58 if (str_starts_with($options['database'], '/') && !str_starts_with($options['database'], $this->pathLocator->getProjectRoot())) {
59 return;
54 $db_path = $this->database->getConnectionOptions()['database'];
  • maybe an existing issue should be call realpath() on this? Or should \Drupal\package_manager\Event\CollectPathsToExcludeEvent::addPathsRelativeToProjectRoot()

    Otherwise couldn't this not catch a path in the project

    if (!str_starts_with($path, $project_root)) {
         throw new \LogicException("$path is not inside the project root: $project_root.");
    }

    Or is this happening somewhere else?

  • Author Maintainer

    That's a really good point, but it's a pre-existing condition that should be fixed in another issue with dedicated test coverage.

    What should be happening in CollectPathsToExcludeEvent::addPathsRelativeToProjectRoot() is something like:

        foreach ($paths as $path) {
          $path_object = $this->pathFactory->create();
          if ($path_object->isAbsolute() && !str_starts_with($path_object->absolute(), $project_root)) {
            throw new \LogicException("$path is not inside the project root: $project_root.");
          }
    Edited by Adam G-H
  • Please register or sign in to reply
  • merged

  • Please register or sign in to reply
    Loading