Each class using DRUPAL_* constants from system.module should define its own constants

Created on 11 February 2017, almost 8 years ago
Updated 2 August 2024, 6 months ago

Problem/Motivation

Split from #2807785: Move global constants from *.module files into interfaces β†’ , comment #64, suggested by @Berdir.

DRUPAL_DISABLED, DRUPAL_OPTIONAL, and DRUPAL_REQUIRED are too generic to be meaningful.

I can only see 3 uses of them, node preview, comment preview and link title. Maybe each should define its own constants?

Proposed resolution

Create new constants to closer to where they are used in core and deprecate the overly ambitious constants that never needed to be globally available. There are three constants (see above) that have been identified. The challenge for this work is getting the deprecation notices accurate and making sure we have

Remaining tasks

  1. Add separate constant to node preview and change the usage to use the more centralized constant.
  2. Add separate constant to Comment preview and change the usage to use the more centralized constant.
  3. Add separate constant to link title and change the usage to use the more centralized constant.
  4. Deprecate the system.module DRUPAL_ constants in favor of the replacements. To deprecate it, @catch suggested on slack, "It should be fine to add @deprecated to the phpdoc like we do for methods etc. I think phpstan picks this up fine now (it didn't when this issue was created or at least we weren't using it then)," which can be found here: https://www.drupal.org/about/core/policies/core-change-policies/drupal-d... β†’ . An example of a deprecation message that @catch recommends is the deprecation note added here: https://git.drupalcode.org/project/drupal/-/blob/10.3.x/core/includes/bo... for `REQUEST_TIME` deprecation.
  5. Create a change record.

User interface changes

None.

API changes

Yes. Three global constants are being deprecated. This means the constants need to be deprecated and new ones added in the same commit.

Data model changes

None.

πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated about 5 hours ago

Created by

πŸ‡·πŸ‡΄Romania claudiu.cristea Arad πŸ‡·πŸ‡΄

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

Not all content is available!

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

Production build 0.71.5 2024