One of the 2 lines (or both?) is causing the error calling qa_cookie_get_create()
1. https://github.com/NoahY/q2a-badges/blob/master/qa-badge-check.php#L627
2. https://github.com/NoahY/q2a-badges/blob/master/qa-plugin.php#L225
Issue @github: https://github.com/NoahY/q2a-badges/issues/22
I analyzed the badges causing the error, these are the ones:
badge_slug=notable_question
badge_slug=popular_question
badge_slug=reader
badge_slug=avid_reader
--
The following code change did not solve the issue.
In qa-plugin.php I am using now from line 220:
$handle = qa_getHandleFromId($uid);
// added 2 lines and changed mysql statement below replacing qa_cookie_get_create() with $cookieid
$userid=qa_get_logged_in_userid();
$cookieid=isset($userid) ? qa_cookie_get() : qa_cookie_get_create(); // create a new cookie if necessary
qa_db_query_sub(
'INSERT INTO ^eventlog (datetime, ipaddress, userid, handle, cookieid, event, params) '.
'VALUES (NOW(), $, $, $, #, $, $)',
qa_remote_ip_address(), $uid, $handle, $cookieid, 'badge_awarded', 'badge_slug='.$badge_slug.($oid?"\t".'postid='.$oid:'')
);
In qa-badge-check.php I am using now from line 622:
$handle = qa_getHandleFromId($user_id);
// added 2 lines and changed mysql statement below
$userid=qa_get_logged_in_userid();
$cookieid=isset($userid) ? qa_cookie_get() : qa_cookie_get_create(); // create a new cookie if necessary
qa_db_query_sub(
'INSERT INTO ^eventlog (datetime, ipaddress, userid, handle, cookieid, event, params) '.
'VALUES (NOW(), $, $, $, #, $, $)',
qa_remote_ip_address(), $user_id, $handle, $cookieid, 'badge_awarded', 'badge_slug='.$badge_slug.($object_id?"\t".'postid='.$object_id:'')
);`
Posted at github as well.