add getId() and make id() a wrapper for it and deprecate it

Created on 5 October 2014, over 10 years ago
Updated 4 January 2025, 3 months ago

Problem/Motivation

We have getId() on some interfaces, and no id().
In other places we have id() and no getId().

Actually replacing id() with getId() in #2246695: replace all core usages of id() with getid() would be the more obvious thing, but it is too massive and disruptive.

To postpone or not to postpone

According to #2350615: [policy, no patch] What changes can be accepted during the Drupal 8 beta phase? :

This is desirable because of DX and reducing confusion because some code will have both ->id() in some lines and getId() in others. The outside-of-drupal world expects getId().
This is a task, because it is not a bug.
This is normal, because .. it is not critical or major. https://www.drupal.org/node/45111 (priority definition, needs more detail there)
This impacts core and contributed modules in no negative way, and positively by using a more standard pattern and bringing some consistency.

Benefit of this is greater than the disruption (which is low).
This has a BC layer.

Since this is normal, that makes this 8.1.x

Proposed resolution

Remaining tasks

User interface changes

No.

API changes

Addition only.
Mark id() deprecated

📌 Task
Status

Closed: won't fix

Version

11.0 🔥

Component

entity system

Created by

🇺🇸United States yesct

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇭Switzerland berdir Switzerland

    This hasn't been touched in 10 years. I'll just go ahead and close this. Yes, it's unusual, be we have other methods like that too and I don't think the gains outweigh the benefits here 10 years into Drupal 8. The amount of code that would need to be changed is immense.

Production build 0.71.5 2024