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?
Files: 
CommentFileSizeAuthor
#37 ajax_entity_routes-1983164-37.patch10.75 KBdawehner
PASSED: [[SimpleTest]]: [MySQL] 55,317 pass(es).
[ View ]
#37 interdiff.txt611 bytesdawehner
#33 entity-form-routes-1983164.33.interdiff.txt1.81 KBlarowlan
#33 entity-form-routes-1983164.33.patch10.75 KBlarowlan
PASSED: [[SimpleTest]]: [MySQL] 55,414 pass(es).
[ View ]
#30 Screen Shot 2013-06-03 at 8.44.57 AM.png21.77 KBlarowlan
#30 Screen Shot 2013-06-03 at 8.46.17 AM.png23.92 KBlarowlan
#29 drupal-1983164-29.patch10.78 KBdawehner
PASSED: [[SimpleTest]]: [MySQL] 56,033 pass(es).
[ View ]
#29 interdiff.txt805 bytesdawehner
#27 drupal-1983164-26.patch9.99 KBdawehner
FAILED: [[SimpleTest]]: [MySQL] 55,972 pass(es), 0 fail(s), and 1 exception(s).
[ View ]
#27 interdiff.txt1.12 KBdawehner
#25 drupal-1983164-25.patch9.41 KBdawehner
FAILED: [[SimpleTest]]: [MySQL] Repository checkout: failed to checkout from [git://git.drupal.org/project/drupal.git].
[ View ]
#25 interdiff.txt554 bytesdawehner
#24 Screen Shot 2013-05-29 at 6.17.12 PM.png16.24 KBlarowlan
#24 Screen Shot 2013-05-29 at 6.18.09 PM.png13.14 KBlarowlan
#23 drupal-1983164-23.patch8.87 KBdawehner
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch drupal-1983164-23.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#23 interdiff.txt744 bytesdawehner
#21 drupal-1983164-21.patch8.77 KBdawehner
FAILED: [[SimpleTest]]: [MySQL] Repository checkout: failed to checkout from [git://git.drupal.org/project/drupal.git].
[ View ]
#21 interdiff.txt1.64 KBdawehner
#18 drupal-1983164-18.patch8.04 KBdawehner
FAILED: [[SimpleTest]]: [MySQL] Repository checkout: failed to checkout from [git://git.drupal.org/project/drupal.git].
[ View ]
#18 interdiff.txt4.64 KBdawehner
#17 drupal-1983164-17.patch11.94 KBdawehner
FAILED: [[SimpleTest]]: [MySQL] Failed to run tests: failed during invocation of run-tests.sh.
[ View ]
#15 drupal-1983164-15.patch12.86 KBdawehner
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in core/tests/Drupal/Tests/Core/Controller/TestKernelRequestEventSubscriber.php.
[ View ]
#15 interdiff.txt8.85 KBdawehner
#13 drupal-1983164-13.patch3.92 KBdawehner
FAILED: [[SimpleTest]]: [MySQL] Repository checkout: failed to checkout from [git://git.drupal.org/project/drupal.git].
[ View ]
#12 new-start.patch1.86 KBdawehner
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch new-start.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#9 drupal-1983164-test.patch9.03 KBdawehner
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch drupal-1983164-test.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#4 drupal-1983164-4.patch871 bytesdawehner
FAILED: [[SimpleTest]]: [MySQL] 55,660 pass(es), 1 fail(s), and 2 exception(s).
[ View ]
#1 drupal-1983164-1.patch1.43 KBdawehner
PASSED: [[SimpleTest]]: [MySQL] 55,399 pass(es).
[ View ]
#1 deeper.png34.77 KBdawehner

Comments

dawehner’s picture

Status:Active» Needs work
StatusFileSize
new34.77 KB
new1.43 KB
PASSED: [[SimpleTest]]: [MySQL] 55,399 pass(es).
[ View ]

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
StatusFileSize
new871 bytes
FAILED: [[SimpleTest]]: [MySQL] 55,660 pass(es), 1 fail(s), and 2 exception(s).
[ View ]

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

StatusFileSize
new9.03 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch drupal-1983164-test.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

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

StatusFileSize
new1.86 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch new-start.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

This is a start to implement subrequest handling.

dawehner’s picture

StatusFileSize
new3.92 KB
FAILED: [[SimpleTest]]: [MySQL] Repository checkout: failed to checkout from [git://git.drupal.org/project/drupal.git].
[ View ]

There we go.

I will work on proper tests now.

dawehner’s picture

Status:Needs work» Needs review

.

dawehner’s picture

StatusFileSize
new8.85 KB
new12.86 KB
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in core/tests/Drupal/Tests/Core/Controller/TestKernelRequestEventSubscriber.php.
[ View ]

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
StatusFileSize
new11.94 KB
FAILED: [[SimpleTest]]: [MySQL] Failed to run tests: failed during invocation of run-tests.sh.
[ View ]

Oh right this testfile is not needed anymore.

dawehner’s picture

StatusFileSize
new4.64 KB
new8.04 KB
FAILED: [[SimpleTest]]: [MySQL] Repository checkout: failed to checkout from [git://git.drupal.org/project/drupal.git].
[ View ]

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

StatusFileSize
new1.64 KB
new8.77 KB
FAILED: [[SimpleTest]]: [MySQL] Repository checkout: failed to checkout from [git://git.drupal.org/project/drupal.git].
[ View ]

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

StatusFileSize
new744 bytes
new8.87 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch drupal-1983164-23.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Updated the patch.

larowlan’s picture

Status:Needs review» Needs work
StatusFileSize
new13.14 KB
new16.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.pngScreen Shot 2013-05-29 at 6.18.09 PM.png

dawehner’s picture

Status:Needs work» Needs review
StatusFileSize
new554 bytes
new9.41 KB
FAILED: [[SimpleTest]]: [MySQL] Repository checkout: failed to checkout from [git://git.drupal.org/project/drupal.git].
[ View ]

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
StatusFileSize
new1.12 KB
new9.99 KB
FAILED: [[SimpleTest]]: [MySQL] 55,972 pass(es), 0 fail(s), and 1 exception(s).
[ View ]

Status:Needs review» Needs work

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

dawehner’s picture

Status:Needs work» Needs review
StatusFileSize
new805 bytes
new10.78 KB
PASSED: [[SimpleTest]]: [MySQL] 56,033 pass(es).
[ View ]

Let's fix the exception.

larowlan’s picture

Status:Needs review» Reviewed & tested by the community
StatusFileSize
new23.92 KB
new21.77 KB

Works as expected™
Screen Shot 2013-06-03 at 8.44.57 AM.pngScreen 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

Assigned:larowlan» Unassigned
StatusFileSize
new10.75 KB
PASSED: [[SimpleTest]]: [MySQL] 55,414 pass(es).
[ View ]
new1.81 KB

Fixes #31

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

#33: entity-form-routes-1983164.33.patch queued for re-testing.

dawehner’s picture

StatusFileSize
new611 bytes
new10.75 KB
PASSED: [[SimpleTest]]: [MySQL] 55,317 pass(es).
[ View ]

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

#37: ajax_entity_routes-1983164-37.patch queued for re-testing.

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.