Problem/Motivation

In #1812866: Rebuild the server side AJAX API a new Object-Oriented AJAX API for D8 was introduced. The existing D7 Ajax API was left in place while usage was converted from the old to the new. It's time to remove the D7 Ajax code from Drupal.

Proposed resolution

Remove most of the contents of ajax.inc. Rewrite / remove any remaining usages of ajax_command_*, ajax_render, or any other Ajax functions removed from ajax.inc.

Remaining tasks

#1812866: Rebuild the server side AJAX API
#1938980: Fix Ajax system; the last remnants of the old API must be swept away
#1957590: Remove remaining procedural ajax command usages.
#1843220: Convert form AJAX to new AJAX API

Open Questions:

1) Most of what is left in ajax.inc is related to forms. Does it make sense to rip it out and stick it in form.inc so we can get rid of ajax.inc entirely?

Answer: Most (~30%) is solving "#ajax" on forms, but let's keep it for now in there to reduce the patch size.

2) There's a massive block of documentation at the top of ajax.inc that needs updating. If we get rid of ajax.inc, where does this go?

Much of it deals with #ajax as well, but indeed this also covers the old way of dealing with it. The most recent version adapts the documentation
to the already ~ 1 year old new standard.

3) The old ajax.inc had defgroup docs for all of the ajax commands, which was nice...is there something comparable for all of the different ajax command classes?

Well, we do have CommandInterface, which makes it quite easy to find them.

Comments

mkadin’s picture

Status: Active » Needs review
StatusFileSize
new41.37 KB

Status: Needs review » Needs work

The last submitted patch, drupal_remove_old_ajax_1959574.patch, failed testing.

mkadin’s picture

Status: Needs work » Needs review
StatusFileSize
new41.75 KB
new697 bytes

Needed the new MIME type on drupalPostAjax

Status: Needs review » Needs work

The last submitted patch, drupal_remove_old_ajax_1959574_3.patch, failed testing.

andypost’s picture

Status: Needs work » Closed (duplicate)
mkadin’s picture

Status: Closed (duplicate) » Postponed
StatusFileSize
new47.32 KB

The scope of this work is beyond #1957590: Remove remaining procedural ajax command usages., so I'm posting the patch from work there here again, and postponing it on that issue.

effulgentsia’s picture

Status: Postponed » Needs review

Status: Needs review » Needs work

The last submitted patch, drupal_remove_old_ajax_1957590_14.patch, failed testing.

mkadin’s picture

StatusFileSize
new23.83 KB

Rerolled this patch after #1957590: Remove remaining procedural ajax command usages.. Likely to fail but need to know which tests to work on.

mkadin’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, drupal_remove_ajax_1959574_9.patch, failed testing.

mkadin’s picture

Status: Needs work » Needs review
StatusFileSize
new25.31 KB

Should be down to 2 fails now, can't for the life of me figure out what's up with these. They work fine in the browser.

I think I've seen another issue struggling with this same problem but can't find it.

Status: Needs review » Needs work

The last submitted patch, drupal_remove_ajax_1959574_12.patch, failed testing.

effulgentsia’s picture

This could use a reroll for #1967036: WebTestBase::drupalGetAJAX() and WebTestBase::drupalPostAJAX() don't set the Accept header needed for content negotiation and other HEAD changes. Good news is, since that issue landed, once rerolled, it should pass.

mkadin’s picture

Status: Needs work » Needs review
StatusFileSize
new19.03 KB

Giving a stripped down version of this patch another shot. Need to see where the tests are at.

Crell’s picture

Status: Needs review » Reviewed & tested by the community

4 files changed, 24 insertions, 430 deletions.

Pretty. :-)

dawehner’s picture

Status: Reviewed & tested by the community » Needs work

Just noting that in core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php ajax_render still exists.

Crell’s picture

Actually... Shouldn't this also fix AjaxEnhancer, which was doing things the old backward way? (Bad Crell for RTBCing without thinking about that.)

wim leers’s picture

