Problem/Motivation

The postSave method for Role is not needed anymore. It used to help with cache invalidation, but Drupal 8 now has correct contexts and tags everywhere, so it should be obsolete now.

Proposed resolution

Remove the method from core/modules/user/src/Entity/Role.php

Remaining tasks

None

User interface changes

None

API changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

LKS90’s picture

Status: Needs work » Needs review
FileSize
532 bytes

Here is the patch that removes the method.

Status: Needs review » Needs work

The last submitted patch, 1: removePostsaveMethod_2475263_1.patch, failed testing.

Berdir’s picture

the fatal error'd tests are unrelated, but CommentAnonymousTest looks like an actual issue that is missing cache tags somewhere...

Wim Leers’s picture

LKS90’s picture

Can't reproduce the Test fail locally, reupload.

LKS90’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 5: removePostsaveMethod_2475263_2.patch, failed testing.

LKS90’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 5: removePostsaveMethod_2475263_2.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
9.94 KB
9.42 KB

So, there are apparently two problems that were hidden by invalidating all render caches when saving a role:

a) the access checks on the reply form redirect and do not add cacheability metadata. This patch converts it to an actual access check with proper metadata. The downside is that users no longer get redirect back and don't see those messages anymore. I think that's OK, but not sure. The alternative would be to add a CacheableRedirectResponse. Would be a good idea anyway to have that (I have 2 contrib modules that can use that i think), but would also make the logic in that method even more convoluted I think, as we need to collect all the relevant metadata for every redirect.

Status: Needs review » Needs work

The last submitted patch, 11: removePostsaveMethod_2475263_11.patch, failed testing.

LKS90’s picture

Also changed the two other failing tests to assert a 403 response instead of looking for some text.

LKS90’s picture

Status: Needs work » Needs review
catch’s picture

There was another issue dealing with the reply form that ran into similar issues, can't remember which one it was though atm.

Wim Leers’s picture

#13: could you provide an interdiff? That makes it easier to see what you changed relative to the previous patch. Thanks :)

LKS90’s picture

An interdiff, as requested.

Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

Opened #2491545: Bring back the error messages for the 403 page of the comment handler to bring those messages back potentially with a clean interface.

Overall this is much better, RTBC.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.0.x, thanks!

  • catch committed 6758f11 on 8.0.x
    Issue #2475263 by LKS90, Berdir: Remove Role::postSave() method
    

Status: Fixed » Closed (fixed)

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