Problem/Motivation

When a user is editing a term, then saves the form, Drupal will send the user to the term view form.

However Drupal doesn't know if the user has access to view the form. There may be custom code, such as entityaccess hooks (in my case), that change behaviour. If custom behaviour disallows view access, the user will see a access denied page.

Steps to reproduce

Proposed resolution

Check whether the user has access to view a term before trying to redirect them.

If the user does not have access, do not add a redirect. This in effect simply refreshes the update form, which we know the user has access to.

Node has had similar behaviour for over 10 years now (#1429442: Access denied page shown after submitting form that creates a unpublished node), wherin it checks if a user can view a node, before trying to redirect them.

Remaining tasks

Review

User interface changes

None.

Introduced terminology

None.

API changes

None.

Data model changes

None.

Release notes snippet

Minor change only.

Issue fork drupal-3470876

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

Assigned: dpi » Unassigned
Issue summary: View changes
Status: Active » Needs review
Issue tags: -Needs tests
dpi’s picture

Test fail seems unrelated...

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

acbramley’s picture

One failure was related, the other didn't seem it.

dpi’s picture

Just the unrelated Nightwatch failure now.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Ran test-only feature and test coverage appears to be there.

1) Drupal\Tests\taxonomy\Functional\TermTest::testRedirects
Behat\Mink\Exception\ExpectationException: Current page is "/taxonomy/term/3", but "/taxonomy/term/3/edit" expected.
/builds/issue/drupal-3470876/core/tests/Drupal/Tests/WebAssert.php:591
/builds/issue/drupal-3470876/core/tests/Drupal/Tests/WebAssert.php:779
/builds/issue/drupal-3470876/core/modules/taxonomy/tests/src/Functional/TermTest.php:605
FAILURES!
Tests: 10, Assertions: 253, Failures: 1.
Exiting with EXIT_CODE=1

There was a reported nightwatch failure in HEAD and believe that's it.

Issue summary appears complete and looking at the code review don't see anything off.

LGTM

catch’s picture

MR looks fine but I think we should have a follow-up to apply the same pattern across entity types - users, media etc. I looked for an existing issue to unify these but couldn't find it, pretty sure we have one though.

catch’s picture

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x, thanks!

  • catch committed 3141b421 on 11.x
    Issue #3470876 by dpi, acbramley: Check term view access before trying...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.