Indeed, I'm afraid this is not even close to RTBC…


In ViewSubscriber, the old AJAX system stuff is being called in two methods (not one as you would expect):

  1. onAjax (as expected; should be safely deletable)
  2. onIframeUpload (rather unexpected, to me at least)

The latter could turn out to be kinda tricky. I'd love to remove it, but that might be impossible, it's necessary for #1009382: Several popular browser extensions corrupt AJAX responses, causing errors (for dealing with crappy browser add-ons/extensions, which I think we should not do at all) and http://malsup.com/jquery/form/#file-upload (for dealing with browsers that don't support XHR level 2). The latter is less relevant now, though it still appears to be necessary for IE 9 and Opera Mini: http://caniuse.com/xhr2.

Figuring out how to deal with that seems to be rather tricky and will require manual testing in many browsers. It must be done as part of this issue too — even though it is unrelated at the surface, because it currently depends on the D7 AJAX API, which is precisely what we want to remove in this issue.


Finally: it'd be nice if you'd like to this rather critical follow-up issue from the main issue next time — I did that just now: #1812866-88: Rebuild the server side AJAX API. How else are followers of that issue supposed to find this one?

wim leers’s picture

The current issue summary is not linking to the original issue, nor explaining why this was not done in the original issue (i.e. converting existing calling code to the new D8 Ajax API), nor explaining tricky edge cases like the one I laid out. An updated issue summary would be very helpful for other reviewers.

wim leers’s picture

Issue summary: View changes

Updated issue summary.

mkadin’s picture

Apologies for not posting this as a follow up issue to the earlier Ajax issues. I'm really a casual core contributor; I'm not super familiar with the process, so take it easy on me.

I've updated the issue summary. @Crell (or anyone else), can you clarify what necessary fixes you're talking about with respect to #19? I've tried to figure out what you mean from other issues, but have been unsuccessful...

wim leers’s picture

#22: No problem! :) Hope I didn't sound too harsh.

Thanks for the issue summary update! Are the open questions in the issue summary really still open questions though?

And indeed, the AjaxEnhancer stuff in #19 needs input/guidance from people familiar with those matters, that's relatively deep stuff that only few people are familiar with.

tim.plunkett’s picture

Issue tags: +Kill includes

.

Crell’s picture

mkadin, are you still interested in this? We really do need to finish it. :-)

mkadin’s picture

