Use `__construct()` instead of removed `::create()`

Created on 2 March 2023, almost 2 years ago
Updated 17 March 2023, almost 2 years ago

Problem/Motivation

Symfony has removed the deprecated create() methods. According to the release notes on https://github.com/symfony/symfony/blob/6.3/src/Symfony/Component/HttpFo..., the following methods have been removed: Response::create(), JsonResponse::create(), RedirectResponse::create(), StreamedResponse::create(), and BinaryFileResponse::create(). Instead, it is recommended to use __construct() for these classes. This change affects all Drupal 10 users who are using the simple_oauth module.

Steps to reproduce

To reproduce the issue, use any Drupal 10 project that is using simple_oauth. For instance, you can encounter a following error message: "Error: Call to undefined method Symfony\Component\HttpFoundation\RedirectResponse::create() in Drupal\simple_oauth\Controller\Oauth2AuthorizeController->redirectAnonymous() (line 182 of /var/www/html/web/modules/contrib/simple_oauth/src/Controller/Oauth2AuthorizeController.php)." To generate this error message, make a GET request to receive an authorization code: {host_url}/oauth/authorize?response_type=code&client_id={client_id}&scope={scope}&code_verifier={code_verifier}, where each {} is replaced with actual data.

Proposed resolution

Use `__construct()` instead of the removed `::create()` methods.

Remaining tasks

Identify the branches that this issue affects.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Fixed

Version

6.0

Component

Code

Created by

🇵🇱Poland mscieszka

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024