Skip to content

fix(SiteSearch): URL-mapped content renders same HTML for all contentlets due to page cache collision - #34879

Merged
dsilvam merged 1 commit into
mainfrom
issue-34130-fix-title-site-search-indexes
Mar 13, 2026
Merged

fix(SiteSearch): URL-mapped content renders same HTML for all contentlets due to page cache collision#34879
dsilvam merged 1 commit into
mainfrom
issue-34130-fix-title-site-search-indexes

Conversation

@dsolistorres

@dsolistorres dsolistorres commented Mar 5, 2026

Copy link
Copy Markdown
Member

Closes #34130

Proposed Changes

  • Set WebKeys.WIKI_CONTENTLET_INODE in HTMLPageAssetAPIImpl.getHTML() method. VelocityLiveMode.buildCacheParameters() reads WIKI_CONTENTLET_INODE as a component of the page cache key. Since it was always null, every URL-mapped contentlet of the same content type produced an identical cache key — so the first contentlet's rendered page was cached and returned for all subsequent ones. With the fix in place, the page cache key is unique per contentlet, so there are not cache collision for different URL mapped items.
  • A new test method urlMapGeneratesDifferentHTMLPerContentlet has been added to URLMapBundlerTest class. The test that creates two URL-mapped contentlets with distinct field values, runs the bundler, and asserts each generated HTML file contains its own unique value.

Checklist

  • Tests

This PR fixes: #34130

…ache collision for URL-mapped content (#34130)

HTMLPageAssetAPIImpl.getHTML() never set WIKI_CONTENTLET_INODE, causing
VelocityLiveMode to build identical cache keys for all contentlets of the
same URL map content type — returning the first rendered HTML for all.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dsilvam
dsilvam added this pull request to the merge queue Mar 13, 2026
Merged via the queue into main with commit 64e21da Mar 13, 2026
43 checks passed
@dsilvam
dsilvam deleted the issue-34130-fix-title-site-search-indexes branch March 13, 2026 17:08
spbolton pushed a commit that referenced this pull request Mar 24, 2026
…lets due to page cache collision (#34879)

Closes #34130

### Proposed Changes
* Set `WebKeys.WIKI_CONTENTLET_INODE` in
`HTMLPageAssetAPIImpl.getHTML()` method.
`VelocityLiveMode.buildCacheParameters()` reads `WIKI_CONTENTLET_INODE`
as a component of the page cache key. Since it was always null, every
URL-mapped contentlet of the same content type produced an identical
cache key — so the first contentlet's rendered page was cached and
returned for all subsequent ones. With the fix in place, the page cache
key is unique per contentlet, so there are not cache collision for
different URL mapped items.
* A new test method `urlMapGeneratesDifferentHTMLPerContentlet` has been
added to `URLMapBundlerTest` class. The test that creates two URL-mapped
contentlets with distinct field values, runs the bundler, and asserts
each generated HTML file contains its own unique value.

### Checklist
- [x] Tests

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
riccardoruocco pushed a commit to riccardoruocco/core that referenced this pull request May 14, 2026
… URL 200-forwards (dotCMS#35696) (dotCMS#35704)

## What does this PR do?

Fixes a page cache key collision where multiple vanity URL 200-forward
requests routed to the same detail page all shared an identical cache
key. The first request warmed the cache and every subsequent request —
regardless of the actual incoming URL — received that cached response.

Closes dotCMS#35696

## Why is this a problem?

`VelocityLiveMode.buildCacheParameters()` composed the cache key from
`pageUrl` (the forwarded-to path), `pageInode`, `vanityUrlId`, etc. —
none of which differ between `/store/123/acme/catalog/` and
`/store/456/globex/catalog/` when both forward to the same page via the
same vanity URL rule.

On multi-node clusters with round-robin load balancing, different nodes
cached different affiliates' content under the same key, causing wrong
content on every other request for the full TTL duration (up to 1 hour).

## What is the fix?

When `VANITY_URL_OBJECT` is present on the request and `isForward() ==
true`, include `RequestDispatcher.FORWARD_REQUEST_URI` as an
`originalUri:` component in the cache key. This is the original browser
URL set by Tomcat when CMSFilter forwards to VelocityServlet via
`RequestDispatcher.forward()`.

```java
String originalRequestUri = (request.getAttribute(VANITY_URL_OBJECT) != null
        && ((CachedVanityUrl) request.getAttribute(VANITY_URL_OBJECT)).isForward())
        ? (String) request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI)
        : null;
```

Non-vanity pages and vanity redirects (301/302) are unaffected — `null`
is filtered out of the key by `PageCacheParameters`.

## Relation to dotCMS#34879

PR dotCMS#34879 fixed the same collision class for URL-mapped contentlets via
`WIKI_CONTENTLET_INODE`. The vanity URL 200-forward path was not
addressed by that fix.

## Testing

- New integration test:
`VelocityLiveModeTest#vanityForwardDifferentOriginalUriProducesDifferentCacheKeys`
- Verified locally against customer's dev environment (Freshdesk dotCMS#37004)
— different affiliate URLs now produce different cache keys and serve
correct content

## Checklist
- [x] Tests added
- [x] Existing tests pass
- [x] No new public API changes (package-private visibility change on
`buildCacheParameters()` for testability only)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area : Backend PR changes Java/Maven backend code

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[DEFECT] Incorrect and repeated titles for Site Search results [Url Mapped Content]

3 participants