From ce85e5a51ada2b10796dfa3c1c6087333dba495a Mon Sep 17 00:00:00 2001
From: Tobias Zimmermann <tobias@the-resc.com>
Date: Wed, 27 Nov 2024 09:56:26 +0100
Subject: [PATCH] Add deprecation for missing $request in
 EntityController::addPage()

---
 .../Drupal/Core/Entity/Controller/EntityController.php   | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/core/lib/Drupal/Core/Entity/Controller/EntityController.php b/core/lib/Drupal/Core/Entity/Controller/EntityController.php
index a16da0a9e63a..ee6768cc1d90 100644
--- a/core/lib/Drupal/Core/Entity/Controller/EntityController.php
+++ b/core/lib/Drupal/Core/Entity/Controller/EntityController.php
@@ -145,7 +145,7 @@ protected function redirect($route_name, array $route_parameters = [], array $op
    *
    * @param string $entity_type_id
    *   The entity type ID.
-   * @param \Symfony\Component\HttpFoundation\Request $request
+   * @param ?\Symfony\Component\HttpFoundation\Request $request
    *   The request object. If this contains a destination query parameter, it is
    *   "forwarded" to the add links (or the redirect response).
    *
@@ -153,7 +153,12 @@ protected function redirect($route_name, array $route_parameters = [], array $op
    *   If there's only one available bundle, a redirect response.
    *   Otherwise, a render array with the add links for each bundle.
    */
-  public function addPage($entity_type_id, Request $request) {
+  public function addPage($entity_type_id, ?Request $request = NULL) {
+    if ($request === NULL) {
+      @trigger_error('Calling ' . __METHOD__ . ' without the $request argument is deprecated in drupal:11.2.0 and it will be required in drupal:12.0.0. See https://www.drupal.org/project/drupal/issues/3490141', E_USER_DEPRECATED);
+      $request = \Drupal::request();
+    }
+
     $entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
     $bundles = $this->entityTypeBundleInfo->getBundleInfo($entity_type_id);
     $bundle_key = $entity_type->getKey('bundle');
-- 
GitLab