Fix: percent-encode paths when rewriting cached Portal Engine thumbnail URLs after a move#458
Fix: percent-encode paths when rewriting cached Portal Engine thumbnail URLs after a move#458robertSt7 wants to merge 1 commit into
Conversation
…il URLs after a move
rewriteChildrenIndexPaths() rewrites the cached thumbnail URL for moved
assets/data-objects in the search index, but only special-cased spaces
(" " -> "%20") when matching the path prefix. Portal Engine's frontend
thumbnail URLs are built via urlencode_ignore_slash() (rawurlencode()
per path segment), which percent-encodes any non-unreserved character,
including accented letters (e.g. "é" -> "%C3%A9"). So for any moved
folder containing such characters, the prefix match silently failed
and the cached thumbnail URL was left pointing at the pre-move path -
breaking images in Portal Engine while the Studio backend (which
re-fetches thumbnails live rather than reading the cached field)
appeared unaffected.
Pass a fully percent-encoded path variant into the Painless script and
match/replace against it as a fallback, instead of only handling
spaces.
PEES-1245
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ec16b11 to
8e684de
Compare
|
There was a problem hiding this comment.
Pull request overview
This PR addresses a Portal Engine–specific regression where cached frontend thumbnail URLs stored in the OpenSearch index are not rewritten correctly after moving asset folders whose names contain percent-encoded characters (e.g., accented characters). It extends the existing OpenSearch “rewrite children paths” Painless script to also match/replace percent-encoded path prefixes, aligning the rewrite logic with how Portal Engine constructs thumbnail URLs.
Changes:
- Pass both plain and per-segment percent-encoded variants of the old/new paths into the OpenSearch update-by-query script.
- Update the Painless script to match/replace using the encoded prefix as a fallback (generalizing the previous space-only handling).
- Add unit tests covering the new path-segment percent-encoding helper (accented characters, spaces, unreserved characters).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/SearchIndexAdapter/DefaultSearch/PathService.php |
Adds per-segment percent-encoded path parameters and updates the Painless script to rewrite cached Portal Engine thumbnail URLs reliably after moves. |
tests/Unit/SearchIndexAdapter/DefaultSearch/PathServiceTest.php |
Adds regression-focused unit tests validating the per-segment percent-encoding behavior used by the rewrite logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


PEES-1245
resolves https://github.com/pimcore/service-operations/issues/932
Moving an asset folder whose name (or a descendant's name) contains accented characters breaks image thumbnails afterwards — but only in Portal Engine, not in the Studio backend. Moving the folder back makes the thumbnails reappear without any regeneration.
Relation to #19242 (already merged into
2026.2)That PR fixed a real but different bug: a macOS-NFD vs NFC Unicode-normalization mismatch when Pimcore itself moves the physical thumbnail files on disk (
Asset::relocateThumbnails()). It's why the Studio backend now shows correct thumbnails right after a move.This PR fixes what's left: Portal Engine doesn't re-fetch thumbnail URLs live — it reads a cached thumbnail URL stored in the OpenSearch index (
custom_fields.PortalEngineBundle.system_fields.thumbnail, populated viaThumbnailService::getThumbnailPath(), which callsThumbnail::getPath(['frontend' => true])). That frontend path is built withurlencode_ignore_slash()(rawurlencode()per path segment), so accented characters end up percent-encoded (e.g.é→%C3%A9).When a folder moves,
PathService::rewriteChildrenIndexPaths()runs a Painless script against the index to rewrite that cached field's path prefix from the old to the new path. The script only special-cased spaces (" " → "%20") before attempting the prefix match — it didn't percent-encode other characters. So for any moved folder containing accented (or other percent-encoded) characters, the match silently fails, and the cached thumbnail URL is left pointing at the pre-move path — which is exactly why it "just works" again once you move the folder back to its original location (the stale cached URL matches the restored path again).Fix
PathService::updatePath()now also passes a fully percent-encoded variant of the old/new path (mirroringurlencode_ignore_slash()segment-by-segment) into the script, and the script matches/replaces against that as a fallback alongside the plain path — replacing the space-only special case, which this generalizes and subsumes.Testing
PathServiceTest::testEncodePathSegments*()covering the new percent-encoding helper (accented characters, spaces, and unreserved characters left untouched).Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com