Repository navigation
Conversation
A custom theme keeps its scripts, stylesheets and images in the media library, where they are served as part of the weblog's design. Replacing, moving or deleting one now needs Admin on the weblog, in the media pages and through AtomPub. Other media files are unchanged.
There was a problem hiding this comment.
Two things before this merges, and some smaller ones:
-
Uploads migrated from the old uploads directory are treated as theme files.
ThemeMediaFiles.isThemeFiletreats any file with a non-blankoriginalPathas a theme file.JPAMediaFileManagerImpl.upgradeUploadsDirsetsoriginalPath(/<dir>/<name>) on every legacy upload it migrates. On a weblog upgraded that way, an Author can no longer delete, move or replace their own old photos, and is told the weblog's theme uses them. That contradicts the CHANGES entry ("Authors still manage their own media files"). Files left over from a custom theme after the weblog switches to a shared theme are locked the same way. Marking theme files explicitly, for example when the theme import creates them, or checking against the current custom theme's resources, would avoid guessing fromoriginalPath. -
The original-path field isn't covered when
mediafile.originalPathEdit.enabled=true. It's off by default, but when it's on,MediaFileEdit.save()checks only for a replacement upload or a directory change. ThesetOriginalPath(bean.getOriginalPath())call after it runs for anyone who can edit the file. An Author can clear the path on a theme file, which releases it so they can delete or replace it. Or they can set a theme path on their own upload, which then serves in its place, or makesgetSingleResultthrowNonUniqueResultExceptionfor that path. Treating a change tooriginalPathas a protected change (needing weblog ADMIN) would close it.
Smaller:
- Renaming isn't guarded. The name is the path Atom
putMediaanddeleteEntryfind the file by, so an Author's rename breaks an admin's Atom tooling for that theme file. mayChange(weblog, user, null)returns true. AtomdeleteEntrypassesgetMediaFileByPath's result without a null check, so a missing path NPEs inremoveMediaFileinstead of returning 404.putMediadoesn't null-check the weblog either. These predate this PR.- There are no tests for the Atom
putMedia/deleteEntrychecks or thedeleteFolderloop inMediaFileView.
Master twin of #387: a custom theme keeps its scripts, stylesheets and images in the media library, where they are served as part of the weblog's design, and Authors could replace, move or delete them like their own uploads.
ThemeMediaFileChangeTest. Full suite on JDK 25 (release 21): 935 tests, 0 failures.CHANGES.mdentry under 7.0.0 behaviour changes.