Accessing comment_id via event_hook

Creating and modifying plugins.
Post Reply
onli
Regular
Posts: 3044
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Accessing comment_id via event_hook

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Accessing comment_id via event_hook

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
onli
Regular
Posts: 3044
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Accessing comment_id via event_hook

Post 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
)
Last edited by onli on Thu Jun 11, 2009 5:13 pm, edited 1 time in total.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Accessing comment_id via event_hook

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
onli
Regular
Posts: 3044
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Accessing comment_id via event_hook

Post 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
Attachments
functions_comments.inc.diff.txt
(1.04 KiB) Downloaded 218 times
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Accessing comment_id via event_hook

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply