#1938980: Fix Ajax system; the last remnants of the old API must be swept away started off so simple. We just want to move some classes around for clarity, and to make it easier to extend. In the process, though, we realized there were still unresolved bugs in the Ajax system, and fixing THOSE is taking considerably more time and has a long dependency chain. Sigh.

In an effort to get things moving, this contains JUST the code-moving-around parts. The ajax resolution code is still what's in core now, which doesn't handle new-style routes, just old-style routes. We know that, it's OK, we'll fix it in the other issue, but let's get in the parts we can.

Patch as soon as I have a nid.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Crell’s picture

Status: Active » Needs review
FileSize
13.18 KB
Crell’s picture

Issue tags: +WSCCI

Forgot that...

effulgentsia’s picture

Status: Needs review » Needs work

#1 no longer applies on HEAD.

Crell’s picture

Status: Needs work » Needs review
FileSize
11.28 KB

The YAML service conversion killed it.

effulgentsia’s picture

AJAX on hook_menu() routes still fails on this, just as it did in #1938980-22: Fix Ajax system; the last remnants of the old API must be swept away. Here's a fix to our tests so that bot catches it. Will follow up here with a fix to the patch to make them pass.

effulgentsia’s picture

This fixes the failures caused by this issue. However, there are still AJAX asset delivery failures that exist in HEAD, but not previously caught by bot due to its lack of sending the header added in #5. With that header added, that bug is now being caught by bot. The fix for it is being worked on in #1941288: Regression: ajaxPageState not being updated with AjaxResponse, assets (js/css) being added twice.

effulgentsia’s picture

This just applies the code fixes in #6, but without the test fixes in #5, in case we want to not hold this issue up on #1941288: Regression: ajaxPageState not being updated with AjaxResponse, assets (js/css) being added twice.

Crell’s picture

Alex: No no no. Please don't go down the "Fix ajax path" here. That's what's blocking the other issue. The whole point here is to NOT FIX THAT, because it's irrelevant to "just moving the damned code around". This issue is just moving code around. Please don't do anything else here.

effulgentsia’s picture

RouteProcessorSubscriber in HEAD runs on all requests. #4 replaces that with enhancers that run only on new router routes. Therefore, it breaks system/ajax requests by not running AjaxEnhancer on it. #7 fixes that (see the #6 interdiff).

effulgentsia’s picture

FileSize
1.39 KB

To clarify, this is the interdiff from #4 to #7. All it does is change AjaxEnhancer to apply to legacy routes as well, to match the existing behavior in HEAD per #9.

The fails in #6 are the same as the fails in #1967036: WebTestBase::drupalGetAJAX() and WebTestBase::drupalPostAJAX() don't set the Accept header needed for content negotiation, and are a preexisting bug in HEAD, so we can punt to that issue to fix them.

The additional fails that are in #5 demonstrate that we do have adequate tests (once we fix drupalPostAjax() itself in that other issue) that would have caught #4 having a bug (including the impact to Field UI originally reported in #1938980-22: Fix Ajax system; the last remnants of the old API must be swept away that required us to rollback that initial commit). That these tests do not fail in #6 demonstrate that the fix (same one in both #6 and #7) works.

As long as Crell approves this interdiff, I think #7 can be RTBC'd.

larowlan’s picture

+1

Crell’s picture

Status: Needs review » Reviewed & tested by the community

Ahhh... #10 makes sense. Thank you for clarifying; I was about to have a heart attack. :-)

Interdiff makes sense, and may actually help unblock #1938980: Fix Ajax system; the last remnants of the old API must be swept away at least a bit. So, now RTBC for #7. Thanks, Alex!

webchick’s picture

Status: Reviewed & tested by the community » Needs work

