Drupal 8, Media, and incompatibility with a common "group" module configuration

Created on 8 May 2020, about 4 years ago
Updated 9 September 2023, 10 months ago

If you have a Drupal site that is leveraging the group module, a common permissions setup is that users do not have the general Drupal permission to create certain node types (let's say: Basic Page). However, they CAN create the content type in a group! This is so they can't create "orphan" content with no parent group.

When you have media configured on a field, and a user without the general Drupal permission to create a content type goes to upload media onto a field, you get an AJAX error on file submission for upload. It's because MediaLibraryFieldWidgetOpener::checkAccess checks to see if the user has global permission to create the node in question.

No good ideas for a general solution offhand. I was able to resolve this with a custom patch that adjusts the check for our needs, but I've got no other ideas offhand. Group has some information stashed and available in $form_state that perhaps could be made accessible? Perhaps a custom alter option?

πŸ› Bug report
Status

Closed: cannot reproduce

Version

9.5

Component
MediaΒ  β†’

Last updated about 16 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States jnicola

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024