Task

Convert theme_ functions to Twig templates.

Remaining

  • theme_ function -> Twig conversions (and preprocess function additions or changes) moved over from the existing conversion issue
  • Patch review
Theme function name Conversion status
theme_theme_test converted
theme_theme_test_foo converted

#1898458: theme_test.module - Convert PHPTemplate templates to Twig
#1757550: [Meta] Convert core theme functions to Twig templates
#1987510: [meta] Convert all core *.tpl.php templates to Twig as singular patch

Files: 
CommentFileSizeAuthor
#38 interdiff.txt811 bytesjoelpittet
#38 1987414-38-twig-theme_test.patch3.26 KBjoelpittet
PASSED: [[SimpleTest]]: [MySQL] 58,730 pass(es). View
#36 1987414-36-twig-theme_test.patch3.9 KBjoelpittet
PASSED: [[SimpleTest]]: [MySQL] 58,778 pass(es). View
#36 interdiff.txt830 bytesjoelpittet
#32 theme-test-twig-conversion-1987414-32.patch2.9 KBchipway
PASSED: [[SimpleTest]]: [MySQL] 58,871 pass(es). View
#32 interdiff.txt485 byteschipway
#30 theme-test-twig-conversion-1987414-29.patch2.93 KBpplantinga
PASSED: [[SimpleTest]]: [MySQL] 58,925 pass(es). View
#20 interdiff-1987414-16-18.txt1.04 KBmdrummond
#18 theme-test-twig-conversion-1987414-18.patch4.25 KBmdrummond
PASSED: [[SimpleTest]]: [MySQL] 58,537 pass(es). View
#16 1987414-16.patch4.32 KBpplantinga
PASSED: [[SimpleTest]]: [MySQL] 57,190 pass(es). View
#12 1987414-12.patch3.35 KBSean Charles
FAILED: [[SimpleTest]]: [MySQL] 57,149 pass(es), 2 fail(s), and 0 exception(s). View
#3 1987414-3.patch3.31 KBwidukind
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1987414-3.patch. Unable to apply patch. See the log in the details link for more information. View

Comments

Cottser’s picture

Issue summary: View changes

Updated issue summary.

c4rl’s picture

Title: theme_test.module - Convert PHPTemplate templates to Twig » theme_test.module - Convert theme_ functions to Twig

Per #1757550-44: [Meta] Convert core theme functions to Twig templates, retitling to indicate this issue applies to theme_ functions rather than templates. See #1898458: theme_test.module - Convert PHPTemplate templates to Twig Assigned to: widukind for template conversion.

c4rl’s picture

Issue summary: View changes

Updated issue summary.

widukind’s picture

Assigned: Unassigned » widukind
widukind’s picture

Status: Active » Needs work
FileSize
3.31 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1987414-3.patch. Unable to apply patch. See the log in the details link for more information. View
widukind’s picture

Status: Needs work » Needs review
widukind’s picture

Issue summary: View changes

List of functions

Cottser’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, thanks @widukind!

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs profiling
widukind’s picture

Assigned: widukind » Unassigned
Issue tags: -Needs profiling
widukind’s picture

Issue tags: +Needs profiling

re-tagged with "Needs profiling"

minneapolisdan’s picture

Status: Needs work » Needs review
Issue tags: -Needs profiling, -Twig

#3: 1987414-3.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +Needs profiling, +Twig

The last submitted patch, 1987414-3.patch, failed testing.

Anonymous’s picture

Assigned: Unassigned »

Working on this during the Portland sprint.

Sean Charles’s picture

Assigned: » Unassigned
Status: Needs work » Needs review
FileSize
3.35 KB
FAILED: [[SimpleTest]]: [MySQL] 57,149 pass(es), 2 fail(s), and 0 exception(s). View

Rerolled

OpenChimp’s picture

profiling this now.. hopefully the patch passes tests

OpenChimp’s picture

Issue tags: -Needs profiling

Profiling looks good so long as the patch passes the tests:

=== 8.x..8.x compared (519ffea2643cf..519fff787bd4d):

