Needs work
Project:
Drupal core
Version:
main
Component:
views.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
10 Jan 2017 at 21:24 UTC
Updated:
3 Sep 2026 at 18:53 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
dwwPartially working patch based on porting the latest code from barraponto at #1183418-106: Ajax attached to exposed filters in form_alter doesn't trigger callback to D8.
Comment #3
lendudeHere is a failing test for this. Haven't actually tested it with the fix yet :-)
The lack of a form-id makes the ajax framework think we have a too large file upload and throws an error that has nothing to do with this, see screenshot taken during the test after the waitforajax()
Comment #4
lendudeAnd now without the half finished line .....
Comment #7
lendudeCombined patch with a bit of a cleanup of #2, still fails, but with a different error now.
Comment #9
michielnugter commentedCurrent fail is because the right triggering element cannot be found. Somehow on
core/lib/Drupal/Core/Form/FormBuilder.php line 1316 the $input['_triggering_element_name'] is empty while it definitly is in the _POST.
Patch is a small improvement in javascript and an incorrect by-reference.
Comment #10
lendudeMore cleanup.
And this is were it goes wrong, because this is a GET form. When looking at
\Drupal\Core\Form\FormBuilder::processFormyou see that it just gets the GET data. So all the values that have been set in the form aren't there either, because they are done by POST. So even if the _triggering_element gets set, you still won't have any values to work with.Comment #13
joelpittet@dww regarding the triggering element recently in D7 (may have been entityreference changes) was fixed by this which may be related #2546700: Add support for detecting the triggering element when buttons are changed client-side
Comment #14
mcfdez87 commentedI implemented the #10 path and the ajax request returns me a very strange response: https://pastebin.com/hStUS8B0
Any suggestion?
Comment #15
mcfdez87 commentedComment #16
mcfdez87 commentedSame issue using Drupal 8.3.2. I applied the patch but it returns me this error in the AJAX response: https://pastebin.com/gDhW6Jnd
Any suggestion?
Comment #17
danielbeeke commentedpeter-van-lierop and I have written a patch which we think fixes this issue.
We are not to sure about the underlaying code. So this needs a good review.
Comment #20
edurenye commentedThe patch from #17 does not work.
Comment #21
leolani commentedI got stuck on this issue for several hours until i found that this is a core issue, so what is the status of this bug or did anyone find a temporary workaround or a working patch ?
Comment #22
lonaloreI have solved this issue in the same way as @danielbeeke and @peter-van-lierop did. But I changed only the FormBuilder class.
Comment #23
lonaloreI attached wrong file in my previous post, sorry. '-.-
Comment #24
anpolimusExpecting the same issue at my project.
patch at #2 fixed it.
Comment #25
anpolimusComment #26
anpolimusAjax callback is executed now, but all data and input value of the triggered element is empty.
Comment #27
anpolimusTested all working patches at this thread - callback execution is working, but form values of triggering element are empty.
Comment #29
Pascal- commentedPatch in #23 doesn't work for me :(
Comment #30
Anonymous (not verified) commentedPatch #23 also doesn't work on Drupal 8.5.3, PHP 7.1, MySQL 5.6
Comment #31
anpolimusHave just attached patch at #23 after core update - issue is fixed.
@Pascal-, @darjanpezer could you please send output of your chrome console during ajax request?
Comment #32
Pascal- commentedTo explain it quickly, I have a view that allows you to filter property for sale by 3 separate taxonomy terms.
The view has it's filter exposed as a block to show them on the frontpage.
The filters are also shown on the propery overview page.
Without AJAX enabled, everything works properly.
When I enable AJAX (Use AJAX option in the view, under the advanced tab)
On the property overview view page:
Nothing happens when I change one of the search terms (the goal is to filter immediately after changing a filter value right?)
When clicking the search button I get the following error in my console:
On the frontpage:
The exposed filter block still works. (Still have to click search, but I like that)
Shouldn't the search button be hidden as well once AJAX is enabled?
Screenshot of the view settings with AJAX still disabled: https://gyazo.com/510f7aea0adcaacba756df62b3c215ef
Comment #33
dawehnerI think changes like that in the forms subsystem would be worth getting a review from. I pinked @tim.plunkett on slack.
Comment #34
dawehnerWhile working on the same kind of problem I needed a couple of adjustments, see interdiff, to make it working for me. (embedding an entity browser
Comment #36
jafacakes2011 commentedPatch in #34 doesn't apply to 8.6.x
The attached patch should.
Comment #37
sadeghpro commentedhi,
I use the patch in #36 its work and there is no error anymore but I have another problem with
$form_state->getValues();in callback function.values empty for example in my case if dump values:
but if sniff packet its send year
Comment #38
ammar qala commented@sadeghpro I've reached the form values through the below:
$form_state->getStorage()['view']->getRequest()->request->get('field_name');maybe there's a better way but this works fine.
Comment #39
scott_euser commentedThe GET vs POST issue was not in the ViewsExecutable which appears to be why the value was not there. Getting directly like in #38 does not solve all problems as, for instance, use of Better Exposed Filters still appears to leave the $form_state->isSubmitted() incorrectly as false.
Interdiff unfortunately failing, but here is the code addition found in the patch compared to #36:
Updated patch applying to latest 8.7.
Assuming here that the tests will continue to fail as no changes made there.
Comment #40
scott_euser commentedAnd a patch for 8.6.x for those who need
Comment #42
arun ak commented@scott_euser even after apply the patch getting the same error:
An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (32 MB) that this server supports.Comment #43
_dcre_ commentedUsing patch #40 solves the file exceeding size..etc issue
However there seems to be another issue now
My custom views filter is inheriting from ManyToOne parent class, not FormBase apparently
When i set the ajax callback like this
'callback' => ['::sayHello']
the callback is never triggered
when i set it like this
'callback' => [$this,'sayHello']
i get the following js errors in the console
1 Uncaught SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at drupalSettingsLoader.js:14
at drupalSettingsLoader.js:16
(anonymous) @ drupalSettingsLoader.js:14
(anonymous) @ drupalSettingsLoader.js:16
big_pipe.js?v=8.6.16:25 Uncaught TypeError: Cannot read property 'callback=Drupal%5CCore%5CRender%5CElement%5CStatusMessages%3A%3ArenderMessages&args%5B0%5D&token=_HAdUpwWmet0TOTe2PSiJuMntExoshbm1kh2wQzzzAA' of undefined
at HTMLScriptElement.bigPipeProcessPlaceholderReplacement (big_pipe.js?v=8.6.16:25)
at Function.each (jquery.min.js?v=3.2.1:2)
at r.fn.init.each (jquery.min.js?v=3.2.1:2)
at bigPipeProcessDocument (big_pipe.js?v=8.6.16:52)
at big_pipe.js?v=8.6.16:66
bigPipeProcessPlaceholderReplacement @ big_pipe.js?v=8.6.16:25
each @ jquery.min.js?v=3.2.1:2
each @ jquery.min.js?v=3.2.1:2
bigPipeProcessDocument @ big_pipe.js?v=8.6.16:52
(anonymous) @ big_pipe.js?v=8.6.16:66
drupal.js?v=8.6.16:13 Uncaught TypeError: Cannot read property 'currentQuery' of undefined
at Object.attach (active-link.js?v=8.6.16:12)
at drupal.js?v=8.6.16:25
at Array.forEach ()
at Object.Drupal.attachBehaviors (drupal.js?v=8.6.16:22)
at drupal.init.js:16
at HTMLDocument.t (ready.min.js?v=1.0.8:4)
attach @ active-link.js?v=8.6.16:12
(anonymous) @ drupal.js?v=8.6.16:25
Drupal.attachBehaviors @ drupal.js?v=8.6.16:22
(anonymous) @ drupal.init.js:16
t @ ready.min.js?v=1.0.8:4
drupal.js?v=8.6.16:13 Uncaught TypeError: Cannot read property 'ui' of undefined
at Object.attach (locale.datepicker.js?v=8.6.16:24)
at drupal.js?v=8.6.16:25
at Array.forEach ()
at Object.Drupal.attachBehaviors (drupal.js?v=8.6.16:22)
at drupal.init.js:16
at HTMLDocument.t (ready.min.js?v=1.0.8:4)
The above js errors occur on page load, not when i try to invoke the callback.
Funny thing is that when i use
'callback' => ['::sayHello']
as said, the callback is not invoked
if i change the above to
'callback' => [$this,'sayHello']
and i DONT cc/reload the page, then the callback is triggered correctly and everything goes well
if i reload the page, i get all the above js errors, and no js can be executed any more
any ideas?
Comment #44
shadcn commentedRe-rolled.
Comment #45
shadcn commentedhmm
Comment #47
codium commentedComment #48
codium commentedComment #49
revati_gawasI used patch #45 and it works for Block Views exposed filter, but getting error like
An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (2 MB) that this server supports.while using #ajax on Page views exposed filter field element. Here what I've got is triggered element were not properly set to $form. So I just added proper page view form path for triggered element.Also I have checked method type with
$form_stateinstead of current request, cause if we check method type by current request, then taxonomy listing page is getting break and showing error likeNotice: Undefined index: terms in Drupal\taxonomy\Form\OverviewTerms->buildForm().A patch against for 8.8.x. Please review.
Thanks!!
Comment #50
revati_gawasComment #51
andysipple commentedI created this issue for media library widget. Turns out to be related to this issue thread. I have patch #39 applied and also tried the other patches below that one.
When using the media library widget the user is unable to use the exposed filters. There is an ajax console log error
Drupal.AjaxError {message: "↵An AJAX HTTP error occurred.↵HTTP Result Code: 20…modules/media_library/src/MediaLibraryState.php).", name: "AjaxError"}Removing the patch the user is able to use the filters again.Did some digging around the issue is resolved when I change the following in core/modules/views/src/ViewExecutable.php line 692
back to this
Comment #52
daveianoI am developing a custom views_exposed_form_plugin and also run into this problem. Patch #39 solves it on a Drupal 8.7.5 for me.
@_dcre_ I also noticed this. For declaring the callback neither
nor this works:
I need to declare the callback via the complete class path like this:
EDIT: Another problem is, that if my form element is in the first dimension e.g.
$form['my_element'], it work's like describe above. If I wrap my element with a details element:$form['details']['my_element'], I am getting the filesize error again.Comment #53
shubham.prakash commentedComment #54
shubham.prakash commentedReroll
Comment #56
daveianoI rerolled the patch from #49 against Drupal 8.7.x if somebody needs it.
@revati_gawas is right: checking the request method directly in the request, and not in the form_state leads to some errors: for me, the bulk operations did not work with the patch applied.
That was the part from previous patches:
Comment #57
kirantej_p commentedPatch mentioned in #39 worked for me. Also, the callback function mentioned in #52 works.
Still, the first dropdown values are not being passed to the second dropdown callback function.
Comment #58
kirantej_p commentedInstead of hacking core, I achieved it using "Request" in form_alter.
I am able to fetch the values using below code:
Implemented in Drupal 8.7.6
Just for anyone's help.
Comment #59
matthieuscarset commentedI was having an issue with custom
#ajaxon a View Exposed Form with Better Exposed Filters in a Drupal8.7.7website.I've used patch #56 and it fixed the situation.
Form elements with Ajax behaviors are working and the too large file exception on submission is not thrown anymore.
Comment #61
cadila commentedHello. Patch from #56 brakes all the Bulk operations in views. Need to find a better solution than this.
Comment #62
Andrei Tyuhai commentedComment #63
Andrei Tyuhai commentedAttaching fix to resolve conflict with View Bulk Operations.
Comment #64
Andrei Tyuhai commentedLast patch was created from the wrong folder. Re-rolling.
Comment #65
Andrei Tyuhai commentedComment #66
dwwThanks, all, for the progress in here!
Not sure what @codium was doing in #47 + #48. Restoring the original priority. This is not a minor bug.
I don't have time right now to more thoroughly review the latest work, but I hope to do so in the near future.
Cheers,
-Derek
Comment #67
dwwUgh. The re-roll in #49 lost the new
core/modules/views/tests/modules/views_test_exposed_filter test modulethat the test depends on. Every patch since then has been invalid. :/This patch restores that test module (last seen in #45), and otherwise builds on #64.
The new test class still fails locally, but at least we're getting closer to a valid test and fix. ;)
No time to dig deeper right now.
This also fixes the code-style bugs mentioned at https://www.drupal.org/pift-ci-job/1478798
Comment #68
dwwOkay, I lied. ;) I looked a little deeper. The test fail I mentioned in #67 is because
setUp()is already logging in an admin user. So trying to create a new admin user and logging in inside the new test method fails since we're already logged in.So, this now passes locally. I assume the bot will be happy, too.
Also uploading a test-only that should fail.
Getting closer! ;)
Cheers,
-Derek
Comment #70
dwwThat's nice, the bot agrees. It found some more code style bugs, fixed here.
Meanwhile, closer review of #68:
WTF is this doing? ;) Seems really weird and wrong. Haven't looked through all the comments in here to figure out when it was added and why.
Too bad we have to use
\Drupal::request()here instead of proper dependency injection (DI). But the code it replaces is already doing that, so I guess we can punt on this for now.This could use a bit more help. ;)
This should use
drupal:viewsAttached patch fixes 3 and 4, but 1 is still TODO. 2 is probably out of scope.
Comment #71
dwwThe weird code in #70.1 was also added in #49. :/ The new test passes locally without it. So for now, I'm completely removing it. No need for yet another test-only here.
I still haven't fully groked all the comments and all the code in this patch. But I think we're getting fairly close to a viable fix for this bug. ;)
Comment #73
Andrei Tyuhai commentedThanks, @dww.
Regarding item 1 at #70.
Intent of this code is to throw different type of exception before it is thrown by buildForm method.
To my mind, this condition needs to be adjusted, because in current situation it has nothing in common with post_max_size limit.
Comment #74
dwwRe: #73: duly noted, thanks. However, why is
$form['secondary']relevant? How can we know or care, that deep inside the Form API, that a form element called 'secondary' exists at all, much less do anything special with it?Comment #75
Andrei Tyuhai commentedAgreed. I've tested my scenario again (custom views filter plugin with ajax callback +vbo) - there is no any
$form['secondary']element in the form. I think it was occasionally included into the patch #49 during testing of some project-related scenario. Relying on request method type and triggering element is enough for all the situations I could test.Patch #71 fixed both issues (with vbo and views filter ajax) for me.
The only change I may to propose is to merge isset condition:
if ($triggered && isset($form[$triggered]) && isset($form[$triggered]['#ajax']))like this:
if ($triggered && isset($form[$triggered]['#ajax']))Comment #76
wheelercreek commentedYou guys are life savers! I just happened to need to do this today and couldn't figure out why the callback wasn't firing! Patch 71 works for me.
Comment #77
dwwRe: #75 -- good point, simplified the
isset(). Also removing a stray newline from core/modules/views/src/ViewExecutable.php. Glad to hear you agree that #70.1 should go, and that your tests are working fine without it.Re: #76 -- great, glad to hear it's working for you. :)
Any other changes, or is this RTBC? I'll ping @Lendude as another Views subsystem maintainer so we can remove that tag.
Thanks!
-Derek
Comment #78
lendudeNice to see progress on this, been a while since I was last here :)
This change seems to lack test coverage. And if this really needs this change outside the Views module, it would be great if we can trigger this without the Views module being involved, to show that we really need to have this in the formbuilder (because I'd prefer not to bother the formbuilder with the weird requirements of Views unless we really have to)
This should really use waitForElement or something of that ilk instead of assertWaitOnAjaxRequest. We probably need to add a little wrapper to the ajax reply to make it easy to detect the change
Comment #79
dww@Lendude thanks for #78!
Re: #78.1: Good points. Sadly, if I revert that hunk and re-run the test locally, it fails:
So yeah, apparently it is needed for this to work. But right, it'd be nice to have a test completely outside of Views to show that, if possible.
Re: #78.2: What's wrong with waiting for the AJAX request to finish, then asserting the text is there? Basically, why do you say this?
Thanks!
-Derek
Comment #80
lendude#78.2 is because assertWaitForAjaxRequest is notoriously fickle, it has been the cause of many a random fail on Drupal CI. It has been shown that actually waiting for the change to appear is much more stable. So unless there is no change to detect, try never to use assertWaitForAjaxRequest. Since this is fairly straight forward I would not expect problems here, but best to be safe.
There are plenty of examples in #2829040: [meta] Known intermittent, random, and environment-specific test failures that in the fixes come down to 'replace assertWaitForAjaxRequest with other wait options'.
Edit: I realise I put the assertWaitForAjaxRequest in the test myself in #3 or something, but wisdom comes with the years (no idea if that is an english expression but it is a dutch one :) )
Comment #81
pcambraAdding #2934463: Ajax is broken in forms built within an Ajax callback as related because after submitting an ajax form exposed, the base url is lost and workaround in #2934463-11: Ajax is broken in forms built within an Ajax callback that could be useful.
Comment #82
seycom commented#77 patch works but it breaks Media Library Widget.
After clicking "Add Media" button on the node media entity reference field, AJAX view in the popup will say "No media available.".
Trying to switch between Grid/Table display will return 403 AJAX error "ID parameter is required and must be a string."
But after clicking on "Filter" button, AJAX view works fine.
Comment #83
manuel.adanFrom #77:
It doesn't work for me when the triggering element is grouped, e.g. $form['advanced']['element']['#ajax']
I think $form_state->getTriggeringElement() should return some value since the request is initiated by an Ajax triggering event, so the triggering element could be got by that way.
Comment #85
andres.torres commented+1 RTBC for #83 on Drupal 8.9.1
Thank you all!
Comment #86
johnpitcairn commentedDoesn't this need to be tested against 9.x then backported now? Retesting...
Comment #87
bdlangton commentedPatch #83 on Drupal 8.9.4 looks good to me.
Comment #88
vacho commentedPatch #83 works for me if I redraw a form element at the callback function.
First problem:
I am implementing the ajax by hook_form_alter and need to validate form_state values after ajax redraw, and with this patch, the $form_state->getValues() is always empty.
I got this works gething the value by getRequest() from view executable.
Second problem:
I works with a view that use ajax to filter. After filter the form ajax doesn't work anymore and I get this error:
page not found
Path: http://my_domain/views/ajax?_wrapper_format=drupal_ajax&ajax_form=1&category=35&nombre=&sub_category=36
Reference: http://my_domain/store
Message: /views/ajax?category=35&sub_category=36&nombre=&ajax_form=1&_wrapper_format=drupal_ajax
I got this works setting into my ajax the 'url' key. due to the view will miss this.
Comment #89
aneek commentedI have the same scenario, in views exposed form (with the help of better exposed filter) I am exposing some fields. And with a form alter I want to change a text field to select list with AJAX added to it.
In the mymodule.module file, I have these below code:
I have applied the #83 patch and it was applied correctly but still I get the MAX file size error.
Am I missing anything here?
Regards,
Aneek
Comment #90
aneek commentedComment #91
vacho commented@aneek "MAX file size error."? do you have an composer error?
If you refear to your environment memory limitation maybe this can be helpful:
Call composer without memory limitations. Take careful in prod environment. It is only for dev environment.
php -d memory_limit=-1 /usr/local/bin/composer update --lockComment #92
aneek commented@vacho - No composer has worked fine. No errors there. The problem that I am facing is, if you see the code that I posted, it doesn't call the callback rather moves to the file upload AJAX call. Please see the image in #3. That is the error it shows. Nothing to do with composer. Makes sense?
Regards,
Aneek
Comment #93
graber commentedThe max file size error is actually triggered from FormBuilder (by throwing a BrokenPostRequestException when form_id is empty in an AJAX request). It is explained in the issue description that it's how Views forms work (removing form_id), so it seems the patch doesn't work.
Comment #95
scott_euser commentedJust updating the patch to be Drupal 9.2.x compatible. Interdiff rejected because of exactly the research patch is rejected - ExposedFilterAJAXTest use statement and public static variables causing conflicts. Test view info yml updated to support core 9x. Otherwise no change.
Comment #96
nikitagupta commentedFixed the test case.
Comment #97
haihoi2 commentedI have apply the patch #96, it works in most cases. But it did not work if the view has ViewBulkOperation.
After deep diving in, I found that the form_id was changed unexpectedly with the code:
So I add unset 03 form input values
Comment #98
suresh prabhu parkala commentedRe-rolled patch. Please review.
Comment #101
beanjammin commentedThe patches for this issue and #2977785: No error messages are shown for applied validation on a view exposed filter with on "AJAX" conflict so that only one can be applied cleanly at a time. This is a re-roll of #96 so that it can be applied cleanly after #2977785-32: No error messages are shown for applied validation on a view exposed filter with on "AJAX".
*Note - Do not use this patch unless you are also using the patch from #2977785-32: No error messages are shown for applied validation on a view exposed filter with on "AJAX".
Comment #103
nsciaccaUsing the patch in #96 fixed my exposed view filter #ajax callback, however it then broke other #ajax that were on the page - specifically in the views content region on an add to cart button I had ajaxified.
Comment #104
daniel_j commented[deleted]
Comment #105
daniel_j commentedRe-rolled the patch in #101 so it applies to Drupal 9.3.0-alpha1.
Comment #106
rob230 commentedPatch #97 does not apply to 9.2. Possibly you have other patches affecting things?
I don't understand the point of Suresh's changes. No explanation given.
All the patches after it are based on also having another patch from a separate issue.
For now #96 is the only one that applies to 9.2 cleanly and works.
Comment #108
beanjammin commentedThis is a re-roll of the patch from #96 so that it applies cleanly to 9.4.x-dev.
Comment #109
beanjammin commentedComment #112
hctomWe also tried this patch and it works for our Ajax callbacks not being attached problem... unfortunately the patch has side-effects as already described in #82:
The media library widget's view opened in a modal does not work initially with this kind of solution. When the patch is applied, the
exposed_dataproperty inViewExecutable::_build()is empty during initial load, while it shouldn't because of the configured default values for exposed filters. In our case, we added a groupedPublishing statusfilter to the media library view, that should display all media items initially (with options for published or unpublished only). But as theexposed_datais empty, its defaultAnyvalue is not applied, but0is used instead, which results in only unpublished media items being visible.Attached you can find a media library views config (based on core media's default view config) with the
Publishing statusfilter added to theWidgetandWidget (table)displays for easier testing and reproducibility.As already described in #82, a click on the
Apply filtersbutton without changing any filters, restores the default filter values and the list is displayed correctly with all functionality again. It also restores the required media library values again (e.g.media_library_opener_id) that are needed to be able to switch to the table listing.Does anyone has an idea how to deal with this?
Comment #113
hctom...hide exported views config from files
Comment #114
hctomHere is a very basic quickfix for the media library problem (because we need this urgently and this was the easiest way to achieve working media library filters again). It just adds another condition when determining exposed input that checks if the trigger was a media library widget open button. I guess this is not the correct was to deal with it, but for anybody having the same trouble, this might be a solution for now. It is based on patch from #108.
As it is only a quickfix, I also hid the file from the issue files in the summary.
Comment #115
hctomHere is an updated quickfix patch that also works for nested subforms (like paragraph forms). Again based on patch from #108.
Comment #116
hctomAll things go by threes ;) The other quickfix patches still had problems after uploading a file in the media library and clicking "Save and select"... So here if (hopefully) the final quickfix patch for the media library (based on #108 again) with a completely different approach that does not check the triggering element's name, but checks for the
media_libraryview ID instead.Comment #119
lapaty commentedPatch #83 works for me on 8.9.20.
Thank you very much!!
Comment #121
ayush.khare commentedRerolled #83 for 10.1.x
Comment #122
ayush.khare commentedFixed CCF in #120
Comment #123
johnhanley commentedI just ran into the infamous "maximum file size" bug when attempting to Ajaxify a Views exposed filter form field with Drupal 9.5.3. I applaud the efforts to resolve this issue and look forward to a final solution.
Comment #124
stockticker commentedre-roll of patch #96 for 9.5.x.
Comment #126
timohuismanThis should resolve the PHPCS errors from #124. The reroll is based on #94 against 9.5.x.
Comment #127
savvas.tsarouchas@intrasoft-intl.com commentedIs #126 safe to use for Drupal 9.5.5?
Thank you for any response.
Comment #128
farse commentedI am using 9.5.8 and of the patches that could be applied none of them worked for my situation. I just have some exposed filters based on taxonomy terms (I want to update one when the other is updated) and I am still getting the "maximum file size" bug when trying I applied #96 and #108
Comment #129
tunprogRerolled #116 for 9.5.x (9.5.9)
Comment #130
savvas.tsarouchas@intrasoft-intl.com commentedI am using Drupal 9.5.5. In all of the patches (apart from the one in #108) the changes related to the ExposedFilterAJAXTest.php
cannot be applied.
Kind regards,
Savvas
Comment #131
dmezquia#129 works for 9.5.9 and 9.5.10, but it only works for a first request, from the second request/change select it doesn't work, it always shows me the same values of the first request, even with clean caches.
Comment #132
almador commentedExperiencing the same problem as in #131, the first time selection for the exposed filter worked fine (after updating the page), but the second one is not working with "
Maximum call stack size exceeded" error.Patch from #129 is applied.
Comment #133
trickfun commented#126 works on Drupal 10
Comment #134
vselivanovPatch #126 doesn't work for me with the recent Drupal 10.2.6.
We used it previously, but now we found a bug with Media Library widget.
Steps to reproduce:
1. With applied patch #126 go to the node edit page with Image field, open popup with Media Library widget.
2. In the view with existing images below the upload area go to the 2nd page (with ajax pager)
3. Select image and click Insert selected.
4. You get an Ajax error in console.
With Drupal 10.2.6 I applied the patch #116, but without tests (sorry for that).
I don't think this is the right approach because of hardcoded view id:
$this->id() !== 'media_library'But it works good for me as a hotfix.
Comment #135
solideogloria commentedThe patch #124 no longer applies for Drupal 10.3. Also, this should probably be converted to use a Merge Request, so that tests can be run.
Comment #141
solideogloria commentedI created a merge request targeting 11.x. The exception for Media Library is not included. It would be better to figure out the root cause of that issue, because a user could have their own view with that ID, and it's not a good idea to hardcode an ID to exclude it.
All future changes should be applied to the MR, instead of as a patch. The GitLab pipeline won't run for patch files.
Comment #142
solideogloria commentedThere are a couple failing tests.
Comment #143
solideogloria commentedI will now let somebody else have a look, as I have little experience with tests.
Comment #144
alshami commentedReroll to drupal 10.3
Comment #145
lawxen commentedPlease ignore this patch for core maintainer
Just a reroll of #124 for old Drupal 9.5.2 with no test code
Comment #146
solideogloria commentedRerolled. The same two tests are failing.
Comment #150
scott_euser commentedThe tests fail because if you actually reproduce the steps in the tests the ajax request called is missing the view_name and other parameters always added to other ajax requests when you submit the form or pager normally:
So for example currently the code changes make the URL like this:
/views/ajax?status=All&type=All&title=value&langcode=All&items_per_page=50&ajax_form=1&_wrapper_format=drupal_ajax
Which is missing the details in in Drupal.views.ajaxViews[views_dom_id:CURRENT-DOM-ID-HERE] which in my case looks like this for currrent dom id:
Yet if you use the normal exposed filter submit form or use the pagination, you can see the view_name, view_display_id, etc from the JSON getting added to the query strings of those ajax requests.
I don't quite know how to fix that; but I wonder if the solution also needs to extend the JS in core/modules/views/js/ajax_view.js like the pager does there, to add in the additional missing details that should get passed as part of the ajax request.
Comment #151
scott_euser commentedActually it does work as is, but the trigger must happen by clicking outside of the field, not as autocomplete. So perhaps autocomplete could be considered as a separate issue to keep the scope to this limited. Screencast of this working attached, Tests updated to match with comment.
Comment #152
scott_euser commentedTests are now passing. Ready for review.
Comment #154
smustgrave commentedRebased it and seems to be causing a javascript error.
Only code change I made was https://git.drupalcode.org/project/drupal/-/merge_requests/8527/diffs?co... for typehints in tests
Comment #155
scott_euser commentedTested it out and its a legitimate error caused by this. Steps to reproduce the test failure:
Comment #159
abarrioReroll of patch from #144 to be used on 10.3.5 version.
Comment #160
ahmad abbad commentedPatch #159 is working but I have the same issue mentioned in #155
Comment #163
codebymikey commentedThe current iteration of the patch triggered the same bug as in #3403077: media_library_opener leads to massive GET requests that break varnish etc. for AJAX based media libraries (or any view with pagination by creating an extremely long URL path as it serializes all the POST data as GET parameters).
It ends up picking up all the POST data and using them as the exposed input query string (which is what the pager uses).
I've updated the logic so that it only picks up POST data that have been explicitly configured as being exposed by the handler.
Attached two solutions, one which picks up all exposed inputs which start with the same id as the exposed filter (because some bespoke filters might have compound fields which have the same prefix, so they might be harder to pick up using the default exposed filter - however this is also a bit of an edge case), and one that should work for about 95% of all use cases.
Comment #167
codebymikey commentedComment #168
alexdoma commented@codebymikey
after your last changes i got an error
Fatal errors. The uploaded file size may have exceeded the maximum file size (100 MB) that this server supports.
Patch #159 working for me correctly
Comment #169
smustgrave commentedThere are 2 MRs both pointing to 11.x, one should be closed please.
Preferably whichever one addresses last remaining item
Thanks.
Comment #171
codebymikey commentedWhilst testing for the #155 issue, I was unable to replicate the bug on a clean install targetting that branch.
I however did run into a separate issue where following the same instructions on a clean 11.x installation, the selected media element is not actually inserted into the page. I'm not sure if a separate media UI issue should be created for it, or addressed as part of this AJAX. But the commit for it is available here if it needs to be moved out.
@alexdoma I was unable to replicate the #168 issue. I've attached a copy of the latest PR, and if you're still having issues, please provide exact instructions on how to replicate on a clean 11.x installation with just the patch applied.
Comment #172
smustgrave commentedSo believe the test coverage needs to be tweaked some. Running test-only change is still green https://git.drupalcode.org/issue/drupal-2842525/-/jobs/4098790
Comment #173
scott_euser commentedTesting this patch out in a custom form behaviour we have for a client (some exposed form alters for autocompletes), with the latest changes in the merge request, we get 400 bad request errors. I don't quite understand why. I can however see that it is due to latest versions of the merge request stripping out _triggering_element_name from the exposed input.
While I am here, going to see if I can spot anything in the tests per #172
Comment #174
scott_euser commentedOkay that did it (locally at least), just needed to target a different view to have the test coverage reproduce the error without the code change. Letting it run now in Gitlab CI
Comment #175
scott_euser commentedOkay this still needs work:
Here's how:
Setup:
$settings['extension_discovery_scan_tests'] = TRUE;enable in settings.local.php so you can enable the test module)Works now:
Doesn't work still and triggers error:
I can see why; the GET request in the working scenario is to "/admin/content?ajax_form=1&_wrapper_format=drupal_ajax", but once you e.g. use pagination it seems views ajax is changing that GET to instead target "/views/ajax?page=1&ajax_form=1&_wrapper_format=drupal_ajax".
If anyone has any tips to help understand why/help stop that from occurring, much appreciated.
Comment #176
scott_euser commentedAs far as I can tell, if we find a way for the URL that gets set in ajax.js to consistently be the route of the View itself (as it is on initial load) things should all start falling into place.
Comment #180
andreastkdf commentedThanks scott_euser for the last addition fixing the issues in custom forms behaviour and for explaining what still needs work on this issue.
Sorry for the MR above (that I now closed), please ignore (I wanted to make an MR targeting 10.4.x, but this is not needed, the diff from the active MR is applying on 10.4.x too)
Comment #182
scott_euser commentedJust confirming that I tested changes from @VladimirAus and continue to have the error described in #175
Comment #189
solideogloria commentedThere are still two MRs targeting main. One should be closed, right?
Comment #190
solideogloria commentedEither resolve the merge conflicts in 8527, or close it. MR 10296 is mergeable, but doesn't contain changes to the media_library JS.