Change the code to avoid using functions, methods, constants, and services that have been deprecated in Drupal 9 and removed from Drupal 10

Created on 31 May 2023, over 1 year ago
Updated 8 November 2023, about 1 year ago

The module uses some functions and constants which have been deprecated in Drupal 8/9 and removed in Drupal 10.

  • drupal_get_path() has been deprecated in Drupal 9.3 and removed from Drupal 10. \Drupal\Core\Extension\ExtensionPathResolver::getPath() must be instead used.
  • drupal_get_filename() has been deprecated in Drupal 9.3 and removed from Drupal 10. \Drupal\Core\Extension\ExtensionPathResolver::getPathname() must be instead used.
  • file_create_url() has been deprecated in Drupal 9.3 and removed from Drupal 10. \Drupal\Core\File\FileUrlGeneratorInterface::generateAbsoluteString() must be instead used.
  • file_load() has been deprecated in Drupal 8 and removed from Drupal 9. \Drupal\file\Entity\File::load() must be instead used.
  • FILE_STATUS_PERMANENT has been deprecated in Drupal 9.3 and removed from Drupal 10. \Drupal\file\FileInterface::setPermanent() must be instead used.
๐Ÿ“Œ Task
Status

Needs review

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia Prachi6824

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

Comments & Activities

  • Issue created by @Prachi6824
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sundaravigneshP

    I have also face this same issue after cloned Coffee Zymphonies Theme like undefined function drupal_get_path().

    Error: Call to undefined function drupal_get_path() in coffee_zymphonies_theme_get_slider_content() (line 176 of themes/contrib/coffee_zymphonies_theme/coffee_zymphonies_theme.theme).

    Please open the coffee_zymphonies_theme.theme file in the path of (themes/contrib/coffee_zymphonies_theme/city_zymphonies_theme.theme ).
    so please add the drupal_get_path() after end of this coffee_zymphonies_theme_get_slider_content function.

    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;
    }
    }

    Its working fine for me,

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    Since the theme uses core_version_requirement: ^8 || ^9 || ^10, simply replacing the function call with a call to a service method is not sufficient to resolve the bug, as Drupal 8.9 does not implement that service.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia rushiraval

    Rushikesh Raval โ†’ made their first commit to this issueโ€™s fork.

  • @rushikesh-raval opened merge request.
  • Status changed to Needs review about 1 year ago
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    In that case, the issue summary must be updated to describe all the necessary changes, and in which Drupal version the function, method, costant, or service has been deprecated.

  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • The following files also have a dependency on classy theme, which is removed from Drupal10 core.

    Most call {{ attach_library('classy/file') }}, but I haven't checked them all:

    web/themes/contrib/coffee_zymphonies_theme/templates/field/file-link.html.twig
    web/themes/contrib/coffee_zymphonies_theme/templates/content/node.html.twig
    web/themes/contrib/coffee_zymphonies_theme/templates/content/search-result.html.twig
    web/themes/contrib/coffee_zymphonies_theme/templates/content/comment.html.twig
    web/themes/contrib/coffee_zymphonies_theme/templates/dataset/forums.html.twig
    web/themes/contrib/coffee_zymphonies_theme/templates/navigation/book-navigation.html.twig
    web/themes/contrib/coffee_zymphonies_theme/templates/content-edit/image-widget.html.twig
    web/themes/contrib/coffee_zymphonies_theme/templates/content-edit/file-managed-file.html.twig
    web/themes/contrib/coffee_zymphonies_theme/templates/misc/status-messages.html.twig

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

    That will need a different issue.

Production build 0.71.5 2024