Problem/Motivation

Error description refers to incorrect element

when a user does not have permission to edit the site name or slogan, an incorrect access denied message is displayed: "Defined on the Site Information page. You do not have the appropriate permissions to change the site logo." it refers to "site logo".

Bad access denied msgs

Error refers to pages the user does not have access

When a user does not have permission to do something, we don't usually have an explanation message.

I'd like to propose removing the "You do not have the appropriate permissions to change the ...." message. I have a client that became confused why he was not granted permission to do something, despite being so close to being able to do it.

And remove the "Defined on the XXX page." text if the user does not have permission to access it.

Steps to reproduce

  1. Add a new user and assign a role other than administrator say Content Editor (comes default with Drupal 10)
  2. Login with the newly created user and go to /admin/structure/block
  3. From the admin permissions page /admin/people/permissions, give permission to "Administer blocks" for the "Content Editor"
  4. Configure Site Branding block /admin/structure/block/manage/olivero_site_branding to see the results in "Toggle branding elements
    " section

Proposed resolution

Remaining tasks

User interface changes

Refer to images in #47

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-2852838

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dpi created an issue. See original summary.

dpi’s picture

Status: Active » Needs review
StatusFileSize
new4.74 KB
  • Updated some usage to ::fromRoute as recommended
  • Updated wording 'site information' -> 'Basic site settings'
  • Given both points in Error refers to pages the user does not have access, there is no longer any description for users without access. As a result, descriptions are created after the form element since they are optional.

Status: Needs review » Needs work

The last submitted patch, 2: system-branding-block-element-descriptions-2852838.patch, failed testing.

dpi’s picture

Status: Needs work » Needs review
StatusFileSize
new4.77 KB

Fixed PHP5 error

bander2’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

The patch is not applying to 8.4.x-dev. Looks like it's using the long array syntax and drupal now uses the short syntax.

jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new4.72 KB

Re-rolled.

bander2’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new32.49 KB
new17.12 KB

Awesome! I'm attaching screenshots of the new branding elements section of the branding block for reverence:

With permissions to administer theme and configuration:
With permissions

Without permissions to administer theme and configuration:
Without permissions

