ConfigFormBase::typedConfigManager() should have been removed when deprecations were removed in 11.0

Created on 29 September 2024, 6 months ago

Problem/Motivation

Some deprecation handling code was added in ๐Ÿ› [regression] The new property \Drupal\Core\Form\ConfigFormBase::$typedConfigManager conflicts with some contrib modules Fixed for the $this->typedConfigManager class property. This added among other things:

+  protected function typedConfigManager(): TypedConfigManagerInterface {

The $this->typedConfigManager constructor parameter no longer has deprecation handling, so this method should be removed too.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

๐Ÿ“Œ Task
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component

forms system

Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom joachim

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Comments & Activities

  • Issue created by @joachim
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia annmarysruthy

    Deprecation code was added in https://www.drupal.org/project/drupal/issues/3394197 ๐Ÿ› [regression] The new property \Drupal\Core\Form\ConfigFormBase::$typedConfigManager conflicts with some contrib modules Fixed and later it was removed in https://www.drupal.org/project/drupal/issues/3443488 ๐Ÿ“Œ Remove deprecated code from lib/Flood and lib/Form Fixed

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada ksere Montreal

    Was just checking the code in the ConfigFormBase class and was wondering if it's safe to fully remove the method?

    /**
       * Returns the typed config manager service.
       *
       * @return \Drupal\Core\Config\TypedConfigManagerInterface
       *   The typed config manager service.
       */
      protected function typedConfigManager(): TypedConfigManagerInterface {
        if ($this->typedConfigManager instanceof TypedConfigManagerInterface) {
          return $this->typedConfigManager;
        }
        return \Drupal::service('config.typed');
      }

    Would it be safer to keep to just remove the condition and turn it into a getter to avoid breaking contrib or custom modules that could be using it? Like so:

    /**
       * Returns the typed config manager service.
       *
       * @return \Drupal\Core\Config\TypedConfigManagerInterface
       *   The typed config manager service.
       */
      protected function typedConfigManager(): TypedConfigManagerInterface {
        return $this->typedConfigManager;
      }

    Just want to make sure!

  • First commit to issue fork.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia mdsohaib4242

    It would be safer to keep the method and just remove the condition, turning it into a getter. This way, you avoid the risk of breaking contrib or custom modules that might rely on it. By keeping it as a getter, you ensure backward compatibility.

    /**
     * Returns the typed config manager service.
     *
     * @return \Drupal\Core\Config\TypedConfigManagerInterface
     *   The typed config manager service.
     */
    protected function typedConfigManager(): TypedConfigManagerInterface {
      return $this->typedConfigManager;
    }
    

    This will make sure your modules continue to work seamlessly without any unexpected breaks. Does this give you a bit more confidence in your change?

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom joachim

    The typedConfigManager() was only added for deprecation handling, when the TypedConfigManager was added to the constructor.

    There's no need for it to exist in the long term.

  • @ankitv18 opened merge request.
  • First commit to issue fork.
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance andypost

    Fix looks good, pipeline needs to re-queue failed job

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia ankitv18

    I thought faux commit would do the magic after learning about composer 2.8.1 issues failing tests.
    Tests are still failing which is quite unfamiliar to me

    Time: 00:08.303, Memory: 8.00 MB
        
        There was 1 error:
        
        1)
        Drupal\Tests\Composer\Plugin\Scaffold\Functional\ComposerHookTest::testComposerHooks
        RuntimeException: Exit code: 1
        
        Creating a "fixtures/drupal-drupal" project at "./create-project-test"
        Installing fixtures/drupal-drupal (1.0.0)
    

    Any idea? @andypost

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia ankitv18

    Now pipelines are passing ~~ seems some issue with gitlab CI or seems failing due to composer 2.8.1(Not sure)
    Moving into review

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    If it was missed in D11 that was definitely a mistake but think it should be deprecated properly since D11 is already out.

    Leaving novice tag.

  • Status changed to Needs work about 1 month ago
  • The Needs Review Queue Bot โ†’ tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • First commit to issue fork.
  • ๐Ÿ‡ง๐Ÿ‡ทBrazil charlliequadros

    Iโ€™ve fixed the code standards issues.

  • The patch successfully deprecates typedConfigManager() in ConfigFormBase, ensuring that it is no longer used in Drupal core while maintaining backward compatibility until its removal in Drupal 12. After applying the patch, analysis tools like Intelephense correctly recognize the deprecation, highlighting it in the codebase. However, no warnings appear in the Drupal logs (dblog), suggesting that core no longer calls this method at runtime. To further verify this, I also created a custom module with a configuration form that explicitly called typedConfigManager() inside validateForm(). While the function was executed, no deprecation warnings were logged, reinforcing the conclusion that this method is no longer triggered within Drupal core itself but depreciation message was triggered in codebase. Overall, the patch achieves its goal without introducing regressions, and developers should ensure they update their custom code accordingly before Drupal 12.
    Hence Moving the issue to RTBC.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    One comment on the MR.

  • ๐Ÿ‡ง๐Ÿ‡ทBrazil charlliequadros

    Hi @catch

    I'd like to clarify a few doubts before making the changes.

    If I remove only the redundant part, won't the comment look strange with just "There is no replacement."?

    Also, I didn't understand this other part.

    Also I think the replacement is to use the typeConfigManager property as is done in ::validateForm()

    Now that 'typedConfigManager' is injected as a dependency, there will always be a valid object.

    In that case, wouldn't the return already be correct? Am I mistaken?

    Could you explain these points to me before I proceed with the changes?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    @charlliequadros the change should be fine and actually more inline with other deprecations in core. While you're at it can you rebase the MR as it's 700+ commits back

    If you are another contributor eager to jump in, please allow the previous poster at least 48 hours to respond to feedback first, so they have the opportunity to finish what they started!

  • ๐Ÿ‡ง๐Ÿ‡ทBrazil charlliequadros

    Hey @smustgrave,
    Iโ€™ve done the rebase as you requested. Do I need to do anything else regarding the questions I asked here ๐Ÿ“Œ ConfigFormBase::typedConfigManager() should have been removed when deprecations were removed in 11.0 Active

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    The comment on the MR is valid

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia adwivedi008

    Hello Smustgrave,

    Can you explain a bit what other changes are required over the Mr because as per comment the changes are not very clear to me

    Do we need to remove the typedConfigManager completely? Or anything else

    The 'This method is no longer used by Drupal core' is redundant here and can be removed.
    Also I think the replacement is to use the typeConfigManager property as is done in ::validateForm()
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Please allow the original user least 48 hours to finish it

  • ๐Ÿ‡ง๐Ÿ‡ทBrazil charlliequadros

    Hi @smustgrave,

    The comment on the MR didn't make much sense to me either. Could you explain that part better?

    Also I think the replacement is to use the typeConfigManager property as is done in ::validateForm()

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    This method is no longer used by Drupal core is incorrect. If you check other deprecation messages should help

  • ๐Ÿ‡ง๐Ÿ‡ทBrazil charlliequadros

    Hi @smustgrave

    Sorry, but I still donโ€™t fully understand what I need to do. Could you clarify the next step?

    Either way, if itโ€™s not possible to explain right now, Iโ€™ll keep an eye on this ticket to see how the issue gets resolved.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Sivaji_Ganesh_Jojodae Chennai

    I think the feedback is to change as follow,

    - @trigger_error('typedConfigManager() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. This method is no longer in use instead $this->typedConfigManager to be used. See https://www.drupal.org/project/drupal/issues/3477616', E_USER_DEPRECATED);
    + @trigger_error('typedConfigManager() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. The replacement is to use the $this->typedConfigManager as is done in ::validateForm(). See https://www.drupal.org/project/drupal/issues/3477616', E_USER_DEPRECATED);
    
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Fixed, now I can't review.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia ankitv18

    @smustgrave Thanks!!
    Please do consider to fix the pipeline also: https://git.drupalcode.org/issue/drupal-3477616/-/jobs/4763371#L394

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia ankitv18
Production build 0.71.5 2024