Call to an undefined function drupal_get_path()

Created on 2 June 2023, over 1 year ago
Updated 1 November 2023, about 1 year ago

Problem/Motivation

drupal_get_path() has been deprecated in favor of extension listing services.

Steps to reproduce

Remove Drupal_get_path() is deprecated in Drupal:9.3.0 and also removed from Drupal:10.0.0. Use \Drupal::service('extension.list.theme')->getPath('theme_name') instead.

Thanks!

🐛 Bug report
Status

Closed: duplicate

Version

1.0

Component

Code

Created by

🇮🇳India Harshita mehra

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Harshita mehra
  • 🇮🇳India sundaravigneshP

    I have also face the same issue, after install city_zymphonies_theme & i have solution to fix this issue.
    Please open the city_zymphonies_theme.theme file in the path of ( themes/contrib/city_zymphonies_theme/city_zymphonies_theme.theme )
    In the line 126 they have mention the drupal_get_path function theme of city_zymphonies_theme. so please add the drupal_get_path() after end of this city_zymphonies_theme_get_slider_content function.

    Here is this drupal_get_path() :

    function drupal_get_path($type, $name) {
    /**
    drupal_get_path('module', 'node') \Drupal::service('extension.list.module')->getPath('node')
    drupal_get_path('theme', 'seven') \Drupal::service('extension.list.theme')->getPath('seven')
    drupal_get_path('profile', 'standard') \Drupal::service('extension.list.profile')->getPath('standard')
    */
    switch ($type) {
    case 'module':
    return \Drupal::service('extension.list.module')->getPath($name);
    break;
    case 'theme':
    return \Drupal::service('extension.list.theme')->getPath($name);
    break;
    case 'profile':
    return \Drupal::service('extension.list.profile')->getPath($name);
    break;
    return false;
    }
    }

    After add this drupal_get_path() function, drush cr & check.

  • Status changed to Active about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Since there is no available patch/MR, the status is still Active.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Since the theme uses core_version_requirement: ^8 || ^9 || ^10, the solution cannot be simply to use the service that replaces that function, as the service is not defined in Drupal 8.

  • Assigned to shiv_yadav
  • @shiv_yadav opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India shiv_yadav

    Hello @Harshita mehna, I have fixed issue created MR.
    please review & retest it.
    Thanks

  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    See my previous comment.

  • 🇮🇳India shiv_yadav

    Hello apaderno, I create MR for D9 & D10.
    Thanks

  • Status changed to Needs review about 1 year ago
  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Yet, the MR does not correctly fix the issue.
    Since the theme is marked as compatible with Drupal 8, either the fix works for Drupal 8 too, or the theme is not anymore compatible with Drupal 8 and must be marked as not compatible with Drupal 8.

  • Status changed to Closed: duplicate about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Let's use a single issue, as both the issues need to change the minimum required Drupal version.

Production build 0.71.5 2024