drupal_get_path() has been deprecated

Created on 24 June 2023, 11 months ago
Updated 10 August 2023, 10 months ago

Problem/Motivation

Error: Call to undefined function drupal_get_path() in idyllic_form_system_theme_settings_alter() (line 212 of themes\idyllic\idyllic.theme).

Steps to reproduce

1. Take clone from git version 1.0.x in drupal 10
2. Installed and set the theme as default
3. Installed latest bootstrap5 theme from composer as it is the base theme for idyllic.
4. Go to homepage to see the following error.

Proposed resolution

Replace the deprecated function drupal_get_path() with \Drupal::service('extension.list.theme')->getPath('idyllic')

🐛 Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

  • Issue created by @sonam_sharma
  • Issue was unassigned.
  • Status changed to Needs work 11 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    The issue summary should always describe what should be fixed/changed. Neither the title nor screenshots are sufficient to describe what the issue is, even in the case a patch is provided.
    In the case of a bug, the description should also list the steps necessary to reproduce the issue, starting from when the module/theme is installed.

  • Status changed to Needs review 10 months ago
  • 🇮🇳India Abh1shek

    I have created a patch for this issue. Here are the steps I followed:

    1. Took clone from git version 1.0.x in drupal 10.1.2
    2. Installed and set the theme as default
    3. Installed latest bootstrap5 theme from composer
    3. Replaced the deprecated function drupal_get_path() with \Drupal::service('extension.list.theme')->getPath('idyllic')

    Now it is working fine. Please review.

  • Status changed to Needs work 10 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    The status is for the issue summary which, apart from quoting an error message, it does not say much on how to reproduce the issue. In any case, quoting an error message is never sufficient for a bug report.
    The issue summary must be updated.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -core_version_requirement: '^8.9 || ^9'
    +core_version_requirement: '^8.9 || ^9 || ^10'
    

    That change is also not correct: Drupal 8.9 does not have the extension.list.theme service and it still needs to use drupal_get_path(); this issue is not about making the module installable on Drupal 10.

  • 🇮🇳India Abh1shek

    Hello @apaderno,

    I wanted to inform you that I have made some revisions to the issue summary. I have taken care to provide a comprehensive description. However, I must admit that I'm a bit puzzled by your statement regarding Drupal 8.9. You mentioned that the extension.list.theme functionality is absent, and drupal_get_path still needs to be used. My experience differs, as I have successfully installed a theme on Drupal 8.9 and seamlessly replaced drupal_get_path with extension.list.theme. The theme is functioning impeccably in this context.

    Could you kindly offer some guidance on this matter? Your insights would be greatly appreciated. Thank you for your assistance.

Production build 0.69.0 2024