Reinstalling the module after an uninstall breaks

Created on 7 September 2023, about 1 year ago
Updated 25 October 2023, about 1 year ago

Problem/Motivation

Reported by Rouven Volk in the Pantheon Community Slack, original thread is here: https://pantheon-community.slack.com/archives/C01DXGMFZFB/p1694119212295379

Found a little bug, reinstalling the Drupal module Pantheon Decoupled triggers “Error message: Unable to install Pantheon Decoupled, user.role.pantheon_decoupled already exists in active configuration.“, since the uninstall routine doesn’t remove this user role.

Reproduce:
use demo environment with installed module
uninstall pantheon_decoupled (1.0.0-beta1)
install module again triggers fatal error, install can’t complete without manually removing the role

Steps to reproduce

  • use demo environment with installed module
  • uninstall pantheon_decoupled (1.0.0-beta1)
  • install module again triggers fatal error, install can’t complete without manually removing the role

Proposed resolution

  • uninstall routine shall remove the user role 'user.role.pantheon_decoupled'
  • install routine could check if the role already exists and just ensure it has the right permission

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

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

Comments & Activities

  • Issue created by @coby.sher
  • 🇩🇪Germany rvolk Frankfurt

    Refined description.

  • First commit to issue fork.
  • @abhisekmazumdar opened merge request.
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India abhisekmazumdar India

    I tried to remove anything that was created by the install hook and needed to be removed. Not everything needed to be deleted, so I only removed:

    • DpPreviewSite - example_nextjs_preview
    • user - pantheon_decoupled
    • role - pantheon_decoupled
  • Status changed to Needs work about 1 year ago
  • 🇺🇸United States brianperry

    Open to discussion here, but I worry about deleting things like users and roles (less so preview sites) on uninstall since we don't know if they were repurposed or modified. Proposed some alternatives to consider on the MR that check for existence before creating rather than deleting on uninstall.

  • 🇩🇪Germany rvolk Frankfurt

    Creating users and roles always opens up a couple of related issues. To do it right, the status page should indicate if something is missing, this way site builders can still extend the user and role model, while the module will only ensure the minimum requirements are met. After uninstall a message to the user might be sufficient, informing him that he can delete the user now. So the optional configuration approach in combination with a status checks should be sufficient for the current case. If we want to remove the user and role, we must make sure that it has not been modified or repurposed.

    Once the status check is in place, we can use the same routine in the install process and only create the user if missing.

    The preview site feels like a no brainer, should be fine to simply remove it.

  • 🇺🇸United States brianperry

    > After uninstall a message to the user might be sufficient, informing him that he can delete the user now.

    A message that the user and role can be deleted is a nice additional step if we're leaving it behind. Thanks for the suggestion @rvolk

Production build 0.71.5 2024