AccountForm clean-up

Created on 5 August 2013, almost 12 years ago
Updated 29 May 2025, about 2 months ago

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

User interface changes

No. (The UI should be the same before and after. We should have screenshot to prove that.)

API changes

No.

๐Ÿ“Œ Task
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component

user.module

Created by

๐Ÿ‡ช๐Ÿ‡ธSpain penyaskito Seville ๐Ÿ’ƒ, Spain ๐Ÿ‡ช๐Ÿ‡ธ, UTC+2 ๐Ÿ‡ช๐Ÿ‡บ

Live updates comments and jobs are added and updated live.
  • API clean-up

    Refactors an existing API or subsystem for consistency, performance, modularization, flexibility, third-party integration, etc. May imply an API change. Frequently used during the Code Slush phase of the release cycle.

  • Security

    It is used for security vulnerabilities which do not need a security advisory. For example, security issues in projects which do not have security advisory coverage, or forward-porting a change already disclosed in a security advisory. See Drupalโ€™s security advisory policy for details. Be careful publicly disclosing security vulnerabilities! Use the โ€œReport a security vulnerabilityโ€ link in the project pageโ€™s sidebar. See how to report a security issue for details.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • Merge request !12270Adapt patch from comment 49 โ†’ (Open) created by prudloff
  • Pipeline finished with Failed
    about 2 months ago
    Total: 777s
    #509750
  • Pipeline finished with Success
    about 2 months ago
    Total: 1276s
    #509765
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance prudloff Lille

    I rebased the latest patch and tests are passing but I did not test manually.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Think the issue summary needs some love. The motivation section mentions performance? But anything to support that?

    Was also mentioned as a remaining task

    The 8.1 I think is out of date haha

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance prudloff Lille

    I tried to rewrite the summary.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Debated turning to a feature request but think we should have some test coverage that altering is possible.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance prudloff Lille
  • ๐Ÿ‡ช๐Ÿ‡ธSpain penyaskito Seville ๐Ÿ’ƒ, Spain ๐Ÿ‡ช๐Ÿ‡ธ, UTC+2 ๐Ÿ‡ช๐Ÿ‡บ

    What test coverage is this missing?

    We don't need to test every form allows altering, that's not specific for any specific form but the form API, which is already covered.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    If the scenario is already covered then why make the change? Assuming this change is to solve a problem that maybe wasnโ€™t covered before.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Can put back into review if you disagree though

  • ๐Ÿ‡ช๐Ÿ‡ธSpain penyaskito Seville ๐Ÿ’ƒ, Spain ๐Ÿ‡ช๐Ÿ‡ธ, UTC+2 ๐Ÿ‡ช๐Ÿ‡บ

    Clean up. The existing tests passing is the test.

  • ๐Ÿ‡ช๐Ÿ‡ธSpain penyaskito Seville ๐Ÿ’ƒ, Spain ๐Ÿ‡ช๐Ÿ‡ธ, UTC+2 ๐Ÿ‡ช๐Ÿ‡บ

    This was suggested by @alexpott in #1998648-52: "Administration pages language" user account setting should be hidden if not used โ†’ . Let's land this 12 years later.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Alright going to leave for others

  • First commit to issue fork.
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom oily Greater London

    Rebased 221 commits.

    Test-only test passes:

    โ„น๏ธ Changes from faec1421c65a694b320f6c807c9546b4dde9482d
    core/modules/user/src/AccountForm.php
    If this list contains more files than what you changed, then you need to rebase your branch.
    1๏ธโƒฃ Reverting non test changes
    grep: warning: * at start of expression
    grep: warning: * at start of expression
    โ†ฉ๏ธ Reverting core/modules/user/src/AccountForm.php
    grep: warning: * at start of expression
    2๏ธโƒฃ Running test changes for this branch
    Exiting with EXIT_CODE=0
    Running after_script 00:01
    Running after script...
    $ sed -i "s#$CI_PROJECT_DIR/##" ./sites/default/files/simpletest/phpunit-*.xml || true
    sed: can't read ./sites/default/files/simpletest/phpunit-*.xml: No such file or directory
    Uploading artifacts for successful job 00:00
    Uploading artifacts...
    WARNING: ./sites/default/files/simpletest/phpunit-*.xml: no matching files. Ensure that the artifact path is relative to the working directory (/builds/issue/drupal-2058319) 
    WARNING: ./sites/simpletest/browser_output: no matching files. Ensure that the artifact path is relative to the working directory (/builds/issue/drupal-2058319) 
    ERROR: No files to upload                          
    Uploading artifacts...
    WARNING: ./sites/default/files/simpletest/phpunit-*.xml: no matching files. Ensure that the artifact path is relative to the working directory (/builds/issue/drupal-2058319) 
    ERROR: No files to upload                          
    Cleaning up project directory and file based variables 00:01
    Job succeeded
    
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Just fyi rebases typically arenโ€™t needed unless the MR no longer applies or if testing is randomly failing for a bug fix

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom oily Greater London

    RE #86 Yes, after running the test-only test seems pointless since no test coverage so far.

  • ๐Ÿ‡ช๐Ÿ‡ธSpain penyaskito Seville ๐Ÿ’ƒ, Spain ๐Ÿ‡ช๐Ÿ‡ธ, UTC+2 ๐Ÿ‡ช๐Ÿ‡บ

    Why would we need a new MR? The current MR shows the diff. And the diff fits two-scrolls.

    The re-arrangement of the code is exactly what we want, that's clear in the issue summary.

    No lenghty comments are added or deleted, they are just moved.

    This just needs someone willing to RTBC it.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom oily Greater London

    RE: #88
    I edited #87 quite a lot before I saw #88 mainly in agreement with #88. Starting to get my head around it. I tracked down your comment in the related issue. So these optional form elements will now be always present in the render array but as 'hidden' fields when not needed? It sounds an enhancement if it is likely to be a restricted list of specific fields for the foreseeable future. If it were likely to grow to more than a few fields might not be an enhancement..

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom oily Greater London

    I see this in the UserHooks.php file in the user core module.

      /**
       * Implements hook_entity_extra_field_info().
       */
      #[Hook('entity_extra_field_info')]
      public function entityExtraFieldInfo(): array {
        $fields['user']['user']['form']['account'] = [
          'label' => $this->t('User name and password'),
          'description' => $this->t('User module account form elements.'),
          'weight' => -10,
        ];
        $fields['user']['user']['form']['language'] = [
          'label' => $this->t('Language settings'),
          'description' => $this->t('User module form element.'),
          'weight' => 0,
        ];
        if (\Drupal::config('system.date')->get('timezone.user.configurable')) {
          $fields['user']['user']['form']['timezone'] = [
            'label' => $this->t('Timezone'),
            'description' => $this->t('System module form element.'),
            'weight' => 6,
          ];
        }
        $fields['user']['user']['display']['member_for'] = [
          'label' => $this->t('Member for'),
          'description' => $this->t("User module 'member for' view element."),
          'weight' => 5,
        ];
        return $fields;
      }
    

    This new hook could have a bearing on this issue.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom oily Greater London

    RE: #90 The new hook seems to be adding entity fields ie nothing to do with the account form fields..

Production build 0.71.5 2024