Merge branch 'MDL-58555' of https://github.com/timhunt/moodle
authorDavid Monllao <david.monllao@gmail.com>
Wed, 12 Apr 2017 12:08:27 +0000 (14:08 +0200)
committerDavid Monllao <david.monllao@gmail.com>
Wed, 12 Apr 2017 12:08:27 +0000 (14:08 +0200)
lib/amd/build/ajax.min.js
lib/amd/src/ajax.js

index 79cd16a..936d338 100644 (file)
Binary files a/lib/amd/build/ajax.min.js and b/lib/amd/build/ajax.min.js differ
index b2afb6b..663ff25 100644 (file)
@@ -111,7 +111,9 @@ define(['jquery', 'core/config'], function($, config) {
         call: function(requests, async, loginrequired) {
             var ajaxRequestData = [],
                 i,
-                promises = [];
+                promises = [],
+                methodInfo = [],
+                requestInfo = '';
 
             if (typeof loginrequired === "undefined") {
                 loginrequired = true;
@@ -137,6 +139,13 @@ define(['jquery', 'core/config'], function($, config) {
                     request.deferred.fail(request.fail);
                 }
                 request.index = i;
+                methodInfo.push(request.methodname);
+            }
+
+            if (methodInfo.length <= 5) {
+                requestInfo = methodInfo.sort().join();
+            } else {
+                requestInfo = methodInfo.length + '-method-calls';
             }
 
             ajaxRequestData = JSON.stringify(ajaxRequestData);
@@ -150,20 +159,22 @@ define(['jquery', 'core/config'], function($, config) {
                 contentType: "application/json"
             };
 
-            var script = config.wwwroot + '/lib/ajax/service.php?sesskey=' + config.sesskey;
+            var script = 'service.php';
             if (!loginrequired) {
-                script = config.wwwroot + '/lib/ajax/service-nologin.php?sesskey=' + config.sesskey;
+                script = 'service-nologin.php';
             }
+            var url = config.wwwroot + '/lib/ajax/' + script +
+                    '?sesskey=' + config.sesskey + '&info=' + requestInfo;
 
             // Jquery deprecated done and fail with async=false so we need to do this 2 ways.
             if (async) {
-                $.ajax(script, settings)
+                $.ajax(url, settings)
                     .done(requestSuccess)
                     .fail(requestFail);
             } else {
                 settings.success = requestSuccess;
                 settings.error = requestFail;
-                $.ajax(script, settings);
+                $.ajax(url, settings);
             }
 
             return promises;