Repository navigation
Check the attachment, not only the role, on the media library thumbnail and EXIF routes - #2247
Open
subodhr258 wants to merge 1 commit into
Open
subodhr258 wants to merge 1 commit into
subodhr258 wants to merge 1 commit into
Conversation
…il and EXIF routes The thumbnail routes behind the Media Editor's picker and the EXIF route behind the Media Library details panel asked only for edit_posts, which does not say whose media a request acts on. They now check the attachment named in the request: - Selecting a poster, adding a custom thumbnail and removing one need edit access to the video. - Reading a video's thumbnails or an image's EXIF data needs read access to the attachment, or the right to upload files, because the Media Library lists every attachment to those users. A private attachment still needs WordPress's own read access. - The thumbnail read saves the thumbnails it fetched from Central only when the caller may edit the video. Other callers get the same response without a write. - A thumbnail URL has to be an absolute http(s) URL. - Removing a video's last custom thumbnail also clears it as the selected poster when it was the selected one. - Removing one of several custom thumbnails keeps the stored list a list, so the next read returns a JSON array the picker can show. The folder ZIP and Central listing routes keep their upload_files check. Users who pass it can already list every item in the Media Library and open its file, so those routes show them nothing more. Tests pin that.
🔍 WordPress Plugin Check Report
📊 Report
|
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
mismatched_plugin_name | Plugin name "GoDAM - Organize WordPress Media Library & File Manager with Unlimited Folders for Images, Videos & more" is different from the name declared in plugin header "GoDAM". |
0 |
trademarked_term | The plugin name includes a restricted term. Your chosen plugin name - "GoDAM - Organize WordPress Media Library & File Manager with Unlimited Folders for Images, Videos & more" - contains the restricted term "wordpress" which cannot be used at all in your plugin name. |
📁 assets/build/css/main.css (1 warning)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedStylesScope | This style is being loaded in all contexts. |
📁 assets/src/libs/analytics.min.js (5 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedScriptsScope | This script is being loaded in all frontend contexts. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880 (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/2026/10/23/hello-world/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/sample-page/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-attachment-post/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
📁 assets/build/js/main.min.js (5 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedScriptsScope | This script is being loaded in all frontend contexts. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880 (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/2026/10/23/hello-world/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/sample-page/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-attachment-post/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
The routes behind the Media Editor's thumbnail picker and the Media Library's EXIF panel asked only for
edit_posts, which says nothing about whose media a request acts on. They now check the attachment named in the request (inc/classes/rest-api/class-media-library.php):set-video-thumbnail,upload-custom-video-thumbnail,delete-custom-video-thumbnailcan_edit_attachment)get-video-thumbnail,get-exif-dataupload_filesfor media the Media Library already lists to that user (can_read_attachment). A private attachment still needs WordPress's own read accessAlso:
get-video-thumbnailsaves the thumbnails it fetched from GoDAM Central, and repairs a stale poster, only when the caller may edit the video. Other callers get the same response without a write.httporhttpsURLs (sanitize_thumbnail_url()); custom thumbnail URLs were not checked before.No change: the folder ZIP (
download-folder) and GoDAM Central listing (get-godam-cmm-files) routes keep theirupload_filescheck. Users who pass it can already list and open every item in the Media Library, so those routes show them nothing more. Tests pin that.Testing
Throwaway WordPress (Playground) with the 2.5.0 release plus this file; Admin, Editor, two Authors (A owns the media), Contributor and Subscriber, each signed in over HTTP with a REST nonce; GoDAM Central stubbed.
tests/php/MediaLibraryAttachmentAccessTest.php; full suite OK (651 tests).phpcsclean;bin/hook-checkchecks pass.Worth knowing
attachment_idnow returns 403 instead of 404.QA:
Issue: rtCamp/godam-plugin-wp#76