Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
in Q2A Core by
A question on my site is by a deleted user (note: unrelated to previous refill problems I had, but I double-checked and the post has NULL as the userid). The username appears as "anonymous", and when logged in as admin it links to an IP address page (IP is based in Canada).

But for some reason it's showing the "I wrote this" button on the post for me. And not just as admin, it shows it when I log in as the test account, even though I have a completely different IP (I am in the UK).

I thought the post claiming button only showed for users on the same IP?
Q2A version: 1.5.2
I also just saw that and was wondering what triggered it. I'm looking forward to the reply.

1 Answer

+1 vote

The 'I wrote this' appears if your Q2A cookie (named qa_id) matches the cookieid of an anonymous post. It is there to allow the following sequence of events:

  1. A registered user visits your Q2A site
  2. The user doesn't notice they are not logged in
  3. The user posts some content such as an answer
  4. The user sees it was posted anonymously because they weren't logged in
  5. The user notices their error and now logs in
  6. The user click 'I wrote this' to reassign the anonymous post to their user
Hmm, that's strange. This is showing for me (admin, Chrome) and my test user (Firefox) but there is no qa_id cookie in either browser. Only qa_noticed (value of 1) and qa_session (value of TestUser%2Ff4aw3s19%2F1). Same goes for the admin account. The question ID is 47516.

Does the "I wrote this" appear for *anyone* who clicks "Log in" from an anonymous post? Or does their IP have to match? (I did that sequence from a test user, but not admin.)
Looking at the Q2A source code, I think it might show if the post has a null cookieid in the database, and there is no cookie set in the browser. Does that match your case? I think I need to tighten that up a little...
Yes, the cookieid is NULL for the post. In fact, *every* row from the posts table has cookieid=NULL. I guess that only gets filled in if the post was originally made anonymously?

Edit: also, still having a problem here after fixing the refill stuff: http://www.question2answer.org/qa/17117/
Yes the cookieid is NULL if it was made by a user. So what happened here is that the user was deleted, making the userid NULL as well, and this is what let to the erroneous allowing of "I wrote this". Will fix in Q2A 1.5.3...