Create computed field

Created on 23 January 2022, over 2 years ago
Updated 4 July 2023, 12 months ago

Create a generic computed field for real name property.

Feature request
Status

Needs work

Version

2.0

Component

Code

Created by

🇭🇺Hungary nevergone Nyíregyháza, Hungary, Europe

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

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

  • heddn Nicaragua
    +++ b/realname.module
    @@ -288,6 +290,20 @@ function realname_delete_all() {
    +    $fields['realname_field'] = BaseFieldDefinition::create('string')
    

    I think I like the name realname only a bit better. It will match the full name of this module.

    Also, would it make sense to add a test or 2 to make sure this doesn't have regressions?

  • Status changed to Needs work over 1 year ago
  • heddn Nicaragua

    NW because doesn't apply.

  • 🇭🇺Hungary nevergone Nyíregyháza, Hungary, Europe

    #3259991-6: Create computed field patch rerolled, the existing test are green.

  • 🇭🇺Hungary nevergone Nyíregyháza, Hungary, Europe
  • 🇮🇳India sumit-k

    Hi, I have prepared a patch that includes fixes for the issues mentioned, along with the corresponding tests. Please review.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 8
    last update 12 months ago
    5 pass
  • Status changed to Needs review 12 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 8
    last update 12 months ago
    4 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 8
    last update 12 months ago
    5 pass
  • 🇭🇺Hungary nevergone Nyíregyháza, Hungary, Europe

    @sumit-k: Thanks the test.

    Please test the following patch.

    This is remove duplicated real name fields with Layout builder:

    Next step:
    Create configuration update path from the old psuedo field to new computed field.

  • 🇮🇳India sumit-k

    Tested following patch. Looks good to me.

  • Status changed to Needs work 12 months ago
  • heddn Nicaragua
    +++ b/realname.module
    @@ -36,20 +38,6 @@ function realname_help($route_name, RouteMatchInterface $route_match) {
    -function realname_entity_extra_field_info() {
    

    Instead of removing this, can we mark it deprecated in the name or something? It would be great to have both there in the code base while we stabilize the conversion to a computed field.

    1. +++ b/realname.module
      @@ -64,7 +52,7 @@ function realname_user_format_name_alter(&$name, AccountInterface $account) {
      +    if (is_string($account->realname) && mb_strlen($account->realname)) {
      
      @@ -119,10 +107,14 @@ function realname_user_view(array &$build, EntityInterface $account, EntityViewD
      +      if (is_string($account->realname)) {
      ...
      +      if (is_string($account->realname)) {
      

      why these changes?

    2. +++ b/tests/src/Functional/RealnameBasicTest.php
      @@ -149,7 +149,7 @@ class RealnameBasicTest extends BrowserTestBase {
      +    $edit = ['fields[realname_field][region]' => 'content'];
      

      I thought the field was renamed, why is this still with a _field suffix added? And if it was working either way, what is this actually testing?

  • 🇭🇺Hungary nevergone Nyíregyháza, Hungary, Europe

    Instead of removing this, can we mark it deprecated in the name or something? It would be great to have both there in the code base while we stabilize the conversion to a computed field.

    The problem is that if we don't remove it, we can't avoid the annoying repetition shown in the image above.

    I thought the field was renamed, why is this still with a _field suffix added? And if it was working either way, what is this actually testing?

    The _field suffix is added because the field was not actually deleted, only displayed (extra field).
    The test does the same thing as before.

    Consideration should be given to moving this task to version 3.x, along with a thorough refactoring.

Production build 0.69.0 2024