Problem/Motivation
From #1998648-53: "Administration pages language" user account setting should be hidden if not used
Some form elements in AccountForm are created only under certain conditions.
contrib' form_alters have to check for elements existence before modifying them.
This is a problem because
- the extra form_alters make performance worse?
- it is bad contributor developer experience (CX)
Postponed on 8.1.x per https://www.drupal.org/contribute/core/beta-changes
Proposed resolution
"standardize" them by using #access
Remaining tasks
- verify in the motivation section, why this is a problem.
- (an evaluation in #53) decide if this should be postponed per https://www.drupal.org/contribute/core/beta-changes
User interface changes
No. (The UI should be the same before and after. We should have screenshot to prove that.)
API changes
No.
Comment | File | Size | Author |
---|---|---|---|
#49 | interdiff-2058319-45-49.txt | 1.83 KB | quietone |
#49 | 2058319-accountform-cleanup-49.patch | 7.13 KB | quietone |
#45 | 2058319-accountform-cleanup-45.patch | 7.86 KB | quietone |
#42 | 2058319-accountform-cleanup-35.patch | 7.54 KB | quietone |
#39 | 2058319-accountform-cleanup-34.patch | 7.91 KB | quietone |
Comments
Comment #1
penyaskito#1998648: "Administration pages language" user account setting should be hidden if not used landed.
Comment #2
swentel CreditAttribution: swentel commentedIsn't this solved now that we have the form display screen ?
Comment #3
penyaskitoNot yet, the idea behind this issue was to move the if-else conditions in AccountFormController::form to the #access property on the form elements.
Comment #3.0
penyaskitotypos everywhere.
Comment #4
penyaskitoFirst attempt to clean-up the if-else structure, using #access instead.
Comment #5
penyaskitoComment #7
penyaskito$form['account']['pass'] should not be overridden. That if remains.
Comment #8
penyaskitoComment #10
penyaskitoOops... Missed a clause for checking only to validate the password when actually changing an existing user.
Comment #12
penyaskitoThe password fields were not correctly displayed when admin registering users.
Comment #13
penyaskitoComment #14
penyaskitoA security review will be helpful.
Comment #16
pcambraThe user/account comparison is used in several places, probably a variable would be useful
A comment here would be helpful
The same comparison is used for the if, access and required, is the if even needed?
Comment #17
penyaskitoHandled #16.1 and #16.2.
For the third point, probably we should revert the change.
Comment #19
penyaskitoReverted the change at #16.3.
Comment #20
dawehnerWe no longer have to use l() but can rely on the link generator.
Comment #21
penyaskitoRight, thanks!
Comment #23
dawehnerYou just need something like in that drupal unit test.
Comment #24
penyaskitoThanks! Green again.
Comment #25
dawehnernope!
whitespace all over the place.
This change doesn't seem to be related?
Do we really need this here? Afaik the router would rebuild itself is something requests it.
Comment #26
penyaskito#25.4: tried that, and the test didn't find "user.password".
Must be protected.
Comment #27
penyaskitoFixed those.
Comment #28
dawehnerWhat about point 4?
Comment #29
XanoWhy not use
#access
for this too?Comment #30
penyaskito@dawehner: Answered in #26:
#25.4: tried that, and the test didn't find "user.password".
@Xano: because it is creating an element with the same name of a previous one. I didn't want to rename because I guessed that if it is named the same is for a reason, but it's worth trying.
Comment #31
penyaskitoComment #32
penyaskitoComment #33
penyaskitoRe-uploaded last one with interdiff.
As renaming IMHO does not makes sense, I just moved that snippet so they are together, and alter the same array instead of creating a new one. Makes it more readable IMHO.
Maybe comments could be improved, suggestions welcome.
Comment #34
sunDo we have test coverage for the complex logic being touched here?
I authored
UserAccountFormFieldsTest
, but that only asserts the expected order of input elements (cf. #2191785: Password managers are identifying/storing wrong username field when creating a user account). — btw, not sure why the test suddenly needs to rebuild the router; a clean-up like this should not cause behavior changes.Comment #35
penyaskito@sun I think we have coverage for everything here, as any wrong change I did broke any or several tests.
About rebuilding the router, in #20 requested to use link generator with named routes instead of l () with a path. That's why we need to change that.
Comment #38
penyaskitoComment #39
quietone CreditAttribution: quietone commentedMy attempt at a reroll
Comment #40
quietone CreditAttribution: quietone commentedComment #42
quietone CreditAttribution: quietone commentedWell, that was an impressive number of fails. Here's an improvement.
Comment #44
quietone CreditAttribution: quietone commentedWell, that helped. But I've either completed messed this up or it needs someone with more knowledge than I currently have.
Comment #45
quietone CreditAttribution: quietone commentedThis should be better.
Comment #46
quietone CreditAttribution: quietone commentedComment #48
quietone CreditAttribution: quietone commentedThe exception has to do with making the link discussed in #20, #34 and #35. My patch keeps the original l(), but the same failure happens with getLinkGenerator as used by penyaskito.
$request_new = $this->getLinkGenerator()->generate($this->t('Request new password'), 'user.pass', array(), array('attributes' => array('title' => $this->t('Request new password via email.'))));
What method should be used to create the link, and then what to do about the test?
Comment #49
quietone CreditAttribution: quietone commentedThank you to YesCT and mpdonadio.
LinkGenerator is working and removed the the changes to /core/modules/user/src/Tests/UserAccountFormFieldsTest.php
Comment #50
quietone CreditAttribution: quietone commentedComment #51
penyaskitoAfter discussion between, quietone, alexpott and myself, we should define a textfield here, and the filter module should alter the form, avoiding the moduleExists calls.
Comment #52
quietone CreditAttribution: quietone commented@penyaskito Thanks for sorting that out. Just so you know I don't yet know how to implement what you suggest.
Comment #53
YesCT CreditAttribution: YesCT commentedupdated issue summary to try and specify why this is a problem.
we need to know so that we know if this should be postponed to 8.1.x per https://www.drupal.org/contribute/core/beta-changes
it looks like this is postponed to 8.1.x to me.
Comment #54
YesCT CreditAttribution: YesCT commentedthere are bunch of issue still open for 8.0.x, especially bugs... but here is a link to some usability things also
https://www.drupal.org/project/issues/search/drupal?project_issue_follow...
Comment #65
quietone CreditAttribution: quietone as a volunteer commentedNo longer postponded and looking at the current code this is still valid