“Comments aren’t working,” he said and I winced. I hate when people say ‘broken’ or ‘not working’ because I don’t magically know what they mean by ‘working.’ But this guy was a coworker whom I like and trust so I asked what he meant by not working, and he said “When you enter a comment, the page reloads, but there’s no comment.”
“Okay,” I muttered to myself. “Touché, Mika.” Because that, indeed, was ‘not working.’ We turned on debugging and got a strange error:
WordPress database error: [Duplicate entry '0' for key 'PRIMARY'] INSERT INTO `wp_comments` (`comment_post_ID`,`comment_author`,`comment_author_email`,`comment_author_url`,`comment_author_IP`,`comment_date`,`comment_date_gmt`,`comment_content`,`comment_karma`,`comment_approved`,`comment_agent`,`comment_type`,`comment_parent`,`user_id`) VALUES (507,'lori','admin@example.com','','12.248.40.138','2014-02-07 23:07:08','2014-02-07 23:07:08','test',0,'1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:26.0) Gecko/20100101 Firefox/26.0','',0,1)
And then it was a mess of ‘Trying to get property of a non-object…’ and ‘headers already sent.’
After some kicking of the usual suspects (reinstall WP, remove plugins, theme, etc) I realized I was stupid and the problem was that the table wasn’t updating the primary entry. It should start at 1 and move up to 2 and so on. Since everything else was working, I compared the table to a working one … and they were not the same. Here’s a good one:
There’s had comment_id
as the name, and the rest of the values were blank. So I restored the values and it worked! Except … I was getting a new error.
Notice: Undefined property: stdClass::$comment_ID in /home/wp-includes/comment.php on line 155 Warning: Cannot modify header information - headers already sent by (output started at /home/wp-includes/comment.php:155) in /home/wp-includes/pluggable.php on line 896
I stared at that for a moment and after I had given up and proposed we reinstall WP and copy tables over, my brain kicked in and I said “Wait a second, isn’t that comment_ID and not id?” I changed it on a whim and shouted “HOLY **** I AM GOOD!”
Yes, it was in all caps. Yes, it was said to my coworker, who said I have his vote.
That was, by far, the weirdest error I’ve seen in months. And the moral of all this? You can’t know everything, but if you read and pay attention and are willing to experiment, you can solve pretty much anything.
Comments
6 responses to “Not The Bug I Expected”
And how does one changed the comment_ID name in the table?
@Jack Beauregard: Turns out it was a strange flaw in a hacker backdoor! They were trying to overwrite the comments with their garbage, but had a typo. Jokes on them, I guess!
How in the world did it become all Caps in the first place?
@Mike Price: you mean why is it supposed to be comment_ID and not comment_id ? Dunno, probably old b2 reasons.
Why did I tweet in all caps? I’m excitable.
Crazy question – is this error you found related to this?
http://wordpress.org/support/topic/cant-mark-as-spam-or-delete-comments?replies=30
(Just an innocent bystander, trying to help out on the WP forums, and also a fan of yours Mika!)
Thank you! This wasn’t *exactly* my problem, but near enough that it helped get things fixed.
Details:
http://wordpress.org/support/topic/cant-mark-as-spam-or-delete-comments/page/2?replies=35#post-5376800