Problem/Motivation
Originally this issue was a question on standardizing on 'attributes_array' vs '#attributes' as attributes array keys in render arrays and preprocessors. Despite resolution in consistency via #1290694: Provide consistency for attributes and classes arrays provided by template_preprocess(), there are still some instances of attributes_array. For consistency sake, we should get rid of these
Proposed resolution
Convert/remove instances of attributes_array. Grep can find these.
Remaining tasks
Patch
User interface changes
None
API changes
None (That is, none not already accommodated by other issues).
Original report by effulgentsia
#1382350-18: [discussion] Theme/render system problems laid out some WTFs of our render/theme systems, and other comments on that issue echoed the desire for more consistency. This seems like an obvious one to fix.
Comment | File | Size | Author |
---|---|---|---|
#21 | interdiff.txt | 2.4 KB | Eric_A |
#21 | 1484704-21-replace-attributes_array.patch | 2.67 KB | Eric_A |
#16 | 1484704-16-replace-attributes_array.patch | 4.83 KB | Eric_A |
#12 | 1484704-12-replace-attributes_array.patch | 5.94 KB | joelpittet |
#12 | interdiff.txt | 1.09 KB | joelpittet |
Comments
Comment #1
pixelwhip CreditAttribution: pixelwhip commented+1 for $element['#attributes']
Comment #2
effulgentsia CreditAttribution: effulgentsia commentedSee also: #1290694: Provide consistency for attributes and classes arrays provided by template_preprocess(). This issue is different, but related.
Comment #3
c4rl CreditAttribution: c4rl commentedNow that #1290694: Provide consistency for attributes and classes arrays provided by template_preprocess() is committed, I am thinking that this is now a task to simply get rid of attributes_array instances since the new Attributes class applies.
A grep reveals the following:
Comment #4
c4rl CreditAttribution: c4rl commentedAdding novice tag, this should be relatively straightforward.
Comment #5
wiifmOkay here is my crack at this. Firstly a grep of the latest 8.x code:
And after patching:
As you can see, some instances of the word 'attributes_array' remain in the codebase, the first two seem correct to me, as it is simply the name of a temporary variable in tests. The last instance also looks like a harmless UI string, and is in tests.
Lets see what the test bot says
Comment #7
elvis2 CreditAttribution: elvis2 commentedVariable names were not changed (ie $attributes_array remained the same).
Comment #8
joelpittet@elvis2 #7 looks good but should be
['attributes']
not['#attributes']
These are the ones I found:
The system ones are taken care of at #1183042-93: Regression: Add WAI-ARIA roles to Core blocks
Comment #9
joelpittetI'll be re-rolling these once this is in:
Comment #10
joelpittetTried to apply #7 but it didn't apply anymore, so here is a re-roll.
Comment #12
joelpittetFixed the title attribute to not set an array.
Comment #13
elvis2 CreditAttribution: elvis2 commented@joelpittet Thanks for pointing the error out. I will fix it later this evening.
Comment #14
joelpittet#12 should be good to go. Could someone review/RTBC?
Comment #15
Eric_A CreditAttribution: Eric_A commentedI'm guessing the WAI-ARIA roles got into #10 and #12 by accident. Those are still being discussed in #1183042: Regression: Add WAI-ARIA roles to Core blocks where @alexpott and @webchick suggested adding a test.
@dawehner RTBC'ed the patch from #41 in #1843750: Convert views/templates/views-view-grid.tpl.php to twig so perhaps he'll do the same here when WAI-ARIA roles are out. :-)
Comment #16
Eric_A CreditAttribution: Eric_A commentedThis is #12 with the WAI-ARIA roles changes reverted.
Comment #17
tstoecklerI'm no @dawehner, but I feel comfortable RTBC'ing this.
One little thing stuck out at me:
For extra credit, this could be put into one-line.
I'll leave it to the committers (or whoever else) to decide, whether they deem that worthy of another re-roll.
Comment #18
alexpott#16: 1484704-16-replace-attributes_array.patch queued for re-testing.
Comment #20
joelpittetComment #21
Eric_A CreditAttribution: Eric_A commentedSo a couple of PHPTemplate to Twig conversion issues considered it their responsibility to partially fix this issue ;-)
Comment #23
Eric_A CreditAttribution: Eric_A commentedAnd removed the "Needs reroll" tag.
Comment #24
Eric_A CreditAttribution: Eric_A commentedEDIT: my patch applied just fine and my checks were done after applying it..
Ok, I just checked core/includes/theme.inc and it too has no instances of $attributes_array anymore. Me, I'm not going to check right now if every line was fixed in the exact same way as the patch here, but basically we're done here, I guess.EDIT: I also checked core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php. Same thing. Fixed by some other issue.Comment #25
Eric_A CreditAttribution: Eric_A commentedHm, then why did my patch in #21 apply locally...
(Yeah, just a testbot glitch here: FAILED: [[SimpleTest]]: [MySQL] Repository checkout: failed to checkout from [git://git.drupal.org/project/drupal.git].)
Comment #26
Eric_A CreditAttribution: Eric_A commented#21: 1484704-21-replace-attributes_array.patch queued for re-testing.
Comment #27
Eric_A CreditAttribution: Eric_A commentedWe're back to green and I'm setting this back to RTBC (see #17). To summarize: patch from #16 did not apply anymore because the 4 lines from views.theme.inc and views_ui.theme.inc were fixed in #1843772: Convert views/views_ui/templates/views-ui-display-tab-bucket.tpl.php to Twig, #1843774: Convert views/views_ui/templates/views-ui-display-tab-setting.tpl.php to Twig, #1843750: Convert views/templates/views-view-grid.tpl.php to twig and #1843766: Convert views/templates/views-view-table.tpl.php to twig. I reverted those changes here and the patch applied again. Then I added the bonus request from #17. The interdiff shows how trivial the changes are.
Comment #28
catchComment #29.0
(not verified) CreditAttribution: commentedIssue summary template