drupal_get_path() has been deprecated

Created on 24 June 2023, over 1 year ago
Updated 12 June 2024, 6 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 review

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia sonam_sharma

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

Merge Requests

Comments & Activities

  • Issue created by @sonam_sharma
  • Issue was unassigned.
  • Status changed to Needs work over 1 year 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 over 1 year 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 over 1 year 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.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia ravi kant Jaipur

    ravi kant โ†’ made their first commit to this issueโ€™s fork.

  • Merge request !4Resolved 'drupal_get_path()' issue โ†’ (Open) created by ravi kant
  • Status changed to Needs review 6 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia ravi kant Jaipur

    The patch is applying and issue is solving for me so creating MR.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    Right, it's the ExtensionPathResolver class that is missing in Drupal 8. The documentation for drupal_get_path() suggests using that class, but for what I can see the extension.list.theme service would work too.

    Yet, the ThemeExtensionList class is marked internal. Contributed modules and themes should not use that class, since it is an internal class.

Production build 0.71.5 2024