diff --git a/core/lib/Drupal/Component/Utility/Html.php b/core/lib/Drupal/Component/Utility/Html.php index cde2a74..b10f203 100644 --- a/core/lib/Drupal/Component/Utility/Html.php +++ b/core/lib/Drupal/Component/Utility/Html.php @@ -35,7 +35,7 @@ class Html { protected static $seenIds; /** - * Contains if the current request was send via AJAX. + * Contains if the current request was sent via AJAX. * * @var bool */ diff --git a/core/lib/Drupal/Core/EventSubscriber/AjaxSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/AjaxSubscriber.php index ab2ab8b..83262f8 100644 --- a/core/lib/Drupal/Core/EventSubscriber/AjaxSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/AjaxSubscriber.php @@ -20,13 +20,19 @@ class AjaxSubscriber implements EventSubscriberInterface { /** + * Request parameter to indicate that a request is a drupal ajax request. + */ + const AJAX_REQUEST_PARAMETER = '_drupal_ajax'; + + /** * Sets the AJAX parameter from the current request. * * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event * The response event, which contains the current request. */ public function onRequest(GetResponseEvent $event) { - if ($event->getRequest()->request->get('ajax', '') == 1) { + // Ensure that ajax=1 is set. + if ($event->getRequest()->request->get(static::AJAX_REQUEST_PARAMETER)) { Html::setIsAjax(TRUE); } } diff --git a/core/misc/ajax.js b/core/misc/ajax.js index f47eb27..8f2b8cd 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -377,6 +377,11 @@ Drupal.ajax.WRAPPER_FORMAT = '_wrapper_format'; /** + * Request parameter to indicate that a request is a drupal ajax request. + */ + DRupal.ajax.AJAX_REQUEST_PARAMETER = '_drupal_ajax'; + + /** * Execute the ajax request. * * Allows developers to execute an Ajax request manually without specifying @@ -491,8 +496,8 @@ Drupal.detachBehaviors(this.$form.get(0), settings, 'serialize'); } - // Set that this is an drupal ajax request. - options.data.ajax = 1; + // Inform Drupal that this is an AJAX request. + options.data[Drupal.ajax.AJAX_REQUEST_PARAMETER] = 1; // Allow Drupal to return new JavaScript and CSS files to load without // returning the ones already loaded. diff --git a/core/modules/file/src/Tests/FileFieldWidgetTest.php b/core/modules/file/src/Tests/FileFieldWidgetTest.php index 4566d27..10f2cad 100644 --- a/core/modules/file/src/Tests/FileFieldWidgetTest.php +++ b/core/modules/file/src/Tests/FileFieldWidgetTest.php @@ -9,7 +9,6 @@ use Drupal\comment\Entity\Comment; use Drupal\comment\Tests\CommentTestTrait; -use Drupal\Component\Utility\Html; use Drupal\field\Entity\FieldConfig; use Drupal\field_ui\Tests\FieldUiTestTrait; use Drupal\user\RoleInterface;