i donât think this is a corrupt database per se. I have seen many kind-of-legit cases where changing post ownership fails , especially where the destination user has less privileges than the original user.
I replaced the arguments that are sensitive with placeholders âsourceâ, âtargetâ. I donât believe the database is corrupt as it would bring on a whole new slew of issues but is there any way I can check off hand?
This would definitely be the case as we are merging a previous admin account into a basic user account.
Further more, I removed all admin abilities and mod privileges and tried to merge the accounts again with no success.
Because it fails in line 10 of post_owner_changer.rb (this is where posts are moved from the source to the target user) and the only object that can be nil at that place is @topic. That leads me to believe that you have at least one post with a topic_id that points to a missing topic in the database.
Looking at this here with @Jim.Morrison and itâs listing out some topic IDs which pull up âOoops! That page doesnât exist or is privateâ⌠We did a migration with @pfaffman about a year ago and I am wondering if some of these are a result of that? Do we just need to do a rake task that can be run to rebuild / remap titles?
I suggest you either delete the posts via PostDestroyer.new(Discourse.system_user, post).destroy or update the topic_id with the ID of a new topic. Youâd also need to make sure that the post_number is unique in that topic.
Deleting is probably easier and I guess you donât need them otherwise youâd have missed them already.
My guess is that some of the posts are in topics that only an admin can write and or read. He wonât be able to access those posts if he is not an admin.
You might be able to do it the other way.
Merge the non admin account into the admin account, then rename the admin account to the non admin account, then remove the admin privileges.
He will still get âOopsâ on topics in categories that he no longer has access to.
No, itâs definitely a missing topic. There are no security checks in database queries! My guess is that someone deleted one or more topics from the database without deleting all the stuff connected to it.