wim leers’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +String change in 8.4.0
  1. +++ b/core/modules/system/src/Plugin/Block/SystemBrandingBlock.php
    @@ -75,40 +75,6 @@ public function blockForm($form, FormStateInterface $form_state) {
    -      $site_name_description = $this->t('Defined on the Site Information page. You do not have the appropriate permissions to change the site logo.');
    
    @@ -117,22 +83,41 @@ public function blockForm($form, FormStateInterface $form_state) {
    +      $description = $this->t('Defined on the <a href=":site-settings">Basic site settings</a> page.', [
    

    This is a string change!

  2. +++ b/core/modules/system/src/Plugin/Block/SystemBrandingBlock.php
    @@ -117,22 +83,41 @@ public function blockForm($form, FormStateInterface $form_state) {
    +    $block_theme_settings_url = Url::fromRoute('system.theme_settings_theme');
    +    $block_theme_settings_url->setRouteParameter('theme', $theme);
    

    These can be merged: Url::fromRoute() takes route parameters too.

jofitz’s picture

Status: Needs work » Needs review
StatusFileSize
new1.72 KB
new4.67 KB
  1. Changed "Basic site settings" to "Site Information".
  2. Added route parameter to Url::fromRoute().

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.

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.

ranjith_kumar_k_u’s picture

Issue tags: -
StatusFileSize
new65.64 KB
new121.54 KB

The last patch applied cleanly on 9.2 these are the changes for a user without permissions.
Before patch
before patch

After patch
after patch

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.

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

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Moving this back to rtbc, the change here is still a good thing to do and the technical remark by @Wim Leers in #8 has been resolved.

quietone’s picture

Assigned: dpi » Unassigned
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

The latest patch here, in #9 does not apply to 9.5.x.

Un-assigning because dpi has not working on this for 5 years.

mrinalini9’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new4.4 KB

Rerolled patch #9 for the 9.5.x branch, please review it.

asha nair’s picture

StatusFileSize
new40.89 KB
new48.58 KB

patch #23 was applied successfully in 9.5.x branch. Adding screenshots for reference

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Bug Smash Initiative, +Needs tests

Patch looks good just needs tests.

smustgrave’s picture

Take that back admin users blocks are now throwing fatal errors. Users with right role get warning. SO patch needs work.

smustgrave’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new2.27 KB
new1.41 KB
new5.88 KB

The last submitted patch, 27: 2852838-27-tests-only.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 27: 2852838-27.patch, failed testing. View results

smustgrave’s picture

Status: Needs work » Needs review
deepalij’s picture

Assigned: Unassigned » deepalij

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

kristen pol’s picture

Assigned: deepalij » Unassigned

Unassigning given the delay and also since we don't normally assign Drupal core issues to ourselves.

gaurav-mathur’s picture

Issue already resolve in version 10. Adding screenshot for reference.

sonam.chaturvedi’s picture

Status: Needs review » Needs work
StatusFileSize
new740.37 KB
new740.37 KB

This issue is still reproducible on 10.1 for Olivero / Bartik themes Site branding blocks.
Please see attached screenshot.

Verified patch#27 on 10.1.x-dev. Patch do not apply, may be due test failure. This needs work.

error: while searching for:
    $this->assertEmpty($site_name_element, 'The branding block site name was disabled.');
    $this->assertSession()->elementTextNotContains('xpath', $site_slogan_xpath, 'Community carpentry');
    $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:system.site');
  }
}
error: patch failed: core/modules/block/tests/src/Functional/BlockSystemBrandingTest.php:119
error: core/modules/block/tests/src/Functional/BlockSystemBrandingTest.php: patch does not apply
prashant.c’s picture

Issue summary: View changes

This issue also exists in 10.0.2-dev for the default themes Olivero and Claro.
Adding steps to reproduce in the main description.

reenaraghavan made their first commit to this issue’s fork.

smustgrave’s picture

Status: Needs work » Needs review
StatusFileSize
new405 bytes
new5.86 KB

Rerolled #27
error: patch failed: core/modules/block/tests/src/Functional/BlockSystemBrandingTest.php:119
error: core/modules/block/tests/src/Functional/BlockSystemBrandingTest.php: patch does not apply

tanuj.’s picture

StatusFileSize
new115.35 KB
new148.11 KB

tested and verified patch #38 on claro and olivero themes, patch applied successfully and fixed the 'Incorrect access denied messages in branding block', attaching screenshots for reference. need RTBC+1

skt-001’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new888.48 KB

patch #38 is working fine. also mentioned in #39 so moving status to RTBC.

larowlan’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/block/tests/src/Functional/BlockSystemBrandingTest.php
@@ -115,6 +115,17 @@ public function testSystemBrandingSettings() {
+    $this->assertSession()->responseNotContains('Defined on the Appearance or Theme Settings page. You do not have the appropriate permissions to change the site logo.');
+    $this->assertSession()->responseNotContains('Defined on the Site Information page. You do not have the appropriate permissions to change the site logo.');
+    $this->assertSession()->responseNotContains('Defined on the Site Information page. You do not have the appropriate permissions to change the site logo.');

We never emit 'You do not have the appropriate permissions' anymore, so these assertions would still pass even if the patch didn't work.

Let's change them to assert the new string isn't emitted.

Let's also add some positive asserts for the user that does have the required permissions

akram khan’s picture

StatusFileSize
new5.78 KB
new1.32 KB

added updated patch and addressed #41

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mstrelan made their first commit to this issue’s fork.

mstrelan’s picture

Status: Needs work » Needs review

Applied the latest patch and converted to a merge request. Fixed the test coverage and found a bug with the active theme and fixed that too.

sd9121’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new115.27 KB
new89.72 KB
new106.64 KB
new100.48 KB

I have reviewed and tested the patch against Drupal 11.x-dev, and it works as expected. The patch successfully removes the incorrect access denied messages that appeared in the Site Branding block when users lacked permission to edit certain elements. Specifically, users without the appropriate permissions no longer see misleading references such as "You do not have the appropriate permissions to change the site logo" when they only lack access to the site name or slogan.

quietone’s picture

Issue summary: View changes
Issue tags: +Usability

This is changing the User Interface, so adding tag. I have also updated credit.

A reminder to everyone making screenshots that they should be available from the Issue Summary. Doing so makes it much easier for reviewers and committers.

quietone’s picture

longwave’s picture

Status: Reviewed & tested by the community » Needs work

I manually tested this but there is a bug, the "Theme Settings" link does not always take me to the right place.

longwave’s picture

This is probably out of scope and requires a new issue, but for users with permission, should we just allow them to configure these settings directly from the block?

pameeela made their first commit to this issue’s fork.

pameeela’s picture

Found this issue while working with Canvas, I followed the link to the Appearance settings to change the logo, and I thought there was a bug when it didn't update. Took me a few minutes to figure out that I changed the global logo rather than the one for my default theme.

I think the current state of the MR makes it more confusing by providing two different links (one of which is often to the admin theme rather than the front end theme).

Can we link only to the default front end theme page? What is the purpose of the global logo settings anyway?

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.