Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Theme functions were removed in 8.x, but not correctly deprecated. In 9.x, they are deprecated, but with a nasty warning. Let's convert them to proper twig templates.
Steps to reproduce
Enable the module on Drupal 9, ensure warnings are visible on your site, view any page (that displays warnings) after a cache rebuild.
Comment | File | Size | Author |
---|---|---|---|
#8 | 3183780-8.patch | 3.59 KB | gnuget |
| |||
#8 | 3183780-2-8-interdiff.txt | 751 bytes | gnuget |
#7 | filefield_sources-twigify-3183780-7.patch | 4.11 KB | rivimey |
#3 | 3183780-2-problems.png | 8.12 KB | Bohus Ulrych |
#2 | filefield_sources-twigify-3183780-2.patch | 3.77 KB | douggreen |
|
Comments
Comment #2
douggreen CreditAttribution: douggreen commentedAttached patch converts the theme functions to twig templates. I'm unfamiliar with this module, so this needs thorough review. I'm particularly concerned with using
|raw
in the element template, as this might have security implications.Comment #3
Bohus UlrychHi,
FYI this patch removed warnings, but also broke functionality.
No error on the page, in watchdog or console log.
Tested with D9.1.5 and module version 8.x-1.x-dev updated 15 Jan 2021 at 18:15 UTC
Thanks
Comment #4
Bohus UlrychHello @douggreen
I believe I've found where is the issue.
In you patch you are replacing
- return '<div class="filefield-sources-list">' . implode(' | ', $links) . '</div>';
with
+<div class="fieldfield-sources-list">
You see? There is different class name filefield-sources-list VS fieldfield-sources-list
And this class name is then used in JavaScript file, with wrong class name it doesn't work.
After correcting this it works.
Comment #5
rivimeyI've made a new patch, based on current HEAD, that implements the change in #4.
Comment #7
rivimeyOops. sorry, let me format that again..
Comment #8
gnugetHere a new version of #2 with the changes suggested at #4.
This is looking good.
I will give it a few days and then I will commit it.
Thanks!!!
Comment #9
Bohus UlrychTested (D9.1.7), works. Thanks
Comment #11
gnugetComment #13
aiphesI'm facing off this issue with
File Field Sources (filefield_sources) 8.x-1.0-alpha4
on D9.2.7.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_filefield_sources_list(). See https://www.drupal.org/node/1831138 in Drupal\Core\Theme\Registry->processExtension() (line 498 of core/lib/Drupal/Core/Theme/Registry.php).
which version do I use to avoid this warning ?
thanks