Schema for user expire rules by role is difficult to validate.

Created on 19 December 2024, 27 days ago

Problem/Motivation

The current implementation of user_expire_role_rules makes it challenging to utilize Drupal core's configuration validation effectively. The available options are structured in a way that prevents comprehensive validation at the configuration schema level. This could lead to inconsistent or invalid configurations being saved by means other than via the Form, for example via drush config:set.

Switching to a configuration entity will provide better validation capabilities, align the implementation with modern Drupal practices, and make the rules easier to manage and extend.

Steps to reproduce

  • Navigate to the configuration page for user expire role rules.
  • Set up rules with inconsistent or invalid configurations (e.g., overlapping roles or missing fields).
  • Save the configuration and notice the lack of validation feedback.

Proposed resolution

Convert user_expire_role_rules into a configuration entity. This approach involves:

  • Using drush generate config-entity to scaffold the necessary boilerplate code for the entity.
  • Defining a schema and validation logic within the configuration entity class to ensure consistent and valid configurations.
  • Implementing a UI for managing the configuration entity (e.g., list builder and form handlers).

Remaining tasks

  • Generate the configuration entity using Drush.
  • Implement the validation logic in the entity class.
  • Create list builder and form handlers for the entity.
  • Update the admin interface to use the new configuration entity.
  • Write tests to cover validation and UI functionality.

User interface changes

A new admin interface will be introduced for managing user_expire_role_rules. This includes:

  • A list builder page to display existing rules.
  • Form handlers for adding, editing, and deleting rules.

API changes

Existing APIs related to user_expire_role_rules will be deprecated or refactored to use the new configuration entity. New entity methods will be added for validation and retrieval of role expiration rules.

Data model changes

The current array-based schema for user_expire_role_rules will be replaced with a configuration entity structure. This change will involve migrating existing configurations to the new entity.

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States trackleft2 Tucson, AZ πŸ‡ΊπŸ‡Έ

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

Comments & Activities

Production build 0.71.5 2024