Deprecated function: Creation of dynamic property in ConfigPatchGitlabApiProjectBranchForm

Created on 29 November 2024, about 1 month ago

Problem/Motivation

The following error message will appear when trying to access the "Config Patch Gitlab API - Project & Branch"
(/admin/config/config_patch_gitlab_api/project_branch):

Deprecated function: Creation of dynamic property Drupal\config_patch_gitlab_api\Form\ConfigPatchGitlabApiProjectBranchForm::$urlGenerator is deprecated in Drupal\config_patch_gitlab_api\Form\ConfigPatchGitlabApiProjectBranchForm->__construct() (line 60 of modules/contrib/config_patch_gitlab_api/src/Form/ConfigPatchGitlabApiProjectBranchForm.php).
Drupal\config_patch_gitlab_api\Form\ConfigPatchGitlabApiProjectBranchForm->__construct() (Line: 76)
Drupal\config_patch_gitlab_api\Form\ConfigPatchGitlabApiProjectBranchForm::create() (Line: 41)
Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition() (Line: 48)
Drupal\Core\Controller\HtmlFormController->getFormObject() (Line: 58)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 44)
Drupal\redirect_after_login\RedirectMiddleware->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 53)
Asm89\Stack\Cors->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Steps to reproduce

I have tested this with PHP 8.3 and Drupal 10.3.9

Proposed resolution

Adding the type before the property helps already:

  /**
   * @var \Drupal\config_patch_gitlab_api\Gitlab\ConfigPatchGitlabClientFactory
   */
  protected ConfigPatchGitlabClientFactory $configPatchGitlabClientFactory;

  /**
   * @var \Drupal\Core\Routing\UrlGeneratorInterface
   */
  protected UrlGeneratorInterface $urlGenerator;

  /**
   * @var \Drupal\Core\State\StateInterface
   */
  protected StateInterface $state;

  /**
   * @var \Drupal\Core\Cache\CacheBackendInterface
   */
  protected CacheBackendInterface $cache;

I will create a MR and patch right away.

πŸ› Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

πŸ‡¨πŸ‡­Switzerland martinpe

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024