Problem/Motivation

template_preprocess_node() and template_preprocess_comment both call user_view($author, 'compact'); but the compact entity display settings are defined in standard.profile and hence may not exist.
In best case scenario, extra fields are rendered (these are rendered by default for a non-existent display mode).
In worst case scenario, you end up with recursion (#2114887: Maximum nesting level when attaching comment field to User.)

Proposed resolution

Node module comes with a new user view mode (node_author) and configured display mode
Comment modules comes with a new user view mode (comment_author) and configured display mode
Standard profile comes with overrides of the configured display modes and include image field settings for user pictures (comment and node cannot know if image module is enabled in their config).
Upgrade path.

Remaining tasks

Everything

User interface changes

None

API changes

None

Data model changes

New view mode and entity display config objects.

Selection_131.png

Comments

chx’s picture

Status: Active » Needs review
StatusFileSize
new448 bytes
amateescu’s picture

StatusFileSize
new613 bytes

How about this instead?

amateescu’s picture

Title: . » User compact view mode is not configured in minimal

...

amateescu’s picture

StatusFileSize
new18.34 KB

The effect is basically the same, we disable the output of 'user_picture'. @tim.plunkett asked me why did I remove the $default_theme assignment.. because it wasn't used :/

minimal-node-page-after.png

amateescu’s picture

StatusFileSize
new1.41 KB

Added a comment for the 'compact' view mode.

chx’s picture

Status: Needs review » Reviewed & tested by the community

Purr-fect.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 3e88fc4 and pushed to 8.x. Thanks!

chx’s picture

Status: Fixed » Active

Same for comment. Either revert the patch above and apply mine or roll one for comment as well.

szantog’s picture

Status: Active » Needs review
StatusFileSize
new805 bytes

Disable member for field in compact view of user in minimal profile should be an ultimate solution?

amateescu’s picture

StatusFileSize
new1.68 KB

No.. chx was right from the start. I tried to find an alternative way because the patch in #1 included the uuid property but I could've just removed it. Sorry chx :)

Status: Needs review » Needs work

The last submitted patch, 1972242-10.patch, failed testing.

amateescu’s picture

Status: Needs work » Needs review
StatusFileSize
new1003 bytes

That's what you get when you mess with the updgrade path :/

alansaviolobo queued 12: 1972242-12.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 12: 1972242-12.patch, failed testing.

larowlan’s picture

alexpott’s picture

Discussed with @catch today - he was a fan of a new module that both node and comment could depend on. However we have more problems since we have to prevent user.compact from being deleted too. It should be locked. And we need to be sure that it can't be deleted. This is one of the causes of #2114887: Maximum nesting level when attaching comment field to User.

larowlan’s picture

Issue summary: View changes

Fixed issue summary

andypost’s picture

maybe we need to allow calculated fields to be exposed through formatters?

--- /dev/null
+++ b/core/modules/user/config/entity.display.user.user.compact.yml

that used in comments too

andypost’s picture

Is it possible to add new view modes for user at this stage?
Looks that makes UX worth, and does not prevents to add displaying comment field on them

andypost’s picture

Issue tags: +Needs reroll
andriyun’s picture

StatusFileSize
new1.04 KB

Just rerolled #22 patch

andriyun’s picture

Status: Needs work » Needs review

trigger testbot

andriyun’s picture

Issue tags: -Needs reroll
andypost’s picture

Status: Needs review » Needs work
Issue tags: +D8 upgrade path

This needs hook_update for existing installs

andriyun’s picture

Assigned: Unassigned » andriyun

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • alexpott committed 3e88fc4 on 8.3.x
    Issue #1972242 by amateescu, chx: Fixed User compact view mode is not...

  • alexpott committed 3e88fc4 on 8.3.x
    Issue #1972242 by amateescu, chx: Fixed User compact view mode is not...

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • alexpott committed 3e88fc4 on 8.4.x
    Issue #1972242 by amateescu, chx: Fixed User compact view mode is not...

  • alexpott committed 3e88fc4 on 8.4.x
    Issue #1972242 by amateescu, chx: Fixed User compact view mode is not...

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

larowlan’s picture

Version: 8.3.x-dev » 8.4.x-dev

Issue summary approach isn't consistent with current patch - can someone confirm preferred approach?

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

vprocessor’s picture

Assigned: andriyun » vprocessor
vprocessor’s picture

Assigned: vprocessor » Unassigned
Status: Needs work » Needs review
StatusFileSize
new404 bytes

Just rerolled #22 patch

And removed changes in '/core/profiles/minimal/minimal.install' because we have this configs in profile with the same changes

Status: Needs review » Needs work

The last submitted patch, 37: user_compact_view_mode-1972242-37.patch, failed testing. View results

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +Bug Smash Initiative

I'm following up on issues that have been committed and re-opened.

This issue was committed to Drupal 8.x in April 2013 and re-opened in #8 to make the same changes to comments. The last discussions were in 2015. More information was asked for in 2015 in #15 and so far, none has been provided.

Is there anything still to do here? If so, update the Issue Summary and add a comment.

Thanks

joachim’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

template_preprocess_node() and template_preprocess_comment() now have a guard on getting the 'compact' user view, so I think we can say this got fixed:

    if ($variables['display_submitted']) {
      if (theme_get_setting('features.node_user_picture')) {
        // To change user picture settings (e.g. image style), edit the
        // 'compact' view mode on the User entity. Note that the 'compact'
        // view mode might not be configured, so remember to always check the
        // theme setting first.
        $variables['author_picture'] = \Drupal::entityTypeManager()
          ->getViewBuilder('user')
          ->view($node->getOwner(), 'compact');
      }
    }
  if (theme_get_setting('features.comment_user_picture')) {
    // To change user picture settings (for instance, image style), edit the
    // 'compact' view mode on the User entity.
    $variables['user_picture'] = \Drupal::entityTypeManager()
      ->getViewBuilder('user')
      ->view($account, 'compact');
  }