ElkArte Community

Elk Development => Bug Reports => Exterminated Bugs => Topic started by: scripple on March 07, 2014, 10:35:26 pm

Title: Inconsistent Hook Names
Post by: scripple on March 07, 2014, 10:35:26 pm
Not really a bug, but consistency is good.  In Post.subs.php createPost()

integrate_create_post <= Just before a post is created
integrate_after_create_post <= Just after a post is created.

integrate_before_create_topic <= Equivalent to integrate_create_post, but this one gets a before
integrate_create_topic <= Equivalent to integrate_after_create_post, but looks like integrate_create_post

There's also two integrate_modify which I believe are equivalent to integrate_create_post, so it's probably the topic ones that maybe should be renamed.
Title: Re: Inconsistent Hook Names
Post by: emanuele on March 09, 2014, 10:02:49 am
Quote from: scripple – Not really a bug, but consistency is good.  In Post.subs.php createPost()
True, consistency is good.

Quote from: scripple – integrate_create_post <= Just before a post is created
integrate_after_create_post <= Just after a post is created.

integrate_before_create_topic <= Equivalent to integrate_create_post, but this one gets a before
integrate_create_topic <= Equivalent to integrate_after_create_post, but looks like integrate_create_post
I'd say:
Code: [Select]
integrate_create_post => integrate_before_create_post
integrate_after_create_post => integrate_create_post
So that the scheme is the same?

Quote from: scripple – There's also two integrate_modify which I believe are equivalent to integrate_create_post, so it's probably the topic ones that maybe should be renamed.
Yes and no.
integrate_before_create_topic and integrate_modify_topic could be the same (even though there are differences on the kind of data passed), while integrate_modify_post and integrate_create_post are slightly different even in the parameters passed (create has one more).
It may be worth harmonize the parameters order in all these hooks...?
Title: Re: Inconsistent Hook Names
Post by: scripple on March 09, 2014, 11:58:09 am
By the two modify ones being equivalent to create_post I meant that they both happened before the modify did, giving you a chance to change things (exactly what I needed).  So they would be integrate_before_modify_xxx if you go with your proposed naming.  I'd be fine with that.
Title: Re: Inconsistent Hook Names
Post by: emanuele on March 10, 2014, 05:19:16 pm
Done here:
https://github.com/emanuele45/Dialogo/commit/56bfc6cf4a0f7e41730038657738ee6815c6808b