Support from Acquia helps fund testing for Drupal Acquia logo

Comments

larowlan’s picture

Status: Active » Needs review
FileSize
8.19 KB

Needs tests still but this works for _form

andypost’s picture

+++ b/core/lib/Drupal/Core/ContentNegotiation.phpundefined
@@ -40,6 +40,7 @@ public function getContentType(Request $request) {
+      error_log($mime_type);

debug?

Status: Needs review » Needs work

The last submitted patch, dialog-form.1.patch, failed testing.

jibran’s picture

Form #1842036-66: [META] Convert all confirm forms to use modal dialog while working on the issue I think we should improve DX experience for simple links and buttons. @quicksketch has added some improvements in #1879120-57: Use Drupal-specific image and link plugins — use core dialogs rather than CKEditor dialogs, containing alterable Drupal forms related to ckeditor.

dawehner’s picture

+++ b/core/lib/Drupal/Core/Controller/DialogController.phpundefined
@@ -54,12 +64,34 @@ protected function forward(Request $request, $content) {
+    $request->headers->remove('Accept');
+    // Remove the X-Requested-With header so the subrequest is not mistaken for
+    // an ajax request.
+    $request->headers->remove('X-Requested-With');
+
+    // Re-enhance the routes with the help of the dynamic router.
+    $defaults = $attributes->all();
+    unset($defaults['_controller']);
+    // Create a duplicate request for forwarding and enhancing. We can't use the
+    // existing request as the protected acceptableContentTypes property has
+    // been set already at this stage and cannot be flushed.
+    $sub_request = $request->duplicate($request->query->all(), NULL, $defaults);
+    foreach ($this->dynamicRouter->getRouteEnhancers() as $enhancer) {
+      // Allow enhancers to run-again, other than the ParamConverterManager
+      // which we exclude because of a) they cannot be run again and b) it would
+      // be poor performance to do so.
+      if (get_class($enhancer) !== 'Drupal\\Core\\ParamConverter\\ParamConverterManager') {
+        $defaults = $enhancer->enhance($defaults, $sub_request);
+      }
+    }
 
-    return $this->httpKernel->forward($content, $attributes->all(), $request->query->all());
+    // Set the controller on the sub-request based on the enhancers.
+    $sub_request->attributes->set('_controller', $defaults['_controller']);
+    return $this->httpKernel->handle($sub_request, HttpKernelInterface::SUB_REQUEST);
   }

Can't we avoid to duplicate the functionality of both ControllerResolver and Httpkernel here? Why not just use HttpKernel->forward and change the request headers first?

larowlan’s picture

Status: Needs work » Needs review
FileSize
13.41 KB
110.55 KB

First patch includes #1983164: Entity Forms in ajax requests don't find the route
Please review the -do-not-test.patch one.

Status: Needs review » Needs work

The last submitted patch, dialog-form-1998698.5.includes-1983164.patch, failed testing.

larowlan’s picture

Status: Needs work » Needs review
FileSize
13.41 KB
22.27 KB

damn last patch is wrong, origin out of date
Please review the do-not-test file

The last submitted patch, dialog-form-1998698.6.includes-1983164.patch, failed testing.

larowlan’s picture

Status: Needs work » Needs review
Issue tags: +Needs tests
quicksketch’s picture

Hm, is testbot stuck on this patch? Seems like it's been testing for the past day with no result.

+    $form['description'] = array(
+      '#markup' => '<p>' . t("Look out kid, it's somethin' you did, god knows when but you're doin' it again.") . '</p>',
+    );

Even though this is A) a test that few will ever see and B) a reference to a Bob Dylan song, I think it'd be safer of us to avoid any controversy by replacing this with a more generic message (bunnies and unicorns apparently widely accepted).

Status: Needs review » Needs work

The last submitted patch, dialog-form-1998698.6.includes-1983164.patch, failed testing.

larowlan’s picture

Status: Needs work » Postponed
jibran’s picture

