Problem/Motivation

Commerce 4.x still has 154 procedural functions marked #[LegacyHook] across its 24 .module files. They forward to the OOP hook classes and only exist for Drupal core versions before 11.1. Since #3638817: Require Drupal ^11.1 and PHP ^8.3 on 4.x, test against Drupal 12 in CI, 4.x requires Drupal ^11.1 (now ^11.5), so they're dead code.

They weren't part of #3638819: Remove code deprecated for removal in commerce:4.0.0. They were never @deprecated; they're a compatibility layer for older core versions.

Proposed resolution

  • Remove all #[LegacyHook] stubs.
  • Move any template_preprocess_* functions to initial preprocess callbacks (Drupal 11.2+).
  • Delete .module files that end up empty, and review whatever else is left in the others (constants, helpers).

Issue fork commerce-3640963

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

jsacksick created an issue. See original summary.

jsacksick’s picture

Status: Active » Needs review

Removed all #[LegacyHook] stubs, plus the template_preprocess_* wrappers (every theme hook already defines initial preprocess, so core never called them).

  • Deleted the now-empty .module files: cart, checkout, log, number_pattern, payment, price, promotion, store, tax.
  • Removed commerce_alter_inline_forms(), an unused wrapper around CommerceHooks::alterInlineForms().
  • What's left in commerce.module, commerce_order.module and commerce_product.module are helpers still in use (commerce_get_entity_display(), _commerce_entity_theme_suggestions(), the order address field helpers, commerce_product_add_body_field(), etc.). Moving those to services can be a separate follow-up.
  • commerce_promotion_post_update_1() called commerce_promotion_entity_base_field_info(); it now calls CommercePromotionHooks::entityBaseFieldInfo().
  • Updated comments that still referenced the old procedural function names.
  • Removed the hook class definitions from the *.services.yml files. Core (11.1+) registers #[Hook] classes as autowired services keyed by class name.

  • jsacksick committed a4dbd7d9 on 4.x
    task: #3640963 Remove the #[LegacyHook] procedural stubs
    
    By: jsacksick
    
jsacksick’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.