ct : 40,580|40,580|0|0.0%
wt : 377,639|377,895|256|0.1%
cpu : 334,533|335,159|626|0.2%
mu : 50,206,616|50,206,616|0|0.0%
pmu : 50,271,728|50,271,728|0|0.0%

Profiler output

=== 8.x..1987414 compared (519ffea2643cf..519fffa9aa250):

ct : 40,580|40,580|0|0.0%
wt : 377,639|378,267|628|0.2%
cpu : 334,533|335,045|512|0.2%
mu : 50,206,616|50,206,712|96|0.0%
pmu : 50,271,728|50,272,256|528|0.0%

Profiler output

---
ct = function calls, wt = wall time, cpu = cpu time used, mu = memory usage, pmu = peak memory usage
The registry has been rebuilt. [success]
'all' cache was cleared in self

Anonymous’s picture

Status: Needs review » Needs work
Issue tags: +Needs profiling
pplantinga’s picture

Status: Needs work » Needs review
FileSize
4.32 KB
PASSED: [[SimpleTest]]: [MySQL] 57,190 pass(es). View

Reroll + fix errors: templates add a newline at the end.

Cottser’s picture

Status: Needs review » Needs work
Issue tags: -Needs profiling +Novice

Thanks @pplantinga! I don't really think this particular patch should be held up on profiling :)

+++ b/core/modules/system/tests/modules/theme_test/templates/theme-test-foo.html.twig
@@ -0,0 +1,14 @@
+ * @see template_preprocess()

+++ b/core/modules/system/tests/modules/theme_test/templates/theme-test.html.twig
@@ -0,0 +1,15 @@
+ * @see template_preprocess()

For now, let's remove these lines per #2013094: [policy adopted, patch needed] Stop saying '@see template_preprocess()' in every twig file.

mdrummond’s picture

FileSize
4.25 KB
PASSED: [[SimpleTest]]: [MySQL] 58,537 pass(es). View

Here is a revised patch with the change suggested in #17.

mdrummond’s picture

Status: Needs work » Needs review

Changing to needs review. Come hither, Testbot!

mdrummond’s picture

FileSize
1.04 KB

Here's an interdiff for the change in #18.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice

Thanks @mdrummond!

This looks good, profiling looks good. #14

RTBC:)

Cottser’s picture

Profiling results are not correct (there should be more function calls, thanks @OpenChimp for trying though!) but I really don't think this one needs profiling. Thanks @mdrummond for the patch tweaks.

Eric_A’s picture

Status: Reviewed & tested by the community » Needs work

This is a conversion issue. Why would it be OK to just change output and tests without any discussion? I'd say it's probably best to not change output at all in this issue and just fix the template.

Cottser’s picture

The alternatives within scope here that I can think of:

@Eric_A, we have adjusted for whitespace in other tests as part of #1757550: [Meta] Convert core theme functions to Twig templates and #1987510: [meta] Convert all core *.tpl.php templates to Twig as singular patch, so this is nothing new… I'm fine with whatever approach is taken though.

joelpittet’s picture

I'm a fan of the {# Comment control trick #} because it's got relatively low processing to do vs spaceless (which is doing the same thing + removing whitespace inside).

I'd like to recommend we use the comment trick to fix all twig templates with this EOF newline character issue. @Cottser, we can discuss this more later but maybe I should add that to Twig Coding Standards http://drupal.org/node/1823416?

joelpittet’s picture

Oh yeah and thanks @Cottser for catching the profiling results were off.

Cottser’s picture

Issue tags: +Novice, +Needs reroll

So this needs a reroll and should be updated to remove the test changes and use the dummy comment at the end of the template to remove the extra newline.

thomas.fleming’s picture

Assigned: Unassigned » thomas.fleming
thomas.fleming’s picture

Assigned: thomas.fleming » Unassigned
pplantinga’s picture

Status: Needs work » Needs review
FileSize
2.93 KB
PASSED: [[SimpleTest]]: [MySQL] 58,925 pass(es). View

How about this?

Cottser’s picture

