Topic: Duplicate hooks / idea

The following hooks are duplicate (if you watch out, there won't be anymore - these are all for the whole source code right now):

aex_qr_delete_hooks
afo_qr_delete_forum_perms
fn_qr_add_online_user
fn_qr_add_online_guest_user

(in admin/extensions.php, admin/forums.php and twice include/functions.php).

----------------------------------------------------------------

Also, when subscribing to a topic, could it redirect to the place where you were? Really annoying (especially in big topics): You are always redirected to the beginning of the topic.

FluxBB - v1.4.8

Re: Duplicate hooks / idea

fn_qr_add_online_user/fn_qr_add_online_guest_user are actually meant to be duplicates. For most queries, we would simply use one hook at the end (before executing the query) and be done with it. However, in this case, we use a different function call depending upon the dblayer. So, we can't so easily put one hook just before the execution of the query (we're trying to avoid using another switch statement to determine which function to call).
But thank you, I've corrected the other duplicates. smile

Re: Duplicate hooks / idea

I still don't understand why they are duplicates, though...

lie2815 wrote:

Also, when subscribing to a topic, could it redirect to the place where you were? Really annoying (especially in big topics): You are always redirected to the beginning of the topic.

And what about this?

FluxBB - v1.4.8

Re: Duplicate hooks / idea

Well, I thought I did a pretty good job of explaining the duplicates above, but I'll try again. wink
Notice where they're used. They're both within a switch statement, in the two different cases, right before the query is run. Normally, we would put the hook outside of the switch statement and then call $db->query_build on the result.
However, in this case, to get around a race condition in our PostgreSQL code that led to duplicate posts, we use $db->query for PostgreSQL and $db->query_build for MySQL(i)/SQLite. So, we can't just put the hook outside and call a function: we don't know what function to call without another switch statement.
In this case, the duplication is almost irrelevant: if we were to put the hook outside and add an extra switch statement, people would have to deal with the code in the exact same way they would now. It would just look uglier from the perspective of the PunBB core code.

As for the subscription idea, I see nothing wrong with it (and it's not difficult, we already store the previous URL), but I want to see what other people think.

Re: Duplicate hooks / idea

Ok thanks. I guess it would have helped if I would have looked at the code tongue

Anyways, but if it is the same hook... I don't see why you should apply the same code to both queries since one of them is an array and the other one isn't...

FluxBB - v1.4.8

Re: Duplicate hooks / idea

For the same reason we don't have one hook per query per dblayer: they're all the same query, just formed differently to take care of the idiosyncrasies of the different systems. In this case, you simply do an is_array check rather than looking for a particular dblayer.

Re: Duplicate hooks / idea

i see. thanks

FluxBB - v1.4.8

Re: Duplicate hooks / idea

Well, I'm currently looking into a way to turn that query into query builder, so we'll see tongue