If you look at the views UI preview you get like

An AJAX HTTP error occurred.
HTTP Result Code: 404
Debugging information follows.
Path: /d8/admin/structure/views/view/content/preview/page_1
StatusText: Not Found
ResponseText: A fatal error occurred: Unable to find the controller for path "/admin/structure/views/view/content/preview/page_1". Maybe you forgot to add the matching route in your routing configuration?
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Needs work
FileSize
34.77 KB
1.43 KB

There seems to be the central problem, that RouteListener does the following:

    {
        $request = $event->getRequest();

        // initialize the context that is also used by the generator (assuming matcher and generator share the same context instance)
        $this->context->fromRequest($request);

        if ($request->attributes->has('_controller')) {
            // routing is already done
            return;
        }

but on the AjaxController subrequest controller is set to NULL, by HttpKernel::forward().

That's certainly not enough to fix the bug, but applying the bug is fun, see screenshot :)

deeper.png

dawehner’s picture

Before the patch in #1913618: Convert EntityFormControllerInterface to extend FormInterface ViewsUIController took care about returning the preview as ajax. Now HtmlFormController::content() returns the full rendered page including the form.

tim.plunkett’s picture

Can we test this in any way? :\

dawehner’s picture

Status: Needs work » Needs review
FileSize
871 bytes

What about something like this?

Status: Needs review » Needs work

The last submitted patch, drupal-1983164-4.patch, failed testing.

tim.plunkett’s picture

Issue tags: +Stalking Crell

Awesome, we have a test!

clemens.tolboom’s picture

According to discussion https://github.com/symfony/symfony/issues/4360 SubRequest is always a get request. But preview is a Post request. Does that somehow match the recursion art from #1
(my 2cents and subscribing)

dawehner’s picture

One initial additional idea has been to use another route enhancer to enhance based upon the content type, similar to the way DialogEnhancer and ModalEnhancer work together. This though is not really a good model, just because there are multiple controllers for different kind of forms: normal forms, entity forms etc.

We should really start thinking about a proper system to allow all this but to be honest the change in #1913618: Convert EntityFormControllerInterface to extend FormInterface feels wrong.

dawehner’s picture

FileSize
9.03 KB

This has been my previous attemps, but yeah this doesn't work as described.

I personally think that there shouldn't be an html form controller but just a html page controller, which takes the output of the form controller.

clemens.tolboom’s picture

+++ b/core/lib/Drupal/Core/AjaxFormController.php
@@ -0,0 +1,23 @@
+    return new Respnse($form);

Should be Response and it should be USE-ed
(just to let know I read it)

Why isn't the whole form replaced by the response of the preview?
And shouldn't auto-preview be stunned after the result?
(questions from a Router rookie)

dcam’s picture

http://drupal.org/node/1427826 contains instructions for updating the issue summary with the summary template.

The summary may need to be updated with information from comments.

dawehner’s picture

FileSize
1.86 KB

This is a start to implement subrequest handling.

dawehner’s picture

FileSize
3.92 KB

There we go.

I will work on proper tests now.

dawehner’s picture

Status: Needs work » Needs review

.

dawehner’s picture

FileSize
8.85 KB
12.86 KB

Added a unit test for HttpKernel.

Status: Needs review » Needs work

The last submitted patch, drupal-1983164-15.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
11.94 KB

Oh right this testfile is not needed anymore.

dawehner’s picture

FileSize
4.64 KB
8.04 KB

Let's make the changes in HttpKernel as small as possible.

tim.plunkett’s picture

+++ b/core/lib/Drupal/Core/Controller/HtmlFormController.phpundefined
@@ -64,7 +64,7 @@ public function content(Request $request, $_form) {
     $form = drupal_build_form($form_id, $form_state);
-    return new Response(drupal_render_page($form));
+    return $form;

If you need another reroll, might as well return drupal_build_form($form_id, $form_state)

This looks good to me, but I'd like to have Crell or larowlan RTBC.

larowlan’s picture

+++ b/core/lib/Drupal/Core/HttpKernel.phpundefined
@@ -240,4 +239,30 @@ public function hasEsiSupport()
+   * @param string $controller

string|NULL passing NULL means the sub-request has the enhancers etc run again - we should note this

dawehner’s picture

FileSize
1.64 KB
8.77 KB

Let's do it.

Pushed to 1983164-ajax-subrequest

larowlan’s picture

+++ b/core/lib/Drupal/Core/Controller/AjaxController.phpundefined
@@ -48,6 +48,8 @@ public function content(Request $request, $_content) {
+    // @todo Explain why this is needed.

This is needed because without it this chunk in Drupal\Core\ContentNegotiation leads us to believe that its still an ajax request, even in the sub-request.

if ($request->isXmlHttpRequest()) {
      return 'ajax';
    }

the isXmlHttpRequest() method checks the x-requested-with header. Can we update the comment?

Other than that this looks RTBC to me too and unblocks #1998698: Allow Dialog Controller to work with form/entity form routes

dawehner’s picture

FileSize
744 bytes
8.87 KB

Updated the patch.

larowlan’s picture

Status: Needs review » Needs work
FileSize
13.14 KB
16.24 KB

Installs fine but doesn't fix the original issue.
Perhaps missing a call to drupal_render - we're seeing Array instead of the output?

Screen Shot 2013-05-29 at 6.17.12 PM.png

Screen Shot 2013-05-29 at 6.18.09 PM.png

dawehner’s picture

Status: Needs work » Needs review
FileSize
554 bytes
9.41 KB

Let's fixes at least one problem.

Status: Needs review » Needs work

The last submitted patch, drupal-1983164-25.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
1.12 KB
9.99 KB

Status: Needs review » Needs work

The last submitted patch, drupal-1983164-26.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
805 bytes
10.78 KB

Let's fix the exception.

larowlan’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
23.92 KB
21.77 KB

Works as expected™
Screen Shot 2013-06-03 at 8.44.57 AM.png

Screen Shot 2013-06-03 at 8.46.17 AM.png

damiankloip’s picture

Overall, you are a HERO. Also just tested and can happily confirm I have my preview back!

Couple of small things, sorry....

+++ b/core/lib/Drupal/Core/HttpKernel.phpundefined
@@ -240,4 +243,30 @@ public function hasEsiSupport()
+   * Setup the request object for a subrequest.

'Sets up the' or 'Creates a'

+++ b/core/lib/Drupal/Core/HttpKernel.phpundefined
@@ -240,4 +243,30 @@ public function hasEsiSupport()
+    // Don't override the controller if it's null.

NULL? Not sure.

+++ b/core/lib/Drupal/Core/HttpKernel.phpundefined
@@ -240,4 +243,30 @@ public function hasEsiSupport()
+    $subrequest = $this->container->get('request')->duplicate($query, NULL, $attributes);
+    return $subrequest;

Can't we just return the result here directly instead of assigning?

+++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.phpundefined
@@ -65,4 +65,18 @@ function testPreviewUI() {
+    // Build a list of the result commands keyed by the js commando.

Who is the js commando? :)

larowlan’s picture

Assigned: Unassigned » larowlan

re-rolling

larowlan’s picture

andypost’s picture

+++ b/core/modules/views_ui/views_ui.theme.incundefined
@@ -461,5 +461,5 @@ function template_preprocess_views_ui_view_preview_section(&$vars) {
-  . '<div class="preview-section">'. $vars['content'] . '</div>';
+  . '<div class="preview-section">'. render($vars['content']) . '</div>';

why not drupal_render() here? is it possible to be empty?

Status: Reviewed & tested by the community » Needs work
Issue tags: -Needs issue summary update, -WSCCI, -VDC, -Stalking Crell

The last submitted patch, entity-form-routes-1983164.33.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
Issue tags: +Needs issue summary update, +WSCCI, +VDC, +Stalking Crell
dawehner’s picture

I don't care.

larowlan’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work
Issue tags: -Needs issue summary update, -WSCCI, -VDC, -Stalking Crell

The last submitted patch, ajax_entity_routes-1983164-37.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
Issue tags: +Needs issue summary update, +WSCCI, +VDC, +Stalking Crell
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

So back to RTBC

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 7166d89 and pushed to 8.x. Thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.