1

I've setup a Craft 3 site for a client and we are seeing the strangest thing where pages are just disappearing. Best we can tell no-one has deleted the entry, but we get a 404 on the front-end and it is not showing up on the back-end, even under "Trashed". What is weird is that when I re-create the page I can't use the same slug so it seems like it is still in the database. I've tried querying the database and I can see rows in the elements_sites table with that uri, but I don't know enough about the data scheme to tell where the disconnect is or tables to look at to determine which is the "live" version. One other note that may be related is several pages disappeared that were all sub-pages to a parent page (but the parent page is still there on the site)

Here is a query I ran for one of the pages that is missing:

Craft DB Query

Any suggestions for how to figure out what is happening or a query to run to determine which pages are live and where the disconnect may be for those pages?

  • Whenever I've experienced anything similar, it's because someone deleted a user and managed to completely ignore/misread the warning box that comes up asking if you also want to delete that user's content... – James Smith Aug 19 at 15:32
  • Thanks @JamesSmith. Is there any way to restore that content by re-assigning it to another user? – Austin Aug 19 at 15:34
  • Yes, that's one of the options that comes up during the use deletion process. – James Smith Aug 19 at 19:08
  • @JamesSmith What about if that option wasn't chosen during the deletion process. It looks like the data is still in the database. Is there a way to re-assign it in the database after the user was deleted? – Austin Aug 19 at 19:48
2

I finally got to the bottom of what happened. I deleted a user about a month ago and after 30 days (the soft delete period) Craft deleted all related pages that the user had originally created. Thankfully, I was able to restore those pages by re-creating records for each in the entries table with a different authorid.

I ran this script on a backup of the database to find the entries for that author.

select es.uri, c.title, et.*, e.* from entries e 
inner join entrytypes et on e.typeid=et.id
inner join elements el on e.id = el.id
inner join elements_sites es on es.elementid = el.id
left outer join content c on c.elementid = el.id
where e.authorid=DELETED_USER_ID
and el.revisionid is null

And then created insert scripts for the entries table for each one I needed to restore. The elements and other data was still in the database so I just had to re-create the entries records.

insert into entries (id, sectionid, parentid, typeid, authorid, postDate, deletedWithEntryType, dateCreated, dateUpdated, uid)
VALUES(ORIGINAL_ENTRY_ID, ORIGINAL_SECTION_ID, ORIGINAL_PARENT_ID, ORIGINAL_TYPE_ID, NEW_AUTHOR_USER_ID, ORIGINAL_POST_DATE, 0, ORIGINAL_DATE_CREATED, ORIGINAL_DATE_UDPATE, ORIGINAL_UID)
| improve this answer | |

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.