Status: Postponed » Needs work

Wait is over :).

larowlan’s picture

Status: Needs work » Needs review
FileSize
13.77 KB

Re-rolled now that #1983164: Entity Forms in ajax requests don't find the route is in.
Passes dialog tests locally.

jibran’s picture

Issue tags: -Needs tests
FileSize
3.08 KB
13.26 KB

Uploading #8 do not test patch with suggestion in #11.
All above fails passes locally.

Status: Needs review » Needs work

The last submitted patch, 1998698-15.patch, failed testing.

jibran’s picture

This passes locally.

quicksketch’s picture

This passes locally.

This is because the test assumes too much. It shouldn't assume either clean URLs or being installed at the root level of the host domain. Since testbot's root directory is /checkout/, not /, the test doesn't pass with action="/ajax-test/dialog" being hard-coded.

quicksketch’s picture

Status: Needs work » Needs review
FileSize
12.91 KB
3.18 KB

Same patch, but uses xpath instead of assertRaw against the HTML strings. This approach should make the tests less sensitive to breakage in the future, since they only check for a form with a certain ID being present, rather than exact HTML strings.

larowlan’s picture

Thanks @quicksketch, perhaps we can ping Wim for a review

Status: Needs review » Needs work

The last submitted patch, dialog_routes-1998698-20.patch, failed testing.

quicksketch’s picture

Status: Needs work » Needs review

#20: dialog_routes-1998698-20.patch queued for re-testing.

larowlan’s picture

this is +1 RTBC from me, but I'm too invested to mark it myself.

quicksketch’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @larowlan. I think I'm probably qualified to mark RTBC, having only fixed tests.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
          // Generate a target based on the controller.
          $target = '#drupal-dialog-' . drupal_html_id(drupal_clean_css_identifier(drupal_strtolower($_content)));

DialogController::dialog() is still using the $_content variable which now does not exist...

+++ b/core/lib/Drupal/Core/Controller/DialogController.phpundefined
@@ -82,20 +83,18 @@ public function modal(Request $request, $_content) {
-      //  http://drupal.org/node/1871596 is in.
+      //   http://drupal.org/node/1871596 is in.

Unnecessary change

jibran’s picture

Status: Needs work » Needs review
FileSize
1.14 KB
12.96 KB

I don't know how to replace

        // Generate a target based on the controller.
          $target = '#drupal-dialog-' . drupal_html_id(drupal_clean_css_identifier(drupal_strtolower($_content)));

.
I hope interdiff is fine.

Status: Needs review » Needs work

The last submitted patch, dialog_routes-1998698-27.patch, failed testing.

jibran’s picture

Status: Needs work » Needs review

#27: dialog_routes-1998698-27.patch queued for re-testing.

larowlan’s picture

This
a) Uses the route name to derive a dialog target for a non-modal when none is given.
b) Adds tests for said change (which would have found the regression identified at #26 if we'd had them)

quicksketch’s picture

Thanks @larowlan I tried rerolling this today but couldn't figure out for the life of me how to acquire the right variable there.

One minor nitpick is we're not using drupal_html_id() properly here:

+          $target = '#drupal-dialog-' . drupal_html_id(drupal_clean_css_identifier(drupal_strtolower($route_name)));

drupal_html_id() should be around the whole ID:

+          $target = '#' . drupal_html_id('drupal-dialog-' . drupal_clean_css_identifier(drupal_strtolower($route_name)));

Otherwise you may end up with $route_name matching some other ID already on the page just by mere coincidence, which results in "--2" being appended to the ID.

jibran’s picture

FileSize
805 bytes
15.69 KB

Let's do this instead $target = '#' . drupal_html_id("drupal-dialog-$route_name");

Thanks @larowlan I tried rerolling this today but couldn't figure out for the life of me how to acquire the right variable there.

So I was not alone :D

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

The feedback from alex got adressed so back to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed f7f7f37 and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

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