Wiki: Delete existing user fails

Created on 15 May 2020  路  2Comments  路  Source: Requarks/wiki

Describe the bug
Trying to delete an existing user fails with Cannot delete user because of content relational constraints.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new (local) user someuser.
  2. Create a page somepage as that user.
  3. Login as admin and try to delete someuser. The system will tell you that you are unable to delete users with existing content and will fail with Cannot delete user because of content. relational constraints.
  4. Login as someuser.
  5. Delete the page somepage
  6. Login as admin and try to delete someuser. The system will tell you that you are unable to delete users with existing content and will fail with Cannot delete user because of content. relational constraints.

Expected behavior
At Step 6. one should be able to delete someuser as all content by that user is removed.

Screenshots
See below.

Host Info (please complete the following information):

  • OS: Docker Container (Linux)
  • Wiki.js version: 2.3.81
  • Database engine: PostgreSQL 11.4
  • Node.js version: 12.16.1

Additional context
I checked the database for any references to the authorId of the user someuser and found an entry in pageHistory for the page somepage. My guess is that in the moment someuser deletes his page somepage this entry is created and now referencing the authorId of someuser which leads to the error when trying to delete that user.
After deleting the entry in pageHistory manually i was able to delete user someuser in the admin backend.
I thinks it is kind of a dilemma, not having an entry in pageHistory on deletion of pages interferes with restoring that page later i guess. So i think the long term best solution is to implement an authorship-transfer systems on user deletion where that authorId gets replaced all over the db. See request https://requarks.canny.io/wiki/p/transfer-authorship-of-pages

bug contrib-medium

Most helpful comment

Fixed by 1f9e5b3fd0e8329189f1eb9615465e78f42a98c2

A target user can now be selected where all content will be reassigned before deletion.

All 2 comments

  • Trying to delete someuser
    wikijs_delete_user_1

  • Deleting all content created by someuser (somepage)
    wikijs_delete_user_2

  • Trying again to delete someuser
    wikijs_delete_user_3

Bildschirmfoto 2020-05-20 um 15 53 33

Bildschirmfoto 2020-05-20 um 16 38 30

Bildschirmfoto 2020-05-20 um 16 40 04

Fixed by 1f9e5b3fd0e8329189f1eb9615465e78f42a98c2

A target user can now be selected where all content will be reassigned before deletion.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ccolella-mdc picture ccolella-mdc  路  3Comments

ccolella-mdc picture ccolella-mdc  路  3Comments

bennycode picture bennycode  路  4Comments

raikoug picture raikoug  路  3Comments

failover88 picture failover88  路  4Comments