Refactor certain inline module-exists checks in core components for readability

Created on 21 May 2015, about 10 years ago
Updated 2 June 2025, 4 days ago

Problem/Motivation

See referenced issues. Module-exist checks have been put in place in multiple core components that reference other core components in order to prevent a PHP exception when the referenced component is not enabled/installed. In some cases, the inline module exists checks make the code less readable.

Proposed resolution

The results of some of those inline checks can be moved into local variables in order to make the code more readable.

See contact_help() for an example of how to deal with this.

$block_page = \Drupal::moduleHandler()->moduleExists('block') ? \Drupal::url('block.admin_display') : '#';

Above line is an example of moving the inline check to a local variable.

Remaining tasks

Identify and replace inline module-exists checks with local variable equivalents where it will improve readability.

User interface changes

None

API changes

None

πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

base system

Created by

πŸ‡ΊπŸ‡ΈUnited States opratr

Live updates comments and jobs are added and updated live.
  • Needs beta evaluation

    Since the first beta of Drupal 8 was released, every new 8.0.x issue should have a beta evaluation in the summary, to help clarify whether the 8.0.0 release is a target for that issue.

  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

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.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for creating this issue to improve Drupal.

    We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

Production build 0.71.5 2024