Remove old 7.x permissions in an 8.0.x update hook

Created on 10 October 2024, about 1 month ago

Problem/Motivation

The 8.x-7.x version of the module defines some permissions which are not defined in the 8.0.x version:

  1. administer elasticsearch connector
  2. administer elasticsearch cluster
  3. administer elasticsearch index

After upgrading the module's code (i.e.: with composer), and running database updates (i.e.: to migrate the configuration to Search Api Servers and Indexes), trying to modify a role that used to have those permissions would result in errors like...

RuntimeException: Adding non-existent permissions to a role is not allowed. The incorrect permissions are "administer elasticsearch cluster", "administer elasticsearch connector", "administer elasticsearch index". in Drupal\user\Entity\Role->calculateDependencies() (line 210 of core/modules/user/src/Entity/Role.php).

... or in some cases, just exporting configuration would result in errors like...

In Role.php line 207:

Adding non-existent permissions to a role is not allowed. The incorrect permissions are "administer elasticsearch cluster", "administer elasticsearch connector", "administer elasticsearch index".

Steps to reproduce

(coming soon)

Proposed resolution

There are similar permissions in search_api, but they grant wider access to add servers/indexes of any type. Instead of replacing the old elasticsearch_connector-7 permissions with the similar-but-broader-scope Search API permissions, a safer solution would be to remove the old elasticsearch_connector-7 permissions during the database update.

Note also that elasticsearch_connector-7 has no usable UI without Search API, so it seems pretty likely to me that users with the old elasticsearch_connector-7 permissions likely also have the equivalent Search API permissions.

We should probably also write a change record for this.

Remaining tasks

  1. Write a patch
  2. Review and feedback
  3. RTBC and feedback
  4. Write a change record
  5. Commit and release

User interface changes

None.

API changes

None.

Data model changes

None.

Feature request
Status

Active

Version

8.0

Component

Code

Created by

🇨🇦Canada mparker17 UTC-4

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024