Deprecated: Optional parameter $entity_type_bundle_info declared before required parameter

Created on 27 December 2024, 8 months ago

Problem/Motivation

Getting this error:
Deprecated: Optional parameter $entity_type_bundle_info declared before required parameter $creation_service is implicitly treated as a required parameter in /code/web/modules/contrib/recurring_events/modules/recurring_events_registration/src/Form/RegistrantDeleteForm.php on line 60
when I try to cancel/delete my waitlist registration

πŸ› Bug report
Status

Active

Version

2.0

Component

Recurring Events Registration (Submodule)

Created by

πŸ‡§πŸ‡·Brazil carolpettirossi Campinas - SP

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

Merge Requests

Comments & Activities

  • Issue created by @carolpettirossi
  • πŸ‡§πŸ‡·Brazil carolpettirossi Campinas - SP
  • Pipeline finished with Failed
    8 months ago
    Total: 319s
    #379963
  • Status changed to Needs work about 2 months ago
  • πŸ‡ΊπŸ‡ΈUnited States jrb Raleigh-Durham Area, NC, USA

    This is actually a problem in 4 different places:

    RegistrantDeleteForm.php

    public function __construct(EntityRepositoryInterface $entity_repository,
      ?EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL,
      ?TimeInterface $time = NULL,
      Messenger $messenger,
      Renderer $renderer,
      RegistrationCreationService $creation_service) {
    

    EventSeriesDeleteForm.php

    public function __construct(EntityRepositoryInterface $entity_repository,
      ?EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL,
      ?TimeInterface $time = NULL,
      Messenger $messenger,
      Renderer $renderer,
      ConfigFactory $config) {
    

    EventInstanceDeleteForm.php

    public function __construct(EntityRepositoryInterface $entity_repository,
      ?EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL,
      ?TimeInterface $time = NULL,
      Messenger $messenger,
      DateFormatter $date_formatter) {
    

    TaxonomyIndexTidEventSeriesDepth.php

    public function __construct(array $configuration,
      $plugin_id,
      $plugin_definition,
      VocabularyStorageInterface $vocabulary_storage,
      TermStorageInterface $term_storage,
      ?AccountInterface $current_user = NULL,
      ?EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL,
      ?EntityFieldManagerInterface $entity_field_manager = NULL,
      Connection $database) {
    

    Given that all of these classes are working as they are (I assume), is the best solution to just make all of these optional parameters not optional?

    Each class has a create method that passes all parameters, so everything should just continue to work, right?

  • πŸ‡§πŸ‡¬Bulgaria pfrenssen Sofia

    This is already fixed in the 3.0.x branch as part of πŸ“Œ Fix constructors which have incorrectly marked arguments as nullable Active . Changing the order of the arguments is a B/C break which will affect existing projects which extend these forms with customized versions. That was why this was not fixed in 2.0.x.

    I think the non-B/C breaking way to solve this is to make the trailing arguments nullable. Then the deprecation warning goes away, and extending code is not affected.

    public function __construct(EntityRepositoryInterface $entity_repository,
      ?EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL,
      ?TimeInterface $time = NULL,
      ?Messenger $messenger = NULL, // Make trailing arguments nullable.
      ?DateFormatter $date_formatter = NULL // Make trailing arguments nullable.
    ) {
    

    I personally think this is not so important to backport to 2.0.x since it is just a deprecation warning and 2.0.x will be unsupported when D10 support ends, so I will close this as a duplicate of πŸ“Œ Fix constructors which have incorrectly marked arguments as nullable Active . However if someone deeply cares about this, feel free to reopen the issue!

Production build 0.71.5 2024