This issue has novice tasks. If you are an experienced core developer and have multiple commit mentions, please review novices' work on these tasks rather than doing them yourself. Feedback from experienced contributors is valued.

Problem/Motivation

Now that theme_field() is gone (or will be gone for good after #2226233: Redo changes from field.module to Twig conversion issue that were clobbered is complete) we can remove some unneeded code from template_preprocess_field():

  // The default theme implementation for fields is a function.
  // template_preprocess() (which initializes the attributes, title_attributes,
  // and content_attributes arrays) does not run for theme function
  // implementations. Additionally, Attribute objects for the three variables
  // below only get instantiated for template file implementations, and we need
  // Attribute objects for printing in both theme functions and template files.
  // For best performance, we only instantiate Attribute objects when needed.
  $variables['attributes'] = isset($variables['attributes']) ? new Attribute($variables['attributes']) : clone $default_attributes;
  $variables['title_attributes'] = isset($variables['title_attributes']) ? new Attribute($variables['title_attributes']) : clone($default_attributes);
  $variables['content_attributes'] = isset($variables['content_attributes']) ? new Attribute($variables['content_attributes']) : clone($default_attributes);

Proposed resolution

Remove the code.

Remaining tasks

User interface changes

n/a

API changes

n/a

Files: 
CommentFileSizeAuthor
#2 remove_unneeded_code_from_template_preprocess_field-2226805-2.patch1.4 KBChandeepKhosa
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 69,642 pass(es). View

Comments

ChandeepKhosa’s picture

Assigned: Unassigned » ChandeepKhosa

..

ChandeepKhosa’s picture

FileSize
1.4 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 69,642 pass(es). View

..

ChandeepKhosa’s picture

Assigned: ChandeepKhosa » Unassigned
Status: Active » Needs review

..

Status: Needs review » Needs work
Cottser’s picture

Assigned: Unassigned » Cottser
Status: Needs work » Postponed

This will probably fail until #2226233: Redo changes from field.module to Twig conversion issue that were clobbered gets in. Assigning to myself so I can keep track of it. Thanks @ChandeepKhosa!

ChandeepKhosa’s picture

OK cool, glad to help out with my first patch :)

Cottser’s picture

Actually it looks like a theme function snuck in that we'll need to convert before this will pass, theme_field__node__title():

#2231505: Convert theme_field__node__title() to Twig

So keeping at postponed.

Cottser’s picture

Status: Postponed » Needs review
Cottser’s picture

Cottser’s picture

Assigned: Cottser » Unassigned
Status: Needs review » Reviewed & tested by the community

Great, this is good to go now.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Yay, less code. :)

Committed and pushed to 8.x. Thanks!

  • Commit 8c5ae65 on 8.x by webchick:
    Issue #2226805 by ChandeepKhosa | Cottser: Remove unneeded code from...

Status: Fixed » Closed (fixed)

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