fix: keep the folder id when renaming it (#35399)#35576
fix: keep the folder id when renaming it (#35399)#35576gortiz-dotcms wants to merge 6 commits intomainfrom
Conversation
|
Claude finished @gortiz-dotcms's task in 4m 32s —— View job dotCMS Backend Review
Result: 3 findings posted to the backend review comment.
Security, Java Standards, and REST API reviewers returned no findings. |
|
Semgrep found 1
The method identified is susceptible to injection. The input should be validated and properly If this is a critical or high severity finding, please also link this issue in the #security channel in Slack. |
🔍 dotCMS Backend Review[🟠 High]
final List<Map<String, Object>> affected = new DotConnect()
.setSQL("SELECT i.id FROM identifier i WHERE i.parent_path LIKE ? ESCAPE '\\' ...")
.addParam(likeParam).addParam(hostId).loadObjectResults();
...
new DotConnect().executeUpdate(
"UPDATE contentlet_version_info SET version_ts = ?"
+ " WHERE variant_id = ?"
+ " AND identifier IN ( SELECT i.id FROM identifier i WHERE i.parent_path LIKE ? ... )",
new Date(), VariantAPI.DEFAULT_VARIANT.name(), likeParam, hostId);💡 Build [🟡 Medium]
clearIdentifierCacheForSubtree(oldPath, hostId); // descendants only — root not covered
evictContentletCacheForSubtree(oldPath, hostId);
folderCache.removeFolder(folder, ident); // FolderCache only
new DotConnect().executeUpdate("UPDATE identifier SET asset_name = ? WHERE id = ?", ...);
folder.setName(newName); folder.setModDate(new Date()); save(folder);
...
CacheLocator.getIdentifierCache().removeFromCacheByIdentifier(folder.getIdentifier()); // L850 — too late💡 Move the [🟡 Medium]
final int updated = new DotConnect().executeUpdate(
"UPDATE folder SET mod_date = ?"
+ " WHERE identifier IN ( SELECT id FROM identifier"
+ " WHERE parent_path LIKE ? ESCAPE '\\' AND host_inode = ? AND asset_type = 'folder' )",
new Date(), likeParam, hostId);💡 Pass Next steps
|
|
Semgrep found 6
The method identified is susceptible to injection. The input should be validated and properly If this is a critical or high severity finding, please also link this issue in the #security channel in Slack. |
- Replace unbounded IN clause in bumpVersionTsForSubtree with correlated subquery, consistent with bumpModDateForSubFolders - Sanitize path variables in Logger.debug calls to prevent log injection - Add missing @OverRide to FolderAPIImpl.renameFolder Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Semgrep found 7
The method identified is susceptible to injection. The input should be validated and properly If this is a critical or high severity finding, please also link this issue in the #security channel in Slack. |
Summary
Fixes #35399
Before this change, renaming a folder deleted the old
identifierrow and inserted a new one with a different UUID. On push-publish receivers this appeared as a brand-new folder at the new path while the original folder (old UUID) stayed orphaned, requiring manual cleanup.What changed
Stable identifier on rename (
FolderFactoryImpl)The rename operation now updates
identifier.asset_namein place instead of replacing the row. The folder UUID is unchanged after a rename.full_path_lcis a generated column so it updates automatically whenasset_nameorparent_pathchange.Child path updates (
updateChildPaths)parent_pathfor all identifiers in the renamed subtree — including folder identifiers — is updated in bulk, sorted by ascending path depth to satisfy theidentifier_parent_path_triggerordering requirement.Push-publish detection
version_tsis bumped for every contentlet in the renamed subtree so push-publish picks them up.mod_dateis bumped for every child sub-folder via a LIKE-based subquery soDependencyModDateUtil.excludeByModDateincludes them in the bundle.Receiver reconciliation (
FolderHandler)Added a fallback lookup: if the receiver cannot find the folder by path or by inode, it searches by the identifier's existing path. This handles independently-provisioned environments where the same identifier UUID exists at a different path after a previous rename that was not yet pushed.
Cache eviction
The root folder's
FolderCacheentry is now evicted before theUPDATE identifier, using the pre-renameIdentifierobject. This removes a race where a concurrent thread could clear the identifier cache between the UPDATE andsave(), causingsave()to evict the wrong (new-path) key.Tests updated
FolderAPITest.renameFolderandFolderAPITest.renameFolder_updatesChildrenAndSubChildrenPathswere rewritten to assert stable-UUID behaviour: identifier UUIDs unchanged after rename,asset_name/parent_pathupdated in place, sub-foldermod_datebumped, and old paths absent from the DB.🤖 Generated with Claude Code