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
Comments
Comment #1
chandeepkhosa commented..
Comment #2
chandeepkhosa commented..
Comment #3
chandeepkhosa commented..
Comment #5
star-szrThis 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!
Comment #6
chandeepkhosa commentedOK cool, glad to help out with my first patch :)
Comment #7
star-szrActually 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.
Comment #8
star-szr#2231505: Convert theme_field__node__title() to Twig is in, this should work now :)
Comment #9
star-szr2: remove_unneeded_code_from_template_preprocess_field-2226805-2.patch queued for re-testing.
Comment #10
star-szrGreat, this is good to go now.
Comment #11
webchickYay, less code. :)
Committed and pushed to 8.x. Thanks!