Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291720

MediaLibraryUiBuilder service does not properly allow additional contextual filter arguments

$
0
0

Problem/Motivation

If you attempt to add contextual filters to the core media library, they will correctly be used when the library results are initially loaded, but are not passed to the view itself, so internal display links (the "grid" and "table" buttons) get URLs built that ignore the contextual arguments.

Steps to reproduce

Add a contextual argument to the core media library (widget displays), such as "media: authored by" and select "user ID from logged in user" as the default value.

Open a media library widget. The view that is loaded only shows the media your user has created. This is correct.

Click on one of the display buttons in the header, either grid or table, and the view will refresh to show all media instead of just your own. This is wrong.

Proposed resolution

Replace the current build call in buildMediaLibraryView()

return $view_executable->buildRenderable($display_id, $args, FALSE);

with

return $view_executable->buildRenderable($display_id, [], FALSE);

I did initially try this with $view_executable->args, but that seems to be redundant and passing [] has exactly the same effect. Current behaviour which passes through just the entity type argument ($args) stops any other contextual filters from working securely when the view is rendered. The $view_executable->execute($args) call a few lines earlier already does the full argument calculations for all contextual filters.

Remaining tasks

Add tests

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 291720

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>