The following review and action items is the result of discussion between @catch, @alexpott, @seanB, @phenaproxima, and myself. Most of it is followup stuff. Enjoy!
Remove from patch into "must" or "should" followups
These things should be removed from the patch so that they can be reviewed on their own without blocking the issue. Each should be mentioned in the change record with a link to the followup issue.
In the case of some parts, we might reduce the scope and add the rest back later; in other cases, the functionality might not need to be in core. But we'll discuss each in a dedicated issue. Be sure to add the notes below to the applicable summaries.
- Token integration. media_token_info(), test coverage, etc. This is a "must" followup because it is required for pathauto support. From @catch:
do we really need tokens for vid and uuid, even node doesn’t provide uuid.
This is done in #8 and the follow-up has been filed: #2877378: Add token replacements for Media.
- Actions integration, including all test coverage for it, configuration, SaveMedia action, etc. This should be a "Should" followup since we are unsure how much contrib needs this. There should also be a related followup for generic entity actions (as per tstoeckler's suggestion early on the issue). From @catch:
The actions are in config/optional but the only thing they depend on is media and system therefore they are always going to be installed. If they are there they should be in config/install.
Also, in particular:
SaveMedia::execute() is weird setting changed to 0
This was copied over from node and may not be needed?
@catch also notes that the action itself is weird and might not be needed even if we add the media actions in core.
This is done in #6 and the follow-up has been filed: #2877383: Add action support to Media module. - Remove forced validation in
Media::preSave()
and file a followup to discuss presave validation for Media and/or for entities in general ("Should"): #2877397: Determine when and if media items should validate themselves
This is done in #19 - Remove full view mode and "tricky" template title handling. There are many valid usecases for this, but it doesn't necessarily need to be in core. Add a "Could" followup note to discuss whether it should be in core: #2877400: Find a way to make title handling generic in entity templates
This is done in #19, but reverted. See #25 through #27.
Other followups to file
- File a dedicated, postponed Media Entity followup for #2696555: On the entity form of revisionable entities, make "create new revision" and "revision log" configurable and add it under "Should" on the roadmap: #2878110: [PP-1] Make revision log and "create new revision" configurable for media items
- File a "Must" followup to fix Media Entity tests for #2827014: Throw an exception when testing status code or response headers in functional JavaScript tests. From @alexpott:
The problematic test is
MediaUiJavascriptTest
- there are 4 calls to$assert_session->statusCodeEquals()
- 3 of which can be removed but the last needs replacing with an assertion on something like "The media type %name has been updated." being on the pageThe follow-up has been filed: #2878112: Fix Media JavaScript tests to account for changes in JavascriptTestBase
- File a "Must" followup to review JS tests. From @alexpott:
there's new code to wait for stuff that's not being used. This might mean that they currently have random errors.
The follow-up has been filed: #2878113: Find possible random errors in Media's JavaScript tests
- File a "Should" followup to discuss the use of
<article>
:
Twig templates use ? https://developer.mozilla.org/en-US/docs/Web/HTML/Element/article - I don't think that media items should wrapped in that.
phenaproxima: Open to suggestions here, but not sure what a more appropriate tag would be.
seanB: It’s either this, or a plain old div I believe. I think perfectly described that a media item is a ‘self-contained composition in a document’ and ‘independently distributable or reusable’.
alexpott: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/article the aria roles that are related really do not make me think this is at all related to what is in media and when you put a media entity on a node using entity reference it's going to be wrapped in article tags - inside another article - seems weird.
This follow-up has been filed: #2878115: Make the HTML wrapper tag for media items more semantically correct
- The ongoing saga of
Media::updateThumbnail()
which has been discussed at length on the issue and at the DDD sprint. Mark the darn thing explicitly internal and file a followup to discuss it more ("Should"). Someone should go through the whole issue, the DDD spreadsheet, the DDD agenda/notes, this review's notes, etc. and collect all feedback about it and put it in the followup: #2878119: Whether queued or not, update the media thumbnail and metadata before beginning the entity save database transaction
Things to fix in the patch
- @naveenvalecha changed "tempstore" to "temp store" in the patch, however:
[ibnsina:drupal | Wed 08:25:38] $ grep -r "tempstore" * | wc -l 75 [ibnsina:drupal | Wed 08:25:45] $ grep -r "temp store" * | wc -l 17
So let's use "tempstore" for now.
This is done - Fix the summary of
Media:getThumbnailUri()
. It gets the thumbnail's URI, not the media entity's. Also explicitly mark the method internal. @todo also check the issue for other discussion of this method.
This is done in #19 and #21 - Rename
Media:sourceFileChanged()
toMedia::has/isSourceFileChanged()
(which?) and explicitly mark it @internal.
This is done in #19 - In
In path_entity_base_field_info()
fix thein_array()
usage to be strict to avoid bugs.
This is done in #19 - Change
\Drupal\media\MediaAccessControlHandler::checkCreateAccess()
to allow users with 'administer media' to create (and add tests).
This is done in #19 Constructs an ImageFormatter object.
C&P error; should beMediaThumbnailFormatter
.
This is done in #19- Mark Media::updateThumbnail() @internal explicitly and add an @todo referencing the followup to be added above.
This is done in #19 - Add an @todo to the template with
<article>
referencing the followup to be added above.
This is done in #19
Comment | File | Size | Author |
---|---|---|---|
#30 | interdiff-2877346-26-28.txt | 1.09 KB | phenaproxima |
#30 | 2877346-28.patch | 234.57 KB | phenaproxima |
#26 | interdiff-21-26.txt | 6.14 KB | seanB |
#26 | 2877346-26.patch | 234.53 KB | seanB |
#21 | interdiff-19-21.txt | 545 bytes | seanB |
Comments
Comment #2
xjmComment #3
xjmComment #4
xjmComment #5
xjmComment #6
phenaproximaOkay. The three patches I'm attaching (and will need to move into the appropriate follow-up, when it's filed):
Comment #7
phenaproximaComment #8
phenaproximaAnother pass, now:
Comment #9
phenaproximaComment #10
phenaproximaAdding #2877378: Add token replacements for Media to the IS.
Comment #11
phenaproximaAdding #2877383: Add action support to Media module to the IS.
Comment #12
phenaproximaAdding #2877397: Determine when and if media items should validate themselves to the IS.
Comment #13
phenaproximaAdding #2877400: Find a way to make title handling generic in entity templates to the IS.
Comment #14
phenaproximaAdding #2878110: [PP-1] Make revision log and "create new revision" configurable for media items to the IS.
Comment #15
phenaproximaAdding #2878112: Fix Media JavaScript tests to account for changes in JavascriptTestBase to the IS.
Comment #16
phenaproximaAdding #2878113: Find possible random errors in Media's JavaScript tests to the IS.
Comment #17
phenaproximaAdding #2878115: Make the HTML wrapper tag for media items more semantically correct to the IS.
Comment #18
phenaproximaAdding #2878119: Whether queued or not, update the media thumbnail and metadata before beginning the entity save database transaction to the IS.
Comment #19
seanBBased on #8.
Media:getThumbnailUri()
sourceFieldChanged
tohasSourceFieldChanged
and added @internalin_array()
call inpath_entity_base_field_info
is changed to strict.MediaAccessControlHandler::checkCreateAccess
to allow users with 'administer media' permission. And added test.Media::updateThumbnail()
@internal and added @todoComment #20
seanBComment #21
seanBMissed the summary of
Media:getThumbnailUri()
.Comment #24
seanBThe failures seem to be caused by:
- Removing preSave validation (easy to fix).
- Removing the full view mode (at least that's what it looks like). This seems to cause issues in the cache tags tests. Still investigating this...
Comment #25
Wim LeersChange this to:
The reason the cache tags test is failing is that
\Drupal\system\Tests\Entity\EntityCacheTagsTestBase::selectViewMode()
selects the non-existentdefault
view mode. Themedia
entity currently does not include any entity view display config entities, but it should. If it only is supposed to support ateaser
view mode (which is what it looks like based on changes in #19), then it should include acore.entity_view_display.media.teaser.yml
file in itsconfig/install
directory.Basically,
\Drupal\system\Tests\Entity\EntityWithUriCacheTagsTestBase::testEntityUri()
is requesting the canonical URL of the entity, and is then verifying in the render cache that the appropriate render cache item exists. To determine the CID for this render cache item, it must know the view mode that is used to render the HTML for the canonical URL.Even if I hardcode
selectViewMode()
to return'teaser'
, it fails. This is probably becauseMedia
uses the defaultEntityViewBuilder
, which means it still defaults to thefull
view mode (see the signature of\Drupal\Core\Entity\EntityViewBuilder::view()
). But you removedfull
… Yet hardcoding it to return'full'
also fails.IOW: strange things are happening with rendering the HTML response for the canonical Media URL. You need to figure out which view mode/entity view display it uses, if any.
Comment #26
seanBAdded back the full view mode. Discussed this with phenaproxima on IRC. The main reasons:
\Drupal\Core\Entity\EntityViewBuilder::view()
uses 'full' view mode as a default. We could try to work around that, but that doesn't seem to make sense.Also fixed the
AccessResult::allowedIfHasPermissions
check inMediaAccessControlHandler
and removed the tests for media validation in PreSave (since we removed the validation).Comment #27
phenaproximaThanks, @seanB!
To reiterate: after reading @Wim Leers' comment in #25 and discussing with @seanB on IRC, we realized that removing the Full view mode is probably not a good idea because of the stuff that breaks when we remove it. Which isn't stuff we devised, and is not in Media's province.
So we have decided to do as the Taxonomy module does and ship with the Full view mode. There's precedent in core (i.e., taxonomy), and we can discuss whether or not we should remove the Full view mode for Media when and if core no longer implicitly expects it to be there.
It seems to me that all feedback has been addressed. Home stretch!
Comment #30
phenaproximaRewrote the doc comment for Media::getThumbnailUri(), since it was confusing and contained a few errors.
Comment #31
phenaproximaI have moved the patch from #30 to #2831274-391: Bring Media entity module to core as Media module. All feedback from this issue is now addressed (I confirmed each point), so I am closing it out.