Skip to content

"Select a Page" custom-field browser (legacy/old edit mode) always returns "No files found" for Pages #36662

Description

@nathan-hildebrandt

Problem Statement

The legacy "Select a Page" / "Select a file" browser dialog used by classic (old edit mode) custom fields — for example the bundled redirect_custom_field_old.vtl template — never returns any Pages, even when live/published pages exist. The dialog opens correctly and renders the site/folder tree, but the content pane always shows "No files found" for every folder, including a site's root with a guaranteed published index page.

This affects any customer using a custom field (VTL) built on dotcms.dijit.FileBrowserDialog with mimeTypes="application/dotpage" to let editors pick a Page — the picker is 100% non-functional; there is no workaround short of manually typing the page's URL.

Root cause: The dialog is configured with mimeTypes="application/dotpage":

  • dotCMS/src/main/webapp/WEB-INF/velocity/static/htmlpage_assets/redirect_custom_field_old.vtl (line 40)

That value flows: BrowserAjax.getFolderContent(...) builds a BrowserQuery.showMimeTypes(["application/dotpage"]) (dotCMS/src/main/java/com/dotmarketing/portlets/browser/ajax/BrowserAjax.java, ~lines 395-409) → BrowserAPIImpl.getFolderContent()getContentUnderParentFromDB()selectQuery()appendMIMETypeQuery() (dotCMS/src/main/java/com/dotcms/browser/BrowserAPIImpl.java, lines 2158-2163):

private void appendMIMETypeQuery(final StringBuilder sqlQuery, final List<String> mimeTypes) {
    final String mimeTypesFilter = String.format(" AND (%s)", mimeTypes.stream()
            .map(mimeType -> String.format("jsonb_path_exists(c.contentlet_as_json,'$.fields.**.metadata ? (@.contentType like_regex \".*%s.*\")')", mimeType))
            .collect(Collectors.joining(" OR ")));
    sqlQuery.append(mimeTypesFilter);
}

This checks whether a binary field's stored metadata has contentType matching the requested MIME type. "application/dotpage" is not a real, persisted value anywhere in a Page Contentlet's contentlet_as_json — it is a synthetic label invented only when building the JSON response sent back to the browser, in BrowserAjax.java (~line 788): pageMap.put("mimeType", "application/dotpage");. That assignment happens client-response-side, after the SQL query already ran, and is also used by a separate, harmless in-memory filterReturnList check — it is never written back into any contentlet's actual stored metadata.

Since Pages (post "HTML Page as Content" refactor — see Task03100HTMLPageAsContentChanges.java) have no binary field at all, jsonb_path_exists(...) can never evaluate true for a Page row. appendMIMETypeQuery therefore unconditionally excludes every Page from the SQL result set whenever mimeTypes=["application/dotpage"] is requested — regardless of publish state, permissions, host, or folder. This is a structural mismatch between a synthetic display-only label and a real DB-level filter, not a data or configuration problem.

Steps to Reproduce

  1. On a content type with a custom field built on the bundled redirect_custom_field.vtl template (or any custom field/VTL that opens dotcms.dijit.FileBrowserDialog with mimeTypes="application/dotpage"), open the content edit form in classic/old edit mode.
  2. Click the field's "Select a Page" button to open the file browser dialog.
  3. Navigate to any site root or folder that has at least one published (live) Page — e.g. the site's index page.
  4. Expected: the live Page(s) under that folder appear in the results list, selectable.
  5. Actual: the folder tree renders correctly (site/folder navigation works), but the content pane always shows "No files found" — no Pages are ever listed, even the guaranteed-published root index page.

Acceptance Criteria

  • Opening the "Select a Page"/"Select a file" browser (legacy custom field, e.g. redirect_custom_field_old.vtl) on any folder containing at least one live Page returns that Page in the results list
  • The root index page of a site (published/live) appears in the browser when navigating to that site's root
  • Existing File Asset / dotAsset mimeType filtering (e.g. an image-only custom field) continues to work unchanged after the fix
  • The original bug (Pages never appearing regardless of publish state, host, or folder) no longer reproduces on any folder/site combination

dotCMS Version

26.06.04-01
26.06.22-02

Severity

High - Major functionality broken

Links

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions