Problem/Motivation
I was reviewing the Media module recently and saw two bits of logic that definitely won't work with Content Moderation:
1. \Drupal\media\Plugin\QueueWorker\MetadataFetcher::processItem loads media items by ID, which will always load the default revision. If I understand this correctly, changing the source field on a forward revision (Draft) of a media item will not update the metadata for the latest revision.
2. \Drupal\media\MediaStorage::shouldUpdateMetadata compares the new source field value with $media->original. If $media->original isn't set the default revision of the media is loaded. Instead of loading the default revision, we should load the latest revision, I think. This one is a bit trickier and may not present practical bugs.
Proposed resolution
Add explicit support for forward revisions in the media module.
Remaining tasks
Audit more of the media module and determine what parts are incompatible with content moderation, then write a patch.
User interface changes
None.
API changes
Undecided.
Data model changes
None.
Comments
Comment #2
phenaproxima+1. All aboard the Content Moderation Pain Train!
Comment #3
marcoscanoJust wanted to mention that using content moderation at the media level will likely prevent to use it at the node level (assuming a node-referencing-media model). Technically it's possible, but with the relationship means we have today (entity_reference, links, etc) it would be of little use to have them both moderatable (and not being able to see all forward revisions at the same time, for example).
Having that said, I'm 100% in agreement that forward revisions with workspaces should work as well for media entities. So the underlying problem still needs to be addressed, maybe just some rewording to refer to the use case that's more likely to be used?
Comment #4
sam152 commentedI think there are a couple of issues that could be spun off from here. To address the issue with using moderation on both nodes and media items raised in #3 we could do something like the following:
That would allow you to create a draft of a node with a draft of a media item and preview both pending changes.
For the queue meta-data updater, I think we would need to load the exact revision that triggered the queue item creation, update the metadata there and NOT create any new revisions (pending or otherwise) from that point forwards. So we could spin off:
And:
Thoughts on splitting the effort like this and the approaches in general? I'm not sure this would create a seamless media/parent entity moderation workflow, but it would probably provide better underlying integration of the various components.
Comment #5
amateescu commentedThis is exactly what Workspaces does by default, and there are existing discussions about refactoring Content Moderation to use workspaces under the hood (#2972622-3: Split the workspaces UI into a separate module), which would bring this functionality for free :)
Comment #6
damienmckennaFYI I built this really, really kludgy module that tries to work around this limitation:
I recommend not using it and architecting your site around Paragraphs and Paragraphs Library, but if you must do it this way, this kludgy module might help.
Comment #8
sam152 commentedGood point @amateescu, I agree that bundling the moderation of multiple things together is the domain of workspaces.
I think the issue summary still describes a change that media needs to make, that is the queued thumbnail feature should be using revision IDs and also probably marking each revision as syncing: #2803717: Allow 'syncing' content to be updated in content moderation without forcing the creation of a new revision, #2329253: Allow ChangedItem to skip updating the entity's "changed" timestamp when synchronizing.
Comment #10
effulgentsia commentedAdding issue credit to this issue to @marcoscano, @pavlosdan, and @Sam152 for helpful comments made in #2969678: Integrate Media Library with Content Moderation that are more in the scope of this issue.
Comment #16
smustgrave commentedWondering if this is still an issue or been mitigated elsewhere
Comment #20
chris matthews commentedI believe this issue should be closed as a duplicate of #2969678: Integrate Media Library with Content Moderation