Problem/Motivation

There's no usage in core and contrib
Also function is broken because trying to save immutable config, ref https://www.drupal.org/node/2407153

Proposed resolution

Remove function

Remaining tasks

- decide to remove or deprecate function
- patch/commit

User interface changes

no

API changes

Removal of update_replace_permissions()

Data model changes

no

Release notes snippet

no

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost created an issue. See original summary.

andypost’s picture

Status: Active » Needs review
FileSize
1.29 KB

Initial stub

andypost’s picture

Issue tags: +Needs change record
longwave’s picture

Nice find!

So this was introduced in #1872876: Turn role permission assignments into configuration. as part of the original D7 to D8 upgrade path, before we dropped that and switched to only allowing migrations.

As the OP states there are no uses in core or contrib: http://grep.xnddx.ru/search?text=update_replace_permissions&filename=

However, it seems like there is a very small chance that this might have been discovered and used in custom code - even if that was only ever in an update hook, it doesn't seem like this would ever be called at runtime. Still, the BC policy doesn't exclude anything like this, and therefore I think this is public API, and we have to go through the deprecation process.

andypost’s picture

andypost’s picture

Deprecation patch

andypost’s picture

FileSize
886 bytes
2.45 KB

This function is broken because trying to save immutable config

Here's a test to show it (interdiff shows catching exception)

Drupal\Core\Config\ImmutableConfigException: Can not set values on immutable configuration user.role.lhwyojj6:permissions. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object
xjm’s picture

Issue tags: +Needs change record

Thanks @andypost. Normally, I would say that even dead code should be deprecated, but if this function's only... function... is to throw an exception, then we can probably actually delete it with a CR.

xjm’s picture

andypost’s picture

Title: Remove unused update_replace_permissions() » Remove unused and broken update_replace_permissions()
Issue summary: View changes
Issue tags: -Needs change record updates

Updated IS and CR

daffie’s picture

Status: Needs review » Reviewed & tested by the community

Tested that the expected exception in the added test is thrown. That proves that the function update_replace_permissions() is broken.
The function is deprecated and will be removed in 10.0.
The deprecation message has testing for it.
All changes look good to me.
For me it os RTBC.

@andypost: Good find!

longwave’s picture

Issue tags: -@deprecated
FileSize
1.29 KB

@daffie We don't even need to deprecate if the function is broken, we can just remove it. Nobody can be using it as it doesn't work - and if they had tried and failed you would hope they would post a bug report, but that hasn't been done either. There are just three issues that mention update_replace_permissions: this one, the refactoring one where this was discovered, and the original introduction of the function.

Reuploading #2 and marking that as RTBC for the simple removal.

xjm’s picture

Title: Remove unused and broken update_replace_permissions() » Remove unused and broken update_replace_permissions(), which always throws an exception

Making the title a bit more clear for anyone who does a double-take at the commit log.

  • xjm committed 5d1599d on 9.1.x
    Issue #3143605 by andypost, longwave, daffie: Remove unused and broken...
xjm’s picture

Status: Reviewed & tested by the community » Fixed

Confirmed with @catch also that he's +1 on removing this since there is no possible way someone could be using it meaningfully. Committed to 9.1.x and published the CR. Thanks! And extra thanks to @andypost for the test proving the broken-ness which made it a lot easier to sign off on something outside normal policy.

Status: Fixed » Closed (fixed)

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