Accidentally deleted most of my posts in Wordpress

Posted on 2010-12-30 14:45

A friend emailed today that a couple of his comments here (specifically one on this post) had never shown up there and we wondered if they had been blocked by Akismet and I hadn't caught the false positive. I suggested that setting up an account with OpenID would be preferable since posts made by folks who authenticate that way don't need to be approved by me before they show up.

I had enabled OpenID logins here (mentioned at the bottom of this post) in November and I still intend to post about OpenID itself at some point. I tested it several times and was confident it was working fine, but now having gone out on a limb and telling someone else to use it I figured I should check it one more time.

I run my own OpenID provider script but as a test I used my Yahoo ID to log in and it created (I thought) a new user based on that OpenID. No worries! Since I didn't want to have another user on the system hanging out for no reason I immediately went in and deleted it. Wordpress warned me that all stories and comments made by that new user were going to be deleted, but hey - I had just created that user so who cares, right? Well - as it turned out I should have been a little more careful. Turns out logging in with that OpenID didn't create a new user - it got associated with an existing user (another identity of mine) which I had used for hundreds of posts in the past. Removing the user wiped out all posts made under that account!

I didn't notice what had happened right away. In fact, it was many hours later and only after I had received about 15 automatic email messages that get generated when folks try to access a page that is not found (404 error). Each message helpfully suggested that I should maybe do something about it soon. In the Wordpress dashboard there were only about 250 stories listed and I knew I had something over 600 just yesterday. Comments, usually something near to a thousand were down to about half of that. I did a search in Google for some popular pages of mine and clicking the link brought me to that 404 error page! Yikes, so much of my online journal was just instantly toast.

I wasn't sure what to do immediately but soon came to find all those posts had been simply moved to the "Trash" and I could just "restore" them (one page of about 25 posts at a time). Restoring brought back all posts and their associated comments the loss of which would have been devastating to me personally with posts as far back as 2004 affected. I was then able to use a SQL command through phpmyadmin to set the posts to have my current user id (they restored with no author because I had deleted that user):

update wp-posts set wp-author = '[my id]' where wp-author = '[my old bogus id]'