Taxonomy filtering on media library form upload

Created on 4 July 2022, over 2 years ago
Updated 7 March 2024, 9 months ago

Problem/Motivation

When adding new media via the media library (media / media library / add media) taxonomies that the account does not have access to are filtered out and cannot be selected. However if I create a new node and use the media library widget to add a new file then the taxonomies do not seem to get filtered at all.

Steps to reproduce

1. Download Drupal 9.4.1 install using the Standard install profile, and log in as an administrator.
2. Install workbench access composer require 'drupal/workbench_access:^1.0@beta'
3. Enable workbench access
4. Create a new vocabulary add some test terms
5. Add a new taxonomy term field to a media type, e.g. Image
6. Add a media field to a content type, e.g. basic page ensure it's configured to accept the media type you've configured the taxonomy term field on
7. Create a new role, assign it permissions to create content and the media type as well as permission to be assigned to access scheme sections
8. Create a new account with the role
9. Create a taxonomy access scheme configured to use the vocabulary and the media entity type you configured
10. Assign the role to one of the sections
11. Login with the new account, visit /media/add and select the media type you added the taxonomy field to
12. Note how the taxonomy list is limited to the assigned section(s) for the account
13. Visit the add content page for the content type you configured the media field on
14. Upload a new file, note how the taxonomy list is not restricted and shows all available taxonomies

Proposed resolution

I'm not too sure where to start but if someone can try to point me in the right direction I can have a go at resolving this. From a quick look it seems to that in workbench_access_form_alter the form object is a type of AddFormBase so immediately returns out - also in FormAlterHelper the access scheme does not apply because we're working with a node rather than media.

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

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.

  • πŸ‡ΊπŸ‡ΈUnited States Jalite1991

    Can confirm this is still an issue. The taxonomy terms do not get filtered when trying to add media through the "Media Library add form upload" component and the media types are associated with the workbench schemes.

  • πŸ‡ΊπŸ‡ΈUnited States jonraedeke

    It seems like a bug if a user can assign new media to a section they don't have access to.

  • πŸ‡ΊπŸ‡ΈUnited States aarontocenter

    I can concur with @jonraedeke that this is a bug, @agentrickard can you change this request from Feature, to bug.

    Recently have a client that needs users to be able to upload to directories they are part of as a "group" associated by the "area" of ownership.

    Because of this taxonomy issue, they are able to upload files, to areas they themselves have no access too, and the only way to give them access, is to open up areas they should be restricted from.

Production build 0.71.5 2024