I'd love to, but you might need to find another taker to finish this up, I don't have any time for core stuff right now :(

wim leers’s picture

wim leers’s picture

Issue tags: +WSCCI

Seems appropriate, considering #1812866: Rebuild the server side AJAX API was also tagged WSCCI.

catch’s picture

Priority: Normal » Critical
webchick’s picture

Issue tags: +Approved API change

#29 implies this.

jessebeach’s picture

StatusFileSize
new19.14 KB
new19.14 KB

This is just a straight reroll of #16, which bitrotted.

I'm going to see how much farther I can take this.

jessebeach’s picture

Status: Needs work » Needs review
StatusFileSize
new832 bytes
new19.95 KB

Just setting to needs review to have tests run. I expect them to fail.

I've uncommented this test in the latest patch. It would seem that this test must pass in order for this issue to be considered resolved.

/**
 * Checks that an ajax request gets rendered as an Ajax response, by mime.
 *
 * @todo This test will not work until the Ajax enhancer is corrected. However,
 *   that is dependent on fixes to the Ajax system. Re-enable this test once
 *   http://drupal.org/node/1938980 is fixed.
 */
public function testControllerResolutionAjax() {
  // This will fail with a JSON parse error if the request is not routed to
  // The correct controller.
  $this->drupalGetAJAX('/router_test/test10');

  $this->assertEqual($this->drupalGetHeader('Content-Type'), 'application/json', 'Correct mime content type was returned');

  $this->assertRaw('abcde', 'Correct body was found.');
}

I am not the right person to look into this issue it turns out. This is too far down into kernel for me.

Status: Needs review » Needs work
Issue tags: -WSCCI, -Approved API change, -Kill includes

The last submitted patch, remove-d7-ajax-api-1959574-32.patch, failed testing.

Anonymous’s picture

Issue summary: View changes

Updated issue summary.

Crell’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 32: remove-d7-ajax-api-1959574-32.patch, failed testing.

dawehner’s picture

To be honest this feels like an issue which should be fixed after the htmlpage issue.

Crell’s picture

Issue summary: View changes
Status: Needs work » Postponed
Related issues: +#2068471: Normalize Controller/View-listener behavior with a Page object

I think you're right. They'd likely conflict and just make rolling harder.

wim leers’s picture

Status: Postponed » Active
wim leers’s picture

Title: Remove the D7 Ajax API from core. » Remove the deprecated Drupal 7 Ajax API
Status: Active » Needs review
StatusFileSize
new20.15 KB

Straight reroll of #32. Let's see what fails.

dawehner’s picture

Issue tags: +WSCCI
StatusFileSize
new29.18 KB

In order to use the logic of AjaxController in the view subscriber as well I introduced the ajax response renderer, similar to the HtmlPageRenderer
and in the future the HtmlFragmentRenderer.

@wim
I started independent from your rerole, though most of the code should be identical.

wim leers’s picture

#40: you know this area of Drupal so much better, so *thank you*! :)

wim leers’s picture

I double-checked, and #40 indeed is a superset of #39. So ignore #39, #40 is the best one!

The last submitted patch, 39: remove-d7-ajax-api-1959574-39.patch, failed testing.

mkadin’s picture

I'm not following core dev close enough to participate in this work anymore, but just wanted to say thanks for carrying this forward folks.

twistor’s picture

  1. +++ b/core/lib/Drupal/Core/Ajax/AjaxResponseRenderer.php
    @@ -0,0 +1,76 @@
    +use Drupal\Core\Page\HtmlFragment;
    ...
    +namespace Drupal\Core\Ajax;
    

    Missing newline.

  2. +++ b/core/lib/Drupal/Core/Ajax/AjaxResponseRenderer.php
    @@ -0,0 +1,76 @@
    +   *   The result of a controller, so for example a string or a render array.
    

    Unneeded 'so.' What about HtmlFragment, Response, and AjaxResponse?

  3. +++ b/core/lib/Drupal/Core/Ajax/AjaxResponseRenderer.php
    @@ -0,0 +1,76 @@
    +    if ($content instanceof HtmlFragment) {
    +      $content = $content->getContent();
    +    }
    +    if ($content instanceof Response) {
    +      $content = $content->getContent();
    +    }
    

    if/elseif ?

  4. +++ b/core/lib/Drupal/Core/Ajax/AjaxResponseRenderer.php
    @@ -0,0 +1,76 @@
    +      // Complex Ajax callbacks can return a result that contains an error message
    

    80 char limit.

  5. +++ b/core/lib/Drupal/Core/Ajax/AjaxResponseRenderer.php
    @@ -0,0 +1,76 @@
    +          $error = t('An error occurred while handling the request: The server received invalid input.');
    

    Inject the translation service?

tstoeckler’s picture

  1. +++ b/core/lib/Drupal/Core/Ajax/AjaxResponseRenderer.php
    @@ -0,0 +1,76 @@
    + * Converts a controller result into an ajax response object.
    ...
    +   * Renders the controller result as ajax response object.
    

    ajax -> Ajax
    Also I think the second one would be much clearer if it were identical to the first one. "Render" is not exactly clear and "an" is missing.

  2. +++ b/core/lib/Drupal/Core/Ajax/AjaxResponseRenderer.php
    @@ -0,0 +1,76 @@
    +    if (!is_array($content)) {
    +      $content = array(
    +        '#markup' => $content,
    +      );
    +    }
    ...
    +    if (is_array($content) && isset($content['#type']) && ($content['#type'] == 'ajax')) {
    

    The is_array() can be saved in the second one, it will never be FALSE.

  3. +++ b/core/lib/Drupal/Core/Ajax/AjaxResponseRenderer.php
    @@ -0,0 +1,76 @@
    +} ¶
    

    Trailing whitespace.

  4. +++ b/core/lib/Drupal/Core/Ajax/AjaxResponseRenderer.php
    @@ -0,0 +1,76 @@
    +    if (!empty($output)) {
    +      $response->addCommand(new PrependCommand(NULL, $output));
    +    }
    

    Previously this was added unconditionally. Is there a specific reason for that?

  5. +++ b/core/modules/system/lib/Drupal/system/Tests/Ajax/AjaxTestBase.php
    @@ -24,22 +24,22 @@
    +   * An AjaxResponse object stores an array of Ajax commands This array
    

    Missing period after "commands".

  6. +++ b/core/modules/system/lib/Drupal/system/Tests/Ajax/FrameworkTest.php
    @@ -27,7 +27,7 @@ public static function getInfo() {
    +   * Ensures AjaxController adds JavaScript settings from the page request.
    ...
    -   * Ensures ajax_render() returns JavaScript settings from the page request.
    

    In case it still fits in the 80 chars (I think it does) add a "that" after "Ensures".

  7. +++ b/core/modules/system/lib/Drupal/system/Tests/Ajax/FrameworkTest.php
    @@ -101,7 +101,7 @@ public function testOrder() {
    +   * Tests behavior of an error alert command.
    ...
    -   * Tests behavior of ajax_render_error().
    

    Since we're already changing this, maybe "Tests *the* behavior"

  8. +++ b/core/modules/system/system.api.php
    @@ -399,17 +399,19 @@ function hook_css_alter(&$css) {
    + * framework.
    ...
    + * Alter the Ajax command data that are sent to the client through the Ajax
    

    are -> is
    Also: Dropping the "through the Ajax framework" would make it < 80 chars.

dawehner’s picture

StatusFileSize
new34.48 KB
new11.17 KB

Wow, two reviews in a short time, thank you!

Previously this was added unconditionally. Is there a specific reason for that?

Well, this code was moved from AjaxController to AjaxResponseRenderer, which is the more modern code compared to ajax_prepare_...

In case it still fits in the 80 chars (I think it does) add a "that" after "Ensures".

It fits exactly.

Since we're already changing this, maybe "Tests *the* behavior"

Sure.

Also: Dropping the "through the Ajax framework" would make it < 80 chars.

In general I wonder whether we should add an interface for the AjaxResponseRenderer?
Additional this replaces all references of ajax_render() in core.

January 4, 2014 at 4:11am

No comment.

tstoeckler’s picture

Awesome thanks! Looks great to me, but I don't know the Ajax system or the new page rendering system well enough to RTBC.

Crell’s picture

  1. +++ b/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php
    @@ -43,16 +44,26 @@ class ViewSubscriber implements EventSubscriberInterface {
    @@ -122,12 +133,8 @@ public function onAjax(GetResponseForControllerResultEvent $event) {
    
    @@ -122,12 +133,8 @@ public function onAjax(GetResponseForControllerResultEvent $event) {
         $page_callback_result = $event->getControllerResult();
     
         // Construct the response content from the page callback result.
    -    $commands = ajax_prepare_response($page_callback_result);
    -    $json = ajax_render($commands);
    -
    -    // Build the actual response object.
    -    $response = new JsonResponse();
    -    $response->setContent($json);
    +    $response = $this->ajaxRenderer->render($page_callback_result);
    +    $response->prepareResponse($event->getRequest());
     
         return $response;
       }
    

    We may as well split this to its own subscriber, as we did for Html.

  2. +++ b/core/lib/Drupal/Core/Ajax/AjaxResponseRenderer.php
    @@ -0,0 +1,77 @@
    +    // Most controllers return a render array, but some return a string.
    +    if (!is_array($content)) {
    +      $content = array(
    +        '#markup' => $content,
    +      );
    +    }
    

    For parallelism with the HTML pipeline, we should not be mixing the array rendering in with the rest of this logic. The renderer should already have a domain object (HtmlFragment, HtmlPage, etc.), and a render array is not a domain object.

    Which does suggest that perhaps we need a Drupal Ajax object other than AjaxResponse? Hm. It's not a perfect parallelism, I grant, but I am not comfortable with the Ajax renderer doing all three things when for Html the controller is responsible for normalizing render arrays to a domain object, and then the renderer just has to deal with the domain object.

Also, as written this means we have 2 redundant pipelines again, depending on whether an ajax request can sneak past the AjaxController. (If AJaxController does its job, then we never actually fire a view listener.) That's what we just fixed for HTML. Let's not introduce it here. :-)

dawehner’s picture

StatusFileSize
new35.32 KB
new2.22 KB

Given that the same code is executed for onAjax and the proper ajaxController we should rather use the AjaxController on those cases as well.

Crell’s picture

Hm. It's still not exactly parallel, but under the circumstances that's probably OK. I think that's the best we're going to be able to do, but we still get a delightful diffstat out of it. :-)

+++ b/core/lib/Drupal/Core/Routing/Enhancer/AjaxEnhancer.php
@@ -37,7 +37,7 @@ public function __construct(ContentNegotiation $negotiation) {
   public function enhance(array $defaults, Request $request) {
-    if (empty($defaults['_content']) && $defaults['_controller'] != 'controller.ajax:content' && $this->negotiation->getContentType($request) == 'drupal_ajax') {
+    if (empty($defaults['_content']) && $defaults['_controller'] != 'controller.ajax:content' && in_array($this->negotiation->getContentType($request), array('drupal_ajax', 'ajax', 'iframeupload'))) {
       $defaults['_content'] = isset($defaults['_controller']) ? $defaults['_controller'] : NULL;
       $defaults['_controller'] = 'controller.ajax:content';
     }

Do we still need this class at all?

This logic was intended as a BC shiv; in theory, ContentControllerEnhancer should be able to take care of ajax formats, too.

However, that would mean ajax-only routes (which we have a number of) would need to specify _content, not _controller, if they want to get the auto-wrapping controller. If they specify _controller, they MUST return an AjaxResponse themselves and they're on their own.

However, that is consistent with what is now required for HTML routes; if you specify _controller, you'd better not return a render array (or anything other than Response, HtmlFragment, or HtmlPage) or things WILL break and it's your own fault. And, in practice, I think that's what all of our ajax routes are doing now already, isn't it...?

So let's see what happens if we take AjaxEnhancer away completely and just add more mappings to ContentControllerEnhancer.

webchick’s picture

Issue tags: +beta blocker

Seeing as this changes a major API, this should most likely be a beta blocker.

dawehner’s picture

I agree that using _content for everything returning a render array would be nice consistency, though I really wonder whether the word "content" describes that properly. Personally I kind of connect content with HTML.
In addition though we would also add iframeupload and ajax support to the ContentControlleEnhancer if we really want to use it.
Do core maintainer have issues with this kind of small api changes these days?

Crell’s picture

I think it's fine. This issue is already ripping out the old API; let's rip it all the way.

sun’s picture

Issue tags: +@deprecated
dawehner’s picture

StatusFileSize
new35.36 KB

Yeah we can always iterate on top of it.

This is just a normal reroll, #2168113: Add leading underscore and other discouragement to drupal_add_css() and drupal_add_js() conflict with it.

Crell’s picture

dawehner: Er, I meant it should be fine to go ahead and fold AjaxEnhancer into ContentControllerEnhancer.

Note that this will conflict with the new plan in #2026431: Make ContentNegotiation a "internal" service, used only by the router, so that core or contrib can implement real negotiation. I'm not sure which we want to do first.

dawehner’s picture

dawehner: Er, I meant it should be fine to go ahead and fold AjaxEnhancer into ContentControllerEnhancer.

This would require ALL ajax callbacks to use _content instead which is kind of fine in, but certainly not in scope of this issue.
We just want to get rid of an old API.

Crell’s picture

dawehner’s picture

56: ajax-1959574.patch queued for re-testing.

Crell’s picture

Status: Needs review » Reviewed & tested by the community

Screw it, let's unblock stuff.

Crell’s picture

56: ajax-1959574.patch queued for re-testing.

dawehner’s picture

Issue summary: View changes
dawehner’s picture

Issue summary: View changes
StatusFileSize
new37.96 KB
new2.8 KB

Fixed the documentation at the top of the ajax.inc file.
I kinda think that we should put that information into a better place but not sure really where.
Let's do that in a follow up, as otherwise the patch is too hard to review.

alexpott’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/includes/ajax.inc
    @@ -185,6 +185,10 @@
    + * As developer you basically create a \Drupal\Core\Ajax\AjaxResponse and add
    + * a couple of \Drupal\Core\Ajax\CommandInterface onto it, which will converted
    + * to a commands array automaticall.y
    

    huh?

  2. +++ b/core/lib/Drupal/Core/Ajax/AjaxResponseRenderer.php
    @@ -0,0 +1,77 @@
    +      $error = $content['#error'];
    +      if (isset($error) && $error !== FALSE) {
    +        if ((empty($error) || $error === TRUE)) {
    +          $error = 'An error occurred while handling the request: The server received invalid input.';
    +        }
    +        $response->addCommand(new AlertCommand($error));
    +      }
    

    This logic looks really odd.

pounard’s picture

This is probably black magic.
if (!empty($error)) {} // Should have been enough I guess.
Or if you want to keep typing: if (NULL !== $error && FALSE !== $error) {} // And there you go.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new38.01 KB
new2.83 KB

This logic is indeed really confusing, what about this really simple concept? I would guess that the entire block could be skipped some as #type ajax is not really recommended anymore but just a AjaxResponse object.

amateescu’s picture

That interdiff seems to be from another issue :) And here's a small review of the doc since the functionality is a bit alien to me:

  1. +++ b/core/includes/ajax.inc
    @@ -185,6 +185,10 @@
    + * As developer you basically create a \Drupal\Core\Ajax\AjaxResponse and add
    

    Like Alex pointed out, this needs to be rephrased a bit. How about merging it with the phrase below?

  2. +++ b/core/lib/Drupal/Core/Ajax/AjaxResponseRenderer.php
    @@ -0,0 +1,78 @@
    + * Converts a controller result into an Ajax response object.
    

    I'm not sure what to say about this one as well, does a controller have a "result"? Because it sounds really weird..

  3. +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
    @@ -1670,7 +1670,8 @@ protected function drupalProcessAjaxResponse($content, array $ajax_response, arr
    +          //   and 'body', since these are used by
    +          // \Drupal\Core\Ajax\AjaxResponse::ajaxRender().
    

    Since I've been nitpicking so far, this needs two extra spaces.

Edit: For the second point above, how about 'Converts the output of a controller ...' or 'Converts the return value of a controller ....'?

dawehner’s picture

StatusFileSize
new2.54 KB
new38.26 KB

Like Alex pointed out, this needs to be rephrased a bit. How about merging it with the phrase below?

Good idea, what about the small merge in the interdiff?

I'm not sure what to say about this one as well, does a controller have a "result"? Because it sounds really weird..

Lets use output in the main description and "return value" on the @param to be more precise on the technical level

dawehner’s picture

StatusFileSize
new38.26 KB
new578 bytes

Amateescu found that.

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

#65 and my doc review was addressed => back to RTBC. @dawehner++

wim leers’s picture

StatusFileSize
new39.77 KB
new4.48 KB

Fixed a bunch of nitpicks. One question.

+++ b/core/lib/Drupal/Core/Routing/Enhancer/AjaxEnhancer.php
@@ -37,7 +37,7 @@ public function __construct(ContentNegotiation $negotiation) {
-    if (empty($defaults['_content']) && $defaults['_controller'] != 'controller.ajax:content' && $this->negotiation->getContentType($request) == 'drupal_ajax') {
+    if (empty($defaults['_content']) && $defaults['_controller'] != 'controller.ajax:content' && in_array($this->negotiation->getContentType($request), array('drupal_ajax', 'ajax', 'iframeupload'))) {

Shouldn't we at least document why we have both "drupal_ajax" and "ajax" as content types, and why AjaxEnhancer also needs to support the "iframeupload" content type?

wim leers’s picture

Status: Reviewed & tested by the community » Needs review
dawehner’s picture

StatusFileSize
new1.03 KB
new39.2 KB

Does this help?

andypost’s picture

+++ b/core/includes/ajax.inc
@@ -196,177 +197,30 @@
-    // Add the status messages inside the new content's wrapper element, so that
-    // on subsequent Ajax requests, it is treated as old content.
-    $commands[] = ajax_command_prepend(NULL, theme('status_messages'));

This hunk changed in #2177637: Replace theme() with drupal_render() in ajax.inc

dawehner’s picture

StatusFileSize
new30.91 KB

Thank you, luckily this was already part of the code before.

drclaw’s picture

Issue summary: View changes

Just unescaped the html in the issue summary

Crell’s picture

Status: Needs review » Reviewed & tested by the community

The last several patches were all just docs tweaks, so I think we're good to go here. Thanks, dawehner et al!

alexpott’s picture

Title: Remove the deprecated Drupal 7 Ajax API » Change record: Remove the deprecated Drupal 7 Ajax API
Status: Reviewed & tested by the community » Active
Issue tags: +Needs change record, +Missing change record

Committed e4e74fc and pushed to 8.x. Thanks!

jessebeach’s picture

Many of these changes seem opaque to anyone using the AJAX system through forms. Am I mistaken?

So it seems the change notice just needs some code examples from ajax_test.module, especially an example of adding a command e.g. $response->addCommand(new HtmlCommand('body', 'Hello, world!'));. And then it seems the only major change is the removal of ajax_render.

mkadin’s picture

Thanks to everyone who pushed this through and got it in.

jessebeach’s picture

I think the JsonResponse->callback method is now returning the data on an insert command, meaning we can't simply invoke jQuery.ajax on a route that should return jsonp data to be eval'ed. I believe this issue broke the loading of the toolbar submenus.

Ultimately I think we'll need a jsonp command that does the data eval'ing in ajax.js. I started an issue here #2187483: Toolbar subtree is broken | JsonResponse->callback now returns data in an Insert Command without any support in ajax.js to eval the callback in the client.

jessebeach’s picture

dawehner’s picture

Status: Active » Fixed
Issue tags: -Needs change record, -Missing change record

Many of these changes seem opaque to anyone using the AJAX system through forms. Am I mistaken?

Right, if you use #ajax nothing changed for you.

So it seems the change notice just needs some code examples from ajax_test.module, especially an example of adding a command e.g. $response->addCommand(new HtmlCommand('body', 'Hello, world!'));. And then it seems the only major change is the removal of ajax_render.

https://drupal.org/node/1843212 already has the change notice here ... this issue was just about deprecating the existing code.

Ultimately I think we'll need a jsonp command that does the data eval'ing in ajax.js. I started an issue here #2187483: JsonResponse->callback now returns data in an Insert Command without any support in ajax.js to eval the callback in the client.

Cu on that issue. Sorry for breaking it.

andypost’s picture

Status: Fixed » Active

Issue needs follow-up!

There's still ajax_render() and ajax_prepare_response() functions in core/includes/ajax.inc that are totally broken because calls removed ajax_command_*

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new6.46 KB

Damnit I totally failed at the last reroll.

andypost’s picture

xjm’s picture

Title: Change record: Remove the deprecated Drupal 7 Ajax API » Remove the deprecated Drupal 7 Ajax API
Status: Needs review » Fixed

That works too. Thanks!

Status: Fixed » Needs work

The last submitted patch, 86: ajax-1959574.patch, failed testing.

xjm’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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

dawehner’s picture