Problem/Motivation

Theme functions have been deprecated since 8.0 in favour of Twig templates, and were properly deprecated for Drupal 10 in #3109480: Properly deprecate theme functions for Drupal 10, so any supporting code should be removed before Drupal 10.0.0-beta1.

The meta suggests grouping by API so I considered including all theme-related deprecations in here, but the documentation changes alone are quite big so this seemed enough to warrant its own issue.

Proposed resolution

Find all code that relates to theme functions and delete it.

Remaining tasks

  1. Wait for #3251854: [META] Requirements for tagging Drupal 10.0.0-alpha1
  2. Reviews / refinements.
  3. RTBC.

User interface changes

API changes

Theme functions will no longer be supported.

Data model changes

Release notes snippet

Comments

longwave created an issue. See original summary.

longwave’s picture

Status: Active » Needs review
StatusFileSize
new34.87 KB
longwave’s picture

Issue summary: View changes

Status: Needs review » Needs work

The last submitted patch, 2: 3097889.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

longwave’s picture

Status: Needs work » Needs review
StatusFileSize
new45.18 KB
new13.6 KB
longwave’s picture

StatusFileSize
new45.39 KB
new13.8 KB

Missed a file

longwave’s picture

Interesting that #5 passed with an empty template file. I think this is because \Drupal\Tests\system\Kernel\Theme\ThemeTest::testThemeDataTypes() only cares about the types and not the actual output.

longwave’s picture

Status: Needs review » Needs work

common_test.module and theme_suggestions_test.module still contain some theme functions that need removing. Also interesting that the tests that use these still pass!

views.module also looks like it has some support for theme functions as well.

longwave’s picture

Status: Needs work » Needs review
StatusFileSize
new50.7 KB
new5.72 KB

Addressed #8.

senthilmohith’s picture

Assigned: Unassigned » senthilmohith
senthilmohith’s picture

Assigned: senthilmohith » Unassigned
Issue tags: +#ContributionWeekend2020
StatusFileSize
new364.48 KB

I have reviewed the patch #9 and it's working as we expected in the 9.0.x version. Most of the deprecated theme functions have been removed. Please refer to the attached screens.

wim leers’s picture

