_wrapper_format=drupal_ajax is always added, instead of updated when the param is already available

Created on 5 June 2023, about 2 years ago

Problem/Motivation

When Drupal detects Ajax in the page, the Ajax object is created and adds the '_wrapper_format=drupal_ajax' parameter to the urls.
The problem is that when you have embedded an ajax-enabled (web)form to a page, in some cases the '_wrapper_format=html' parameter was already added. This causes to have 2 times the same '_wrapper_format' in the POST url query. Depending you use apache or nginx, one of the 2 is removed..

Proposed resolution

First detect if the url already has this param. If so update it rather then adding it again.

My apologies if a related ticket already exists, then I will have missed it.

πŸ› Bug report
Status

Active

Version

9.4

Component
AjaxΒ  β†’

Last updated about 4 hours ago

Created by

πŸ‡§πŸ‡ͺBelgium Tim Lammar

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

Comments & Activities

  • Issue created by @Tim Lammar
  • πŸ‡§πŸ‡ͺBelgium Tim Lammar

    This Patch did the trick for me, but probably room for improvement.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Environment: PHP 8.1 & MySQL 5.7 updated deps
    last update about 2 years ago
    Custom Commands Failed
  • last update about 2 years ago
    Custom Commands Failed
  • Status changed to Needs review about 2 years ago
  • 9.4 isn’t taking ordinary bug reports.

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

    Changing to 11.x as it will have to be committed there first anyway.

    As a bug will need a test case showing the problem.

  • Status changed to Needs work about 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave
  • πŸ‡§πŸ‡ͺBelgium BramDriesen Belgium πŸ‡§πŸ‡ͺ

    Going to check if this issue is still present on D10. Currently upgrading a project that is using this patch

  • πŸ‡§πŸ‡ͺBelgium Tim Lammar

    Updated patch to work with D10.2.4

  • πŸ‡¬πŸ‡§United Kingdom Sophie.SK

    Patch in #8 also worked against a 10.4.7 site.

    We had the issue with a brand new installation of Webform.

    The error only seems to appear on the second time you try to add/delete an element without refreshing the page:

    • Select '+ Add element' at top of page
    • Choose an element and save
    • Select '+ Add element' for a second time (or select 'Save + Add element' in fly out menu)
    • Choose and element and try to save
    • Result: Ajax error in console

    Same also applies for deleting. The first time you can delete the element without issue. If you try and delete a second item, the error appears
    If you refresh the page in between adding / deleting the element, then the addition / deletion is successful.

    Applying this patch has resolved the Ajax error. We still have a console error, but the one that was preventing new elements from being added seems to have been fixed.

    Leaving as "Needs work" as it sounds like this still needs to be re-rolled against Drupal 11 though.

Production build 0.71.5 2024