Change path and redirect_path to not assume leading slash

Created on 10 April 2025, 16 days ago

Problem/Motivation

The "path" and "redirect_path" fields on the VerifyEmail entity currently add a leading "/".

However, this prevents certain paths, most notably "" from being used.

Proposed resolution

  • We need to change to the path and redirect path to not prepend a "/".
  • We need to add an install hook to add a "/" to the start of existing paths.

Remaining tasks

  1. In src/verifyEmailListBuilder::buildRow remove the "/" from the markup
  2. In the $path property of src/Entity/VerifyEmail, remove the part about appending to "/" from the comment.
  3. In src/From/VerifyEmailAddEditForm, remove the '#field_prefix' => '/' from path and redirect_path. Add a #description stating the path should be a valid path within the site
  4. In src/Routing/VerifyEmailRoutes, remove "/" from the path for both routes
  5. Add an Update Hook that gets all VerifyEmail entities with \Drupal::service('entity_type.manager')->getStorage('verify_email')->getQuery()->accessCheck()->execute();, then iterate through the entities, and update path and redirect_path to add a "/"

(Note: the module uses the new object oriented hooks, but these are not supported for update hooks because not enough of the Drupal kernel is in place when they run, so the update hook should be a traditional Drupal hook).

User interface changes

Small change to the entity edit form to clarify that the "/" should be included in the path.

API changes

None

Data model changes

None

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇮🇪Ireland lostcarpark

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