+++ b/core/includes/theme.inc
@@ -122,65 +122,6 @@ function drupal_theme_rebuild() {
-/**
- * Allows themes and/or theme engines to discover overridden theme functions.
- *
- * @param array $cache
- *   The existing cache of theme hooks to test against.
- * @param array $prefixes
- *   An array of prefixes to test, in reverse order of importance.
- *
- * @return array
- *   The functions found, suitable for returning from hook_theme;
- */
-function drupal_find_theme_functions($cache, $prefixes) {

I hate to say this but … it looks like this wasn't deprecated? 🤔


I think this needs review from a theme subsystem maintainer.

longwave’s picture

It might not have been explicitly deprecated but theme functions themselves have not been used for >5 years now so I don't see how it is of use to anyone.

lauriii’s picture

It seems like theme functions are still being used by contrib projects: http://grep.xnddx.ru/search?text=function%20theme_&filename=. 😳 Based on this, it seems risky to remove theme functions without first triggering proper deprecation errors. 😩 In my opinion, we should schedule the removal to Drupal 10. 😭

wim leers’s picture

#14 is exactly what I feared, but wanted a theme system maintainer to give their more informed stance. Unfortunate. But pragmatic.

longwave’s picture

The original deprecation was done in #2576881: Deprecate theme functions for removal before Drupal 9 (docs only) long before we started using trigger_error() and friends to notify developers when they use deprecated code. There is some discussion of how we should notify developers in that issue but it looks like the suggested followup to actually add deprecations was never created.

So I guess the next step is to create that followup now, get modern deprecation messages committed to 9.1.x for removal in 10.x, and then postpone this issue until 10.x?

lauriii’s picture

Issue tags: +Needs followup

So I guess the next step is to create that followup now, get modern deprecation messages committed to 9.1.x for removal in 10.x, and then postpone this issue until 10.x?

These seem like the correct next steps to me. Adding a tag for creating the follow-up to try to ensure that the follow-up gets filed this time 😅

longwave’s picture

Version: 9.0.x-dev » 9.1.x-dev
Status: Needs review » Postponed
Issue tags: -Needs followup
lauriii’s picture

Awesome, thank you @longwave!

miro_dietiker’s picture

Issue tags: -#ContributionWeekend2020 +ContributionWeekend2020

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

eric_a’s picture

Version: 9.2.x-dev » 10.0.x-dev
Status: Postponed » Needs review
eric_a’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
eric_a’s picture

Issue summary: View changes
anushrikumari’s picture

Rerolled for 9.2.x, as patch #9 doesn't apply for the same

longwave’s picture

Status: Needs work » Postponed
Issue tags: -Needs reroll

This can't be committed until 10.x opens so there isn't really a need to reroll this until then.

gábor hojtsy’s picture

Adding the proper parent.

andypost’s picture

Status: Postponed » Active
paulocs’s picture

Assigned: Unassigned » paulocs

I'm working on a re-row.

paulocs’s picture

Assigned: paulocs » Unassigned
StatusFileSize
new30.96 KB

Only a re-row for now.

andypost’s picture

Status: Active » Needs review
longwave’s picture

StatusFileSize
new29.59 KB
new2.46 KB

Few minor fixes against the reroll.

longwave’s picture

StatusFileSize
new32.67 KB
new3.53 KB

Removed another few docs comments that still refer to theme functions.

    // In some cases, a template implementation may not have had
    // template_preprocess() run (for example, if the default implementation
    // is a function, but a template overrides that default implementation).

Not sure what to do about this sentence or whether this still applies - maybe this can be refactored away?

The last submitted patch, 31: 3097889-31.patch, failed testing. View results

longwave’s picture

StatusFileSize
new55.31 KB
new22.64 KB

Remove legacy test classes and modules for testing theme functions.

dww’s picture

Title: Remove deprecated theme functions » [PP-1] Remove deprecated theme functions
Issue summary: View changes
Status: Needs review » Postponed
Related issues: +#3251854: [META] Requirements for tagging Drupal 10.0.0-alpha1

Per @catch at #3244802-8: Remove BC layers in entity system, any deprecation removal issue should be on hold until after 10.0.0-alpha1 is tagged.

Thanks!
-Derek

andypost’s picture

Faced in #3260778-5: Remove deprecated code from bootstrap.inc more work needed for issue to remove @todo to it

andypost’s picture

Title: [PP-1] Remove deprecated theme functions » Remove deprecated theme functions
Status: Postponed » Needs review
catch’s picture

Ironically, this might break upgrade_status...

http://grep.xnddx.ru/search?text=drupal_find_theme_functions&filename=

I think we need a 9.4.x follow-up to deprecate (or mark internal?) drupal_find_theme_functions() for removal in Drupal 10. But since upgrade_status is the only usage in contrib and custom use seems extremely unlikely, seems OK to go ahead here.

andypost’s picture

Status: Needs review » Reviewed & tested by the community

Upgrade status could use follow-up to and drupal_find_theme_functions() ++ as well

catch’s picture

Opened the follow-up for drupal_find_theme_functions() #3262500: Mark drupal_find_theme_functions() @internal in Drupal 9 in 9.4.x

I was about to open the follow-up for Upgrade Status, but the 8.3.x branch doesn't have this usage, only the 8.2.x branch, so it's actually fine.

gábor hojtsy’s picture

This reminds me Upgrade Status is not even Drupal 10 alpha1 compatible (facepalm). Either way, compatibility with versions later than alpha1 is not intended until it would check for Drupal 11 compatibility :D Opened #3262488: Make Upgrade Status compatible with Drupal 10 in Upgrade Status.

That said, Upgrade Status may be able to just include a copy of this global function I think? The underlying getPrefixGroupedUserFunctions() did not seem to have been modified? Actually, I think we should just make that check optional. Opened #3262503: Don't attempt to use drupal_find_theme_functions() on Drupal 10 in Upgrade Status.

gábor hojtsy’s picture

@catch: 8.x-3.x of Upgrade Status also uses drupal_find_theme_functions() in ThemeFunctionDeprecationAnalyzer, so it is definitely still there. So I think #3262503: Don't attempt to use drupal_find_theme_functions() on Drupal 10 is valid to fix then.

catch’s picture

@Gábor Hojtsy ahh thanks, maybe http://grep.xnddx.ru just doesn't have the 3.x branch yet, glad I opened the issue after all.

  • catch committed 6ad38cd on 10.0.x
    Issue #3097889 by longwave, paulocs, anushrikumari, SenthilMohith,...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 10.0.x, thanks!

Very glad we don't have to keep this around for another release.

andypost’s picture

Status: Fixed » Closed (fixed)

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