No longer applies. :(

But Alex just walked me through it and I'm comfortable committing when it's ready. Seems good to separate these out into pluggable route enhancers rather than a huge gunky bunch of ifs/elses.

One thing I'd be curious to know is if we can un-comment the test at this point now that we've added the missing reference to legacy blah blah thing.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
12.48 KB
12.46 KB

It only conflicted because #1847768: Remove ip_address() added reverse_proxy_subscriber right where this patch was moving stuff around, no actual conflicts.

Trying with an without that test commented out.

effulgentsia’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/lib/Drupal/Core/Routing/Enhancer/AjaxEnhancer.php
@@ -0,0 +1,43 @@
+    if (empty($defaults['_content']) && $this->negotiation->getContentType($request) == 'drupal_ajax') {

The reason the uncommented test fails is that the above is checking that _content is empty instead of _controller being empty. The other enhancers check for empty _controller, which makes more sense, because the idea is that you want to apply a default _controller when there isn't one already. However, the above line is the same as what is already in the RouteProcessorSubscriber being removed, and this issue is only about moving that code, not fixing it. #1938980: Fix Ajax system; the last remnants of the old API must be swept away is the issue in which that line can be fixed, once we fix our other HEAD problems involving competing AJAX systems and simpletest testing the wrong one.

So, RTBC for the green patch in #14.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Some minor nits... would love to unblock this to get stuff moving...

+++ b/core/lib/Drupal/Core/Routing/Enhancer/AjaxEnhancer.phpundefined
@@ -0,0 +1,43 @@
+  /**
+   * Constructs a new \Drupal\Core\Routing\Enhancer\AjaxEnhancer object.
+   */

Missing param...

+++ b/core/lib/Drupal/Core/Routing/Enhancer/AjaxEnhancer.phpundefined
@@ -0,0 +1,43 @@
+   * Implements \Symfony\Cmf\Component\Routing\Enhancer\RouteEnhancerInterface::enhance()

+++ b/core/lib/Drupal/Core/Routing/Enhancer/FormEnhancer.phpundefined
@@ -0,0 +1,43 @@
+   * Implements \Symfony\Cmf\Component\Routing\Enhancer\RouteEnhancerInterface::enhance()

+++ b/core/lib/Drupal/Core/Routing/Enhancer/PageEnhancer.phpundefined
@@ -0,0 +1,43 @@
+   * Implements \Symfony\Cmf\Component\Routing\Enhancer\RouteEnhancerInterface::enhance()

@inheritdoc

+++ b/core/lib/Drupal/Core/Routing/Enhancer/FormEnhancer.phpundefined
@@ -0,0 +1,43 @@
+  /**
+   * Constructs a new \Drupal\Core\Routing\Enhancer\FormEnhancer object.
+   */

Missing param

+++ b/core/lib/Drupal/Core/Routing/Enhancer/PageEnhancer.phpundefined
@@ -0,0 +1,43 @@
+  /**
+   * Constructs a new \Drupal\Core\Routing\Enhancer\PageEnhancer object.
+   */

Missing param

+++ b/core/modules/system/tests/modules/router_test/lib/Drupal/router_test/TestContent.phpundefined
@@ -0,0 +1,19 @@
+  public function test1() {
+    return 'abcde';
+  }

Missing doc block

larowlan’s picture

Status: Needs work » Needs review
FileSize
3.41 KB
12.65 KB

As promised on IRC

Crell’s picture

Status: Needs review » Reviewed & tested by the community

Unless testbot says no... (which it shouldn't, as this is all comment changes)

alexpott’s picture

Title: Move controller derivation to route enhancers (and just that) » Change notice: Move controller derivation to route enhancers (and just that)
Priority: Normal » Critical
Status: Reviewed & tested by the community » Active
Issue tags: +Needs change record

Committed 99b39dc and pushed to 8.x. Thanks!

larowlan’s picture

Status: Active » Needs review

Change notice for review is here: https://drupal.org/node/2012100

Crell’s picture

Title: Change notice: Move controller derivation to route enhancers (and just that) » Move controller derivation to route enhancers (and just that)
Priority: Critical » Normal
Status: Needs review » Fixed

yay!

Status: Fixed » Closed (fixed)

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

xjm’s picture

Issue tags: -Needs change record

Untagging. Please remove the tag when the change notification task is completed.