media_library_opener leads to massive GET requests that break varnish etc.

Created on 21 November 2023, about 1 year ago
Updated 21 August 2024, 4 months ago

Problem/Motivation

See πŸ“Œ Compress ajax_page_state Fixed for discussion.

media_library adds media_library.opener params to query parameters, including duplicate ones, leading to massive URLs like this:

https://dev.www.my-test-site.com/testing/views/ajax?ajax_form=1&_wrapper_format=drupal_ajax&media_library_opener_id=media_library.opener.field_widget&media_library_allowed_types%5Bimage%5D=image&media_library_selected_type=image&media_library_remaining=1&media_library_opener_parameters%5Bfield_widget_id%5D=field_media_image%3A-field_paragraph_band-0-subform&media_library_opener_parameters%5Bentity_type_id%5D=paragraph&media_library_opener_parameters%5Bbundle%5D=page_header&media_library_opener_parameters%5Bfield_name%5D=field_media_image&media_library_opener_parameters%5Bentity_id%5D=725&media_library_opener_parameters%5Brevision_id%5D=797&hash=MdCytfJWxVGpEfN1LYH6YKwhAuiPKz_o-u8JaIl7hyY&_wrapper_format=drupal_ajax&view_name=media_library&view_display_id=widget&view_args=image&view_path=%2Fnode%2F105%2Fedit&view_base_path=admin%2Fcontent%2Fmedia-widget&view_dom_id=5d0e1f479c58d847ab8977967424d7ed258a264e1a11b05cc3b3abb68e179991&pager_element=0&ajax_form=1&_wrapper_format=drupal_ajax&media_library_opener_id=media_library.opener.field_widget&media_library_allowed_types%5Bimage%5D=image&media_library_selected_type=image&media_library_remaining=1&media_library_opener_parameters%5Bfield_widget_id%5D=field_media_image%3A-field_paragraph_band-0-subform&media_library_opener_parameters%5Bentity_type_id%5D=paragraph&media_library_opener_parameters%5Bbundle%5D=page_header&media_library_opener_parameters%5Bfield_name%5D=field_media_image&media_library_opener_parameters%5Bentity_id%5D=725&media_library_opener_parameters%5Brevision_id%5D=797&hash=MdCytfJWxVGpEfN1LYH6YKwhAuiPKz_o-u8JaIl7hyY&page=1&_drupal_ajax=1&ajax_page_state%5Btheme%5D=framework_admin_theme&ajax_page_state%5Btheme_token%5D=SD2fJyW4XLNuU287foru_6-9lT9JjPOl_P1bY9BT7NA&ajax_page_state%5Blibraries%5D=eJx9lH2aozAIxi-UxjPsSXxQUTNNghuInc7pFz-iY2en_yj8XkgpYKALLtZC5BtI1f62khAN_CrZkWZMLgpGuYatbz6CXUvRNET3qkt5Am8X27R37JxQKrD4vwp28nlwke3Gg1IwrYdEJTLCfBNoeKeDpwb8jeXpXRx2uKbV3jUJ0tPKiAF3JVKHt55SMC15Sg19Vh32kL0coHZRj8LqxT91dmHyWHuCrloeqiQs5UErbsabZtyvPAu1tCQKXgQ91sPEV6jddvIshZ78B2ABQb4gbY7HLsHwkybkiSJrgZu2zDVFVT_-ZtROncdHtcC7LzTXOe3j-x-02nNPg-mdP-tVewH6M9-QeqanKPBApoDVN9vyPLzTLI8umHW--5QxNNjVZX_qbdiXBaiyewEP1w0oZlmGY63U3sDaBGr6zK32Vs8H548lmUAbm2AauSSeZJ29tvd9UKAO_PuQvbwJZDxVGVew7FGpP-mfSthKCSq-XT9UwyMlafMhF9_wkwVDtUdtTgO6gi83wKtvUVsy4Z81TygvQk4mB2Cu-wQBH5Tu9X5NLIMon2fLbDKfS7DY65XBZnb44Gp9WviAzwvQZmWP_wAsB9ZA

Steps to reproduce

Proposed resolution

1. Find out why it's duplicated and ensure that doesn't happen, might need a change in MediaLibraryState
2. Look at compressing this the same way ajax_page_state is compressed. The current code includes serialized PHP, so we could probably replace that with json_encode() too which would be an improvement in itself.
3. If for some reason it's still massive, look at other options like storing state in temp store.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
MediaΒ  β†’

Last updated 3 days ago

Created by

πŸ‡¬πŸ‡§United Kingdom catch

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

Comments & Activities

  • Issue created by @catch
  • πŸ‡ΊπŸ‡ΈUnited States bkosborne New Jersey, USA

    I think I ran into this today. Received reports that someone could not browse past the 2nd page of a media library when browsing from the widget. I observed that the request header size grew to over 8kb which was the limit in Varnish. Inspecting the request, I see that a ton of the query string parameters are being duplicated on each page load.

  • πŸ‡ΊπŸ‡ΈUnited States bkosborne New Jersey, USA

    I just spent an hour trying to figure out why duplicate params are being added. I still have no idea unfortunately. Paging through the media library directly (outside of the field widget) doesn't cause the duplicates issue. It's just within the media library widget. So I have to think it's something in either media_library.view.js or media_library.widget.js, but I can't find any obvious places to start debugging.

    I guess this is less of a problem on 10.2.x because the libraries param of the ajax page state is compressed β†’ , but I don't plan to upgrade our sites to 10.2.x for a couple more months.

  • πŸ‡¬πŸ‡§United Kingdom catch

    Adding a couple of related issues.

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    I've just run into this with a client as well, this is on Drupal 10.3.2 (also reproducible on 10.2.6). It only happens on AWS environments and only when editing a node, not adding. Exposed filters work fine as well as exposed sorts.

    The difference between editing and adding a node is down to query param length

    When editing a node the query param is 2162 characters long
    When adding a node the query param is 1938 characters long

    This is referring to the number of characters appearing after /views/ajax? when clicking a pagination link in the media library on the above mentioned screens

Production build 0.71.5 2024