Many drag and drop fixes#270
Conversation
- Changed references from 'user_id' to 'owner_id' in trash-related functions to better reflect ownership semantics. - Updated SQL queries in trash functions to use 'owner_id' for consistency. - Enhanced drag-and-drop functionality for shortcuts to include 'entityId' for better identification of source entities. - Implemented cascade cleanup for placements when a WordPress entity is trashed or deleted, ensuring corresponding desktop shortcuts are also soft-trashed. - Added unit tests for cascade cleanup functionality to verify correct behavior across various entity types (posts, attachments, users).
✅ WordPress Plugin Check Report
📊 ReportAll checks passed! No errors or warnings found. 🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check |
|
@claude what about a review here? those are many fixes for drag and drop (it was not working dragging from media to Gutenberg, and from OS to Gutenberg). Then another refactor happened, as we were mixing owner_id and user_id columns. And Lastly we were not able to drag and drop anything from My WordPress to the trash. This PR tries to address it all. |
|
Claude finished @AllTerrainDeveloper's task in 4m 36s —— View job PR Review: Many drag and drop fixesReviewed PR #270 — 22 files, three independent streams: Gutenberg DnD, Todo:
Stream 1 — Gutenberg drag and drop (OS files + Media Library list view)
The core fix (stash the bridge payload + native HTML5 backstop for when Chromium strips the custom MIME at the iframe boundary) already existed. This PR adds two meaningful improvements:
This file is documented in its own header as "a vanilla IIFE with no build step" — a deliberate exception to the TypeScript build pipeline that predates v0.14.0 and is separate from the
Stream 2 —
|
| Hook | Covers |
|---|---|
wp_trash_post |
Post/page/attachment soft-trash (all routes incl. our own drag-to-trash CMO, WP admin, WP-CLI) |
before_delete_post |
Force-delete (skips trash stage) |
delete_attachment |
Hard-delete path for attachments |
deleted_user |
Account removal |
The wp_trash_post handler correctly detects post_type === 'attachment' and redirects to file_type='attachment' so the wrong file-type isn't searched. The desktop_mode_files_cascade_trash_placements_for_entity() function is idempotent, bulk-friendly, and fires a per-placement action for plugins.
Tests cover: soft-trash, idempotency, file-type isolation, all four hook paths, action firing, cascade marker in trashed_meta. That's comprehensive for a new file.
One small note on trashed_by in the cascade: it's set to $owner_id (the placement owner) rather than the acting user, since cascade-trashing is a side-effect of an entity-level authorized action, not a direct user gesture. This is correct and well-documented in the function's docblock.
Overall assessment
The three streams are logically independent and well-separated. The code quality is high:
- No security issues found
- All SQL uses
$wpdb->prepare() - Error paths are handled defensively without silent no-ops
- The cascade-cleanup design follows the framework's hook patterns
Two items worth a follow-up before merge:
RENAME INDEXMySQL/MariaDB compatibility (cosmetic/logging risk, not data corruption)- Preview-pane deselection on drag-to-trash (minor UX gap)
Neither is a blocker but the RENAME INDEX one could produce confusing error log entries for some users.
Uh oh!
There was an error while loading. Please reload this page.