Page 1 of 1
Accessing comment_id via event_hook
Posted: Thu Jun 11, 2009 1:45 pm
by onli
Sorry to bother you with the following:
I'm trying to write a plugin that adds some functionality to made comments for a short time. To identify the comments made by a specific user, I wanted to save the session_id() combined with the comment_id. But I don't succeed in reading the comment_id. Shouldn't something like
Code: Select all
case 'frontend_saveComment_finish':
...
$cid = $addData['comment_id'];
access the comment_id? Or am I misinterpreting the event_hook and have to access the $eventData (how exactly?)?
sincerely
Re: Accessing comment_id via event_hook
Posted: Thu Jun 11, 2009 3:48 pm
by garvinhicking
Hi!
I don't have the code right now, but in those cases I usually fopen() a logfile for writing, and simply dump a print_r() of $eventData and $addData to the file, and then see what the keys/values are...?
Regards,
Garvin
Re: Accessing comment_id via event_hook
Posted: Thu Jun 11, 2009 4:56 pm
by onli
Thanks Garvin.
Going that way revealed $addData was really empty, I forgot to add it to the event_hook-call.
I fear that the 'comment_id' ain't what I searched. Neither $eventData nor $addData contain an unique_id which I could use to identify the saved comment when it get fetched again. comment_id seems to be just the entry_id. Do I oversee something?
sincerely
PS:
Code: Select all
Array #$eventData
(
[0] => 31
[id] => 31
[1] => true
[allow_comments] => true
[2] => false
[moderate_comments] => false
[3] => 1242926209
[last_modified] => 1242926209
[4] => 1238248604
[timestamp] => 1238248604
[5] => Autotitle-Test
[title] => Autotitle-Test
)
Array #addData
(
[url] =>
[comment] => Mit Anmeldung.
[name] =>
[email] =>
[subscribe] =>
[parent_id] => 0
[type] => NORMAL
[source] => internal
[comment_id] => 31
)
Re: Accessing comment_id via event_hook
Posted: Thu Jun 11, 2009 5:04 pm
by garvinhicking
Hi!
You're right. The return value of serendipity_insertComment() is not stured. This is a bug of the s9y core, we need to store that and commit it to trunk.
Until then, you might want to call serendipity_db_insert_id() again in the frontend_savecomment_finish hook, and hope that no other plugin listened on that hook already and made a new insert statement
Regards,
Garvin
Re: Accessing comment_id via event_hook
Posted: Thu Jun 11, 2009 5:22 pm
by onli
Simply set comment_id to $cid of serendipity_insertComment()? I attached a diff
I'm totally fine with waiting with the next steps of the plugin until this is solved.
sincerely
Re: Accessing comment_id via event_hook
Posted: Fri Jun 12, 2009 4:29 pm
by garvinhicking
Hi!
Sorry, I forgot to report back here. Yesterday I committed an update and now set "comment_cid" to $cid. I left "comment_id" to point to $id, because it might be that other people's plugin already used that..
Regards,
Garvin