Follow-up of #3128409: Drupal 9 compatibilities report

Problem/Motivation

Theme functions are deprecated in Drupal 8, but in Drupal 9 the deprecation warnings are no longer silenced #3117330: Trigger errors in deprecated theme functions, meaning that the following warning appears due to the theme function theme_name_item_list:

User deprecated function: Theme functions are deprecated in drupal:8.0.0 and are removed from drupal:10.0.0. Use Twig templates instead of theme_name_item_list(). See https://www.drupal.org/node/1831138 in Drupal\Core\Theme\Registry->processExtension() (line 498 of core/lib/Drupal/Core/Theme/Registry.php).

Steps to reproduce

This happens when `Drupal\Core\Theme\Registry::processExtension` is run (eg during database updates).

It would be great if this could be fixed.

Proposed resolution

Convert theme functions to twig templates.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#5 3168948-5.patch8.21 KBnikathone

Comments

JeremySkinner created an issue. See original summary.

jeremyskinner’s picture

Issue summary: View changes
megachriz’s picture

Issue summary: View changes

I updated the issue summary, linked to the issue this is a follow-up to and very briefly described the proposed resolution.

jasonluttrell’s picture

For anyone else wondering, the theme-related error message can be silenced with a quick/temporary patch:

diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php
index 094780a10..15c88b029 100644
--- a/core/lib/Drupal/Core/Theme/Registry.php
+++ b/core/lib/Drupal/Core/Theme/Registry.php
@@ -495,7 +495,7 @@ protected function processExtension(array &$cache, $name, $type, $theme, $path)
         // if the theme hook specifies a function callback instead, check to
         // ensure the function actually exists.
         if (isset($info['function'])) {
-          trigger_error(sprintf('Theme functions are deprecated in drupal:8.0.0 and are removed from drupal:10.0.0. Use Twig templates instead of %s(). See https://www.drupal.org/node/1831138', $info['function']), E_USER_DEPRECATED);
+          @trigger_error(sprintf('Theme functions are deprecated in drupal:8.0.0 and are removed from drupal:10.0.0. Use Twig templates instead of %s(). See https://www.drupal.org/node/1831138', $info['function']), E_USER_DEPRECATED);
           if (!function_exists($info['function'])) {
             throw new \BadFunctionCallException(sprintf(
               'Theme hook "%s" refers to a theme function callback that does not exist: "%s"',

Hopefully, someone will fix this soon?

nikathone’s picture

Title: theme_name_item_list causes a deprecation warning in Drupal 9 » Remove theme functions deprecated in Drupal 9
StatusFileSize
new8.21 KB

Updated the title to match what the patch is doing which is to remove all the theme functions deprecated in Drupal 8 and are going to be removed in Drupal 10.

nikathone’s picture

Status: Active » Needs review
mrshowerman’s picture

#5 works for me, in terms of getting rid of the annoying deprecation notice. Thanks!

jeremyskinner’s picture

Works well for me too, thanks!

  • nkoporec committed 5900906 on 8.x-1.x authored by nikathone
    Issue #3168948 by nikathone, JeremySkinner, mrshowerman: Remove theme...
nkoporec’s picture

Status: Needs review » Fixed

comitted, thanks !

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.