Deprecate Drupal\locale\Locale and its one method

Created on 21 February 2024, 3 months ago
Updated 1 May 2024, 22 days ago

Problem/Motivation

Drupal\locale\Locale::config() is just a wrapper method that returns a service.

It doesn't serve any useful purpose and makes code more confusing to read. It's clearer to see what's going on when you see a service being called than a mystery static method.

Steps to reproduce

Proposed resolution

Deprecate the config() method.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

๐Ÿ“Œ Task
Status

Fixed

Version

10.3 โœจ

Component
Localeย  โ†’

Last updated about 9 hours ago

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

Merge Requests

Comments & Activities

  • Issue created by @joachim
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom joachim
  • First commit to issue fork.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia govind_giri_goswami

    Yes, we can remove the Drupal\locale\Locale::config() method because in files such as core/modules/locale/locale.bulk.inc and core/modules/locale/tests/src/Functional/LocaleConfigTranslationImportTest.php, the function of the injected service is directly called instead of going through the config() function. Therefore, it's more efficient to directly utilize the injected service in these files.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Keshav Patel

    Keshav Patel โ†’ made their first commit to this issueโ€™s fork.

  • Pipeline finished with Failed
    3 months ago
    Total: 173s
    #113418
  • Pipeline finished with Success
    3 months ago
    Total: 579s
    #113423
  • Status changed to Needs review 3 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Keshav Patel

    Replaced Drupal\locale\Locale::config() with \Drupal::service('locale.config_manager'), Verified the Checks Using core/scripts/dev/commit-code-check.sh --cached (All Checks Passed). Please Review

  • Status changed to Needs work 3 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Don't see the deprecation.

  • First commit to issue fork.
  • Pipeline finished with Failed
    2 months ago
    Total: 182s
    #124813
  • Pipeline finished with Failed
    2 months ago
    Total: 214s
    #124840
  • Pipeline finished with Failed
    2 months ago
    Total: 216s
    #124987
  • Pipeline finished with Failed
    2 months ago
    Total: 486s
    #124995
  • Status changed to Needs review 2 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia karanpagare

    Deprecated the config() method.

  • Status changed to Needs work 2 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom joachim

    > Deprecated the config() method.

    Deprecating doesn't meant removing it -- we have to keep it in, and add a trigger_error() to it so that any callers are told that they need to updated their code.

  • First commit to issue fork.
  • Pipeline finished with Failed
    about 2 months ago
    Total: 171s
    #132297
  • Status changed to Needs review about 2 months ago
  • Status changed to Needs work about 2 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Deprecation isnโ€™t correct. Recommend looking through the repo for examples of deprecation format

  • Pipeline finished with Failed
    about 2 months ago
    Total: 1781s
    #133006
  • ๐Ÿ‡ฏ๐Ÿ‡ตJapan magaki

    I modified the documentation according to Drupal deprecation policy and added its test.
    Please review it.

    The test fails, but it doesn't seem to be related to the changes.
    https://git.drupalcode.org/issue/drupal-3422915/-/pipelines/133015/test_...โšก%EF%B8%8F%20PHPUnit%20Unit

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

    Seems small enough to deprecate in 10.3 for removal in 11.

    Will need a change record and the link points to that. Can be simple and would search the change record list for other deprecation examples for to write one (usually just a sentence or two)

    And for the random failure would try and pull the latest 11.x code into this branch. Thatโ€™s resolved it on other issues.

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

    Good work with the test!

  • Status changed to Needs review about 2 months ago
  • ๐Ÿ‡ฏ๐Ÿ‡ตJapan magaki

    I modified the deprecated version to 10.3 and removal version to 11.0.

    I could not create change records because I have no permissions.

  • Pipeline finished with Failed
    about 2 months ago
    Total: 578s
    #133025
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    On this ticket whaat happens if you click add change notice?

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

    If that doesnโ€™t work will try and help on Monday

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

    > pull the latest 11.x code into this branch

    Please rebase rather than merge!

  • Pipeline finished with Failed
    about 2 months ago
    Total: 181s
    #133120
  • ๐Ÿ‡ฏ๐Ÿ‡ตJapan magaki

    I made a mistake in rebase once, so I force pushed the pre-rebase, updated the 11.x branch of the repository to the latest, and rebased the branch to on top of that.

  • Pipeline finished with Success
    about 2 months ago
    Total: 607s
    #133128
  • ๐Ÿ‡ฏ๐Ÿ‡ตJapan magaki

    Thank you for confirming my account.
    I could create a new change records.
    https://www.drupal.org/node/3437110 โ†’

  • Pipeline finished with Success
    about 2 months ago
    Total: 496s
    #133153
  • Status changed to RTBC about 2 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Deprecation CR looks good.

    Thanks for updating link in code too.

  • Status changed to Needs work about 2 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    Thanks for working on this everyone!

    Some unrelated change snuck into the MR - probably due to an IDE - we need to remove that. Also I don;t think this issue should be introducing a camel cased variable everywhere. I
    think we should replace Locale::config() we \Drupal::service('locale.config_manager') and be done.

    Also we need to add a deprecation to the class body so that we can safely remove the class in 11.x. I. think this is fine here because this in not a plugin and therefore won't trigger unexpected deprecations only good ones.

  • Pipeline finished with Failed
    about 2 months ago
    #133614
  • Status changed to Needs review about 2 months ago
  • ๐Ÿ‡ฏ๐Ÿ‡ตJapan magaki

    - Added documentation about the deprecation of the Locale class.
    - Removed unnecessary periods.
    - About using $localConfigManager as a temporary variable of Locale::config()
    - Removed $localConfigManager if it was only used once.
    - Renamed to $locale_config_manager if it was used more than once.
    Please review it

  • Pipeline finished with Canceled
    about 2 months ago
    Total: 62s
    #133616
  • Pipeline finished with Success
    about 2 months ago
    Total: 635s
    #133618
  • Status changed to RTBC about 1 month ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Deprecation seems good now. Marking this so we don't miss the 10.3 boat.

  • Status changed to Needs work about 1 month ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    If we're doing this for removal in 11.0.0, we should also have an 11.x-specific MR here that does the removal directly without the bc layer / test coverage etc. The existing MR should be re-targeted/rebased for 10.3.x

    Haven't been asking for this previously, but we're adding new deprecations nearly as quickly as we're removing them still, so think we need to start using that workflow.

  • Status changed to Needs review 30 days ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom joachim

    Easier to make the current MR for 11.x the one without the deprecation, and make a new branch and MR for 10.3 with the current code.

  • Pipeline finished with Success
    30 days ago
    Total: 1048s
    #154201
  • Status changed to RTBC 30 days ago
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance andypost

    Looks ready again

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Pravesh_Poonia

    Yes, Issues are looking Fixed now

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    alexpott โ†’ changed the visibility of the branch 3422915-10.2.deprecate-drupallocalelocale to hidden.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    alexpott โ†’ changed the visibility of the branch 11.x to hidden.

  • Status changed to Needs work 30 days ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    I've fixed up the 10.3.x MR so that the test is correct - this does not return a \Drupal\Core\Config\ConfigManager object it returns a \Drupal\locale\LocaleConfigManager object.

    Unfortunately the 11.x MR does not do the removal so that needs work.

    Also we use \Drupal::service() over Drupal::service()

  • Pipeline finished with Failed
    30 days ago
    Total: 1106s
    #154388
  • Assigned to joachim
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom joachim

    > This file needs to be removed - this is the 11.x branch.

    Ok something went WTF with my branches. I'll fix.

  • Issue was unassigned.
  • Status changed to Needs review 30 days ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom joachim

    I've fixed the file removals in the 11.x MR. I've no idea how they got lost / and maybe on the wrong branch!

    I'm confused about whether there's anything else to fix -- @alexpott you seem to have applied the suggested changes to both branches?

  • Pipeline finished with Success
    30 days ago
    Total: 988s
    #154455
  • Status changed to RTBC 25 days ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Rebased the 10.3.x MR as the failure appeared to be a random Umami bug.

    Believe all feedback has been addressed

  • Pipeline finished with Success
    25 days ago
    Total: 598s
    #159004
    • alexpott โ†’ committed dc9a4c53 on 10.3.x
      Issue #3422915 by magaki, karanpagare, joachim, alexpott, Keshav Patel,...
  • Status changed to Fixed 24 days ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    Committed dc9a4c5 and pushed to 10.3.x. Thanks!
    Committed 4c93088 and pushed to 11.x. Thanks!

    • alexpott โ†’ committed 4c93088c on 11.x
      Issue #3422915 by magaki, karanpagare, joachim, alexpott, Keshav Patel,...
    • alexpott โ†’ committed 4c93088c on 11.0.x
      Issue #3422915 by magaki, karanpagare, joachim, alexpott, Keshav Patel,...
Production build 0.69.0 2024