Problem/Motivation

https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/node/...

This is a procedural function in node.module that can be deprecated in favour of an OOP API.

Steps to reproduce

N/A

Proposed resolution

Replace with a new function from #2699835: Add a method to ContentEntityBase for getting its Bundle entity chained with ->label()

Remaining tasks

Postponed on #2699835: Add a method to ContentEntityBase for getting its Bundle entity
Deprecate + replace usages of node_get_type_label

API changes

node_get_type_label is deprecated

Issue fork drupal-3531943

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

acbramley created an issue. See original summary.

acbramley’s picture

Issue summary: View changes
Status: Active » Postponed
acbramley’s picture

acbramley’s picture

Issue summary: View changes

acbramley’s picture

Status: Postponed » Needs review
berdir’s picture

Status: Needs review » Needs work

Missing the @trigger_error()?

acbramley’s picture

Status: Needs work » Needs review

woops!

berdir’s picture

Status: Needs review » Needs work

The change looks good.

I'm unsure about the D12 deprecation, while it's trivial and not used a lot, the suggested replacement requires 11.3. I'd suggest we expand the change record, mention that getBundleEntity is 11.3+ and suggest using $node->get('type')->entity->label() as an alternative which is fully backwards compatible and then we'll see if core maintainers are OK with that.

acbramley’s picture

Status: Needs work » Needs review

the suggested replacement requires

But the deprecation is also in 11.3, but I see where you're coming from for modules supporting both 11.3 and 11.2.

I've updated the CR.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

CR reads fine and a good deprecation. Not sure what else to review..

catch’s picture

Status: Reviewed & tested by the community » Needs work

I checked contrib and found 10-20 modules using this (three pages on gitlab search).

#3518671: [policy, no patch] Defer disruptive 11.3 deprecations for removal until 13.0 probably means this should be deprecated for removal in 13.0 - it's borderline given there's an 11.2 way to do this, but if we defer the deprecation to 13.x then modules that want to support 11.2 and 12.0.0 betas at the same time can ignore the change and do it once (to the new, new way) when they drop 11.2 support instead of twice.

acbramley’s picture

Status: Needs work » Reviewed & tested by the community

Updated deprecation messages, back to RTBC since this is a trivial change.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x, thanks!

  • catch committed cea6c6bd on 11.x
    Issue #3531943 by acbramley, berdir: Deprecate node_get_type_label()
    
catch’s picture

catch’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.