Problem/Motivation

Steps to reproduce:

  1. Edit new users view
  2. Add field, filter by user, select permissions
  3. Click save
  4. Place the block in your frontpage

The admin user shows:

<div class="views-field views-field-permission"><span class="field-content">, View published content, Use the <a href="/admin/config/content/formats/manage/basic_html">Basic HTML</a> text format, View comments, Post comments, Skip comment approval, [...]</span></div>

See the trailing comma.

Proposed resolution

Fix the filter format permission name.

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

penyaskito’s picture

penyaskito’s picture

Issue summary: View changes
penyaskito’s picture

This has to do with escaping the title of the permission, which contains html:

Notice: Undefined index: use text format plain_text in Drupal\user\Plugin\views\field\Permissions->preRender() (line 103 of core/modules/user/src/Plugin/views/field/Permissions.php).

I checked that the trailing comma is just the consequence, not the symptom. The "use plain text format" permission comes without the title because of this issue, and then is not found on the permissions array when looking for the title.

penyaskito’s picture

Status: Active » Needs review
Issue tags: +Needs tests
FileSize
517 bytes

This fixes the issue, let's see what the bot things.

penyaskito’s picture

Title: Field permission in views shows a trailing comma » Fallback filter permission doesn't return a proper name
Component: views.module » filter.module
Issue summary: View changes
penyaskito’s picture

Issue tags: -Needs tests
FileSize
1.11 KB
1.62 KB

Now with a test.

The last submitted patch, 6: 2354493-6.test-only.patch, failed testing.

penyaskito’s picture

From FilterFormatInterface:

  /**
   * Returns the machine-readable permission name for the text format.
   *
   * @return string|bool
   *   The machine-readable permission name, or FALSE if the text format is
   *   malformed or is the fallback format (which is available to all users).
   */
  public function getPermissionName();

but it does not say why, and all tests are green.

penyaskito’s picture

Issue summary: View changes
jhedstrom’s picture

+++ b/core/modules/filter/src/Entity/FilterFormat.php
@@ -238,7 +238,7 @@ public function isFallbackFormat() {
-    return !$this->isFallbackFormat() ? 'use text format ' . $this->id() : FALSE;

If this change is made, does the permission now appear on the permissions page (I'm guessing that's why it was originally returning FALSE)?

penyaskito’s picture

Yes, with the patch applied it is shown in the permissions page. By default it will be "Use plain text format".

Patch still applies. We need to define if this is currently a bug, and if not, my guess is that it should be better documented why are we doing this.

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.

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.

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.

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

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should 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.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should 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.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.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: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
quietone’s picture

Version: 9.3.x-dev » 10.0.x-dev
Status: Needs review » Closed (cannot reproduce)
Issue tags: +Bug Smash Initiative

I tested this on 10.0.x, standard install, and was not able to reproduce this error. I followed the steps given in the Issue Summary. This is what the block displays for the admin user and I don't see an trailing comma.

<div class="views-field views-field-permission"><span class="field-content">View comments, View published content, Use shortcuts, Use the site-wide contact form, Post comments, Use search, Skip comment approval, Use the <a href="/admin/config/content/formats/manage/basic_html">Basic HTML</a> text format</span></div>

Therefore, closing as cannot reproduce. If you are experiencing this problem on a supported version of Drupal reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue (starting from "Install Drupal core").

Thanks!