Skip to content

Content Drive folder listing shows content from other sites with the same folder path #38280

Open

Description

@zJaaal

Problem Statement

Inside a folder, Content Drive lists content from every site that has a folder at the same path, not only the current site. It happens with and without a search term, but search is where it's most visible: searching inside /blog/ on one site returns matches from /blog/ on every other site with that folder.

It affects any instance with more than one site that shares a folder structure, which is common after copying a site. Users see, select and act on content that belongs to another site, in a view labeled with the current one. Per-item permissions still apply, so users only see content they can read; the problem is the scope, not access.

The site root and the "all site content" view are scoped correctly. Only listings inside a folder are affected.

Cause. When a folder is selected, ContentDriveHelper builds the query with ignoreSiteForFolders(true):

builder.withHostOrFolderId(folder.getInode())
    // When a specific folder is selected, enable ignoreSiteForFolders to allow
    // folder selection without being limited by site filtering
    .ignoreSiteForFolders(true);

With that flag, BrowserAPIImpl skips the site clause (shouldApplySiteFiltering is false), so the database query is left with only id.parent_path = ?. That matches the folder path as text, which every site with that folder shares. The search runs Elasticsearch over the candidates this query returns, so it inherits the same scope. The index-only heuristic (buildPureESQuery) is not affected because it filters by conhost and the folder's inode, but it isn't the default.

Steps to Reproduce

  1. Copy a site (Sites → Copy, copy everything), for example demo.dotcms.com to a new site.
  2. Open Content Drive on the original site and open a folder that exists on both, for example /destinations/.
  3. The list shows each item twice: once from the current site and once from the copy.
  4. Search for a word in one of the titles, for example "french": matches from both sites appear.

Same check through the API, on the original site:

Request (POST /api/v1/drive/search) Original site Copied site
Folder /destinations/, no search term 6 6
Folder /destinations/, search "french" 2 2
Folders /blog/ and /store/, no search term 3 each 3 each
Site root, all site content, search "french" 8 0
Site root only, no search term 247 0

Acceptance Criteria

  • Inside a folder, Content Drive lists only content from the current site's folder, with or without a search term.
  • A folder with the same path on another site contributes nothing to the listing, its counts or its pagination.
  • The site root and the "all site content" view keep working as they do today.
  • Folder listings and search through the legacy browser endpoint (/api/v1/browser), which also uses ignoreSiteForFolders, keep their current behavior unless the spec decides otherwise.
  • Decide in the spec whether a folder listing should include System Host content at the same path when the shared assets toggle is on, and cover the decision with a test.
  • An integration test with two sites that share a folder path covers the folder listing with and without a search term.

dotCMS Version

Latest from main.

Severity

High - Major functionality broken

Links

NA

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions