Error when uninstalling linkchecker prevents uninstall

Created on 10 September 2023, about 1 year ago
Updated 1 August 2024, 3 months ago

Problem/Motivation

I wasn't able to uninstall the module after having data in the database. I am using 8.x-1.1.

Steps to reproduce

  1. Install linkchecker
  2. Create content with links in it
  3. Configure the fields that contain links to be checked by the linkchecker
  4. Go to linkchecker settings
  5. Click Reanalyze content for links button under Maintenance
  6. Run cron
  7. Note that you will have data in the database
  8. Try uninstalling: drush pm:uninstall linkchecker
  9. Result:
    In PmCommands.php line 189:
                                                                                                                                
      linkchecker: There is content for the entity type: LinkChecker link type. <a href="/admin/modules/uninstall/entity/linkc  
      heckerlink">Remove LinkChecker link types</a>.                                                                            
                                                                                                                                
    Failed to run drush pm:uninstall linkchecker: exit status 1
    
  10. Manually remove the data from the database tables: linkchecker_index and linkchecker_link
  11. Try uninstalling: drush pm:uninstall linkchecker
  12. Result: Uninstall works

Proposed resolution

The drush linkchecker:clear option is misleading because it clears and rescans. It could be made to just clear/delete and then the user could delete the data there first before uninstalling. Or a delete command could be added to drush (though would be confusing to have both), and a button could be added to the UI to just delete.

Remaining tasks

  1. Figure out approach
  2. Update code
  3. Review and test
  4. Commit :)

User interface changes

Potentially there could be a delete/clear button in the UI that only deletes the data.

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇺🇸United States Kristen Pol Santa Cruz, CA, USA

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

Comments & Activities

  • Issue created by @Kristen Pol
  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA

    Update steps to reproduce.

  • 🇳🇴Norway eiriksm Norway

    While I understand what you mean very well, isn't this expected from modules providing content entities? I mean, the exact same thing would happen if you tried to uninstall the node or block_content module?

    Maybe I am misunderstanding you, in which case I am sorry 🤓 If that's the case, could I ask you to try to explain again? ❤️

  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA

    Sorry i wasn’t more clear. Normally for uninstalling, modules will have an uninstall hook and explain that there is data and it needs to be removed first and also provide and easy way to do that rather than having people have to manually delete database tables. Not everyone will know how to delete data in the database.

  • 🇮🇳India SandeepSingh199

    Yes i agree with eiriks, still if module needs a patch to cleanup i can get a patch for this cleanup scenario on module uninstall.

  • 🇺🇸United States simplyshipley

    I really like the idea of this module. and it seems to work well during my initial testing. But I'm not a fan of being forced to truncate production database tables to uninstall the module, so I will not be using it at this time. Are there plans to allow the linkchecker entities to be deleted through the UI in the future?

  • 🇺🇸United States simplyshipley

    I created a couple patches to help resolve this issue:

    linkchecker-add-remove-all-links-button-to-admin-settings-form-3386292-7.patch
    Adds a button to the LinkCheckerAdminSettingsForm.php file that allows users to delete all link data by reusing an existing method
    $this->linkCleanUp->removeAllBatch();

    linkchecker-added-delete-operation-and-route-to-linkchecker-entity-3386292-7.patch
    This patch adds a the delete operation to the custom entity. It adds the core\Entity\ContentEntityDeleteForm as the delete form and a matching delete link. I also mapped the "label" = "lid" so the link entity ids shows if using bulk operations. This patch also adds the new delete route to the LinkCheckerLinkRouteProvider.php.

    These patches allow users to delete individual link entities and/or delete all link entities to uninstall the module.

Production build 0.71.5 2024