0

Since upgrading to craft 2.6.2785 when I delete a user it appears to remove the user from the elements and elements_il8n tables but does not delete the user from the users table.

If you then search for the user in the CMS it does not find them however the user has not been removed from the database so if you try and set up a new user with the same email address it fails with "email has already been taken message".


Update on this. I re-imported the database from dev to staging. In my dev deleting users works fine. When importing the database which is fairly large due to 20k+ users I get this error:

SQL Error (1452) Cannot add or update a child row:a foreign key constraint fails ('databaseName'.'#sql-1510_62265', CONSTRAINT 'craft_matrixcontent_newscontent_elementId_fk' FOREIGN KEY ('elementId') REFERENCES 'craft_elements' ('id') ON DELETE CASCADE)

Then when trying to delete a user it says it's deleted removes the elements from the element tables but does not remove the user from the users table.

2
  • Were any Entries authored by the deleted user?
    – Matt P
    Jun 8 '16 at 10:46
  • No no entries. I think this maybe to do with a possible corrupt database or plugin now so will investigate further.
    – Lettie
    Jun 8 '16 at 12:34
1

Solved this one by adding SET foreign_key_checks = 0; to the beginning of the SQL dump and SET foreign_key_checks = 1; at the end of the file. Not sure if it is the best solution but it certainly worked.

4
  • This is just kicking the can down the road. You've got inconsistent data in your database (for whatever reason) that should be fixed. Settings FK checks to 0 on import is just saying "ignore those problems".
    – Brad Bell
    Jun 8 '16 at 20:18
  • @bradbell yes I realise this. Can you suggest anyway of fixing the inconsistent data? What we need to check for and any preferred software to do it? Cheers.
    – Lettie
    Jun 9 '16 at 8:57
  • For this particular error, it's complaining about data that's in the elementId column of the craft_matrixcontent_newscontent table that is missing in the id column of the craft_elements table. So you'd want to write a SQL query that finds the missing data. stackoverflow.com/questions/3826929/…
    – Brad Bell
    Jun 9 '16 at 16:51
  • Cheers @bradbell will create something.
    – Lettie
    Jun 13 '16 at 8:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.