Issue tags: -Needs reroll

Thank you very much @pplantinga :)

A few of us (myself, @joelpittet, @Sean Charles) discussed changing tests vs. working around the whitespace, and we concluded that adding this dummy comment (or adding spaceless tags) to remove the extra newline is more confusing and not practical, especially in this case.
I would rather keep our core templates clean, lean and mean than complicate them to fit within the bounds of existing tests.

The addded newline is a natural result of the conversion process, since we are moving from a theme function (PHP function concatenating strings) to a template file (which needs a newline at EOF for Git reasons).

So at this time I think the best way forward with this issue and similar issues is to just change the test to add the newline (or make other whitespace adjustments as needed) for the reasons stated above.

chipway’s picture

FileSize
485 bytes
2.9 KB
PASSED: [[SimpleTest]]: [MySQL] 58,871 pass(es). View

Remove white space comment in theme-test-foo.html.twig.

Joel told to do this.

pplantinga’s picture

Looks like it works without changing tests? Cool.

Do we still need profiling?

Cottser’s picture

Status: Needs review » Needs work

Thanks! We need to remove theme_theme_test_foo(). And likely update the tests as a result. I ran Drupal\system\Tests\Theme\ThemeTest locally and did get 1 fail and 1 exception.

joelpittet’s picture

Status: Needs work » Needs review
joelpittet’s picture

Issue tags: -Novice
FileSize
830 bytes
3.9 KB
PASSED: [[SimpleTest]]: [MySQL] 58,778 pass(es). View

@Cottser ran the test locally without a fail/exception Was that through the UI or CLI?

Attached is that function removed.

Cottser’s picture

Status: Needs review » Needs work

It was through the UI, but testbot likes this so we should be good :) Just need to remove the rdf-metadata.html.twig template from the patch.

joelpittet’s picture

Status: Needs work » Needs review
FileSize
3.26 KB
PASSED: [[SimpleTest]]: [MySQL] 58,730 pass(es). View
811 bytes

Whoops, thanks for spotting the extra sneaky file.

Status: Needs review » Needs work
Issue tags: -Twig

The last submitted patch, 1987414-38-twig-theme_test.patch, failed testing.

Cottser’s picture

Status: Needs work » Needs review
Issue tags: +Twig

#38: 1987414-38-twig-theme_test.patch queued for re-testing.

pplantinga’s picture

Status: Needs review » Reviewed & tested by the community

Looks good

webchick’s picture

Status: Reviewed & tested by the community » Needs review

Wellll, hold up now.

We're still going to have some theme functions in D8 at the point it ships, in a few areas where performance are concerned. Correct?

If so, then I don't think we can convert (at least all of) these tests, because we still need test coverage to ensure theme functions work. This test module already has coverage for template files, so it seems these theme functions are deliberately theme functions.

Or am I missing a cluestick?

Cottser’s picture

Status: Needs review » Postponed

Yeah, I'd thought about that as well @webchick and it's a great point. Postponing for now and if we are somehow able to get rid of all theme functions before release then we can work on this again.

Cottser’s picture

Issue summary: View changes

Updated issue summary.

Cottser’s picture

joelpittet’s picture

Version: 8.0.x-dev » 9.x-dev
Status: Postponed » Active

We will get the functions out before 8.0.x but we will need to keep this test in for posterity until 9.0.x

Cottser’s picture

Status: Active » Postponed

But not yet.

catch’s picture

Shouldn't we just be removing the tests here along with the theme function functionality?

If we need to convert the theme function to a template, that suggests we're missing coverage elsewhere and could be done in 8.1.x.

catch’s picture

Title: theme_test.module - Convert theme_ functions to Twig » Remove test coverage for theme functions
Issue tags: +Needs issue summary update

Re-titling for now.

joelpittet’s picture

@catch Yes, if this is for 9.x then removing the test coverage would appropriate.

catch’s picture

Status: Postponed » Closed (duplicate)

Marking this as duplicate of #2716163: [meta] Remove all the deprecations. When we remove the bc layer for theme functions, these tests will break and we can remove them.