Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
ajax system
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
12 Aug 2013 at 14:29 UTC
Updated:
3 Oct 2014 at 19:30 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #0.0
wim leersUpdated issue summary.
Comment #0.1
wim leersUpdated issue summary.
Comment #0.2
wim leersAdded steps to reproduce.
Comment #1
wim leersNote that this it not necessarily a bug in
AjaxResponse, it could also be a bug in the routing system.I don't know enough about the routing system to pinpoint it further (without learning all of the routing system).
Comment #1.0
wim leersUpdated issue summary.
Comment #2
Crell commented"A fatal error occurred" sounds like an actual error happened somewhere and it's being badly reported. That suggests an issue in the error handling system to me.
Comment #3
wim leers#2: true. To that end, #1158322: Add backtrace to all errors could be highly helpful.
Comment #4
Crell commentedI know Symfony and Silex have very good debug output in case of uncaught exceptions. Symfony also has a nice debug toolbar. We should perhaps look into both of them and see if there's code we can borrow, or at least concepts.
Comment #5
wim leers#4: that'd be AWESOME :)
Comment #6
berdirDrupal\Core\Controller\ExceptionController
The method it's looking for is "on403drupal_ajax", which is a rather weird method name :) Maybe link that to Json on that level? We do expect json, right?
That whole thing seems quite un-extendable? What would have have to do if I want to return XML, or actually, request XML and get a 403 or 404?
Comment #7
wim leersGreat analysis — thanks so much, Berdir! :)
Comment #8
damien tournoud commentedSo, how is
Drupal\Core\EventSubscriber\ViewSubscribersupposed to work? It has similar code:... but defines a
onAjax()but noondrupal_ajax(). I suppose we are not actually using the correct mimetype yet?I echo Berdir's sentiment: we are missing a proper rendering layer. Symfony Full Stack doesn't have a proper rendering layer either, but at least it can guess templates based on the format of the incoming request (as implemented in
Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener.Also, is there any reason we are not using the proper
Request::getRequestFormat()/Request::setRequestFormat()instead of hardwiring our content negotiation service everywhere?Comment #9
Crell commentedDamien: We have an open issue with no code yet to standardize on getRequestFormat() properly. You're correct that we should be.
Also, we're discussing in the WSCCI channel as we speak about how ViewSubscriber needs to die a painful death. :-) It was never intended to live this long; refactoring HtmlPageController and ViewSubscriber (which are quite muddled right now) is something I've been thinking about the past few days. ExceptionController is equally hackish. It's out of scope for this issue to rewrite, but I want to try rewriting them.
Comment #10
damien tournoud commented@Crell: Is there any specific reason why we are wiring all this in "wrapping" controllers, instead of using the
KernelEvents::VIEWevent like Symfony full stack does (and likeViewSubscribercurrently does)?Also, the default
Symfony\Component\HttpKernel\EventListener\ExceptionListenerhandles exceptions as sub-requests to a special controller, which makes a ton of sense to me too. But of course, that requires separating rendering from the controllers, and brings us back to the previous point.Comment #11
Crell commentedDamien: HtmlPageController was written with the expectation that it would get replaced by SCOTCH, but that's not happened. ViewSubscriber was written 7 months earlier with the expectation that it would get replaced as well, by SCOTCH or otherwise. Refactoring both of those so that we're using the view event properly, with a classed object, is exactly what I want to do. That's tangentially related to this issue but would likely overlap with it. (I'm waiting for the title issue to get in so that I'm not editing the exact same lines at the same time.)
Comment #11.0
Crell commentedadded related issues
Comment #12
berdirWhat's the state here? This is still a problem and makes debugging ajax requests very painfull. It's not just a problem for 404/403 but also real errors where right now, ajax actions just silently fail.
Comment #13
Crell commentedI believe #2323759: Modularize kernel exception handling will allow us to address this issue.
Comment #14
dawehnerSo
Comment #15
haydeniv commentedSo #2323759: Modularize kernel exception handling is in so active now?
Comment #16
Crell commentedCan we get a failing test here to confirm it's still an issue and wasn't fixed implicitly as part of the exception refactor? If it's still an issue we need a test anyway but that should make it much easier to fix.
Comment #17
webchickComment #18
wim leersThere you go.
(Still a fatal error.)
Comment #19
wim leersUpdated the STR in the IS.
Comment #21
dawehnerLet's see whether this works. On top of that I wonder whether we this will cause issues in ie9, see #2339491: Ajax requests on forms with files fail on IE 9
Comment #22
wim leersWoot! Can't wait to see the test results :)
Comment #23
dawehnerAt least one of the failures of the quick test ones, will be green.
Comment #25
dawehnerMeh. Not sure whether {} or [] should be the prefered way when there is no text. It seems to be that symfony decided to go with the first one, for some reason? Now this
patch uses "[]" but we could easily switch.
Comment #27
Crell commentedRemember, it's a JSON object. A bare [] isn't valid JSON. A bare {} is a valid JSON null object.
Comment #28
dawehnerMaybe now.
Comment #30
wim leersHah, it used to be
[], but I guess that's because the old AJAX system was also wrong :)Only test failures remaining in a single test! :)
Comment #31
dawehnerThere we go.
Comment #32
damiankloip commentedThis patch is looking good to me. Just one thing IMO, we should return
{"error": "Some fatal error message here"}instead of just["Some fatal error message here"]. This keeps things more consistent but also allows you to get this withresponse.errorand notresponse[0]Comment #33
Crell commentedAnd we even get to fix that thing, too. Nice!
Comment #34
wim leersHurray!
RTBC+1
Comment #35
catchCommitted/pushed to 8.0.x, thanks!