PDA

View Full Version : [fixed] Thread subscriptions stop after merge


melondog
Fri 5th Apr '02, 1:53pm
When a thread is moved or merged with another thread, the subscription to that thread is removed. I have several members reporting this. The current version we are running is 2.2.3, I'm not sure if this has been fixed since then.

Joshua Clinard
Tue 30th Jul '02, 6:17pm
Has anyone else had this problem?

Freddie Bingham
Tue 30th Jul '02, 6:34pm
I didn't check the code but I would guess that since the thread that the user subscribed to no longer exists, an entry for the 'new' thread isn't inserted.

Moving a thread would not affect subscriptions unless the thread is moved to a forum that the user no longer has access to.

Joshua Clinard
Tue 30th Jul '02, 6:43pm
Oh. Would it be possible to have the software insert an entry for the merged thread?

I'm gonna do some testing on subscribing to a moved thread.

Mike Sullivan
Tue 30th Jul '02, 8:54pm
It appears thread subscriptions from the merged thread are removed. Moving to see if there's something we can do about this without much trouble.

Paul
Tue 30th Jul '02, 10:13pm
Oh! I've always feared this! Everytime I've moved a thread, I've wondered.. "What will happen to subscribed users?" but I thought for sure the code would handle this.

I imagine at the simplest level, this would involve a query changing any subscriptions to the moved thread to the thread to which it is being merged with.

This wouldn't affect threads that have simply been moved to another forum, would it? The thread id stays the same.

[edit: never mind the last point, I just read freddie's post]

Paul

Paul
Mon 12th Aug '02, 6:10pm
Sure enough... a delete is being done from subscribedthreads for the old threadid...


$DB_site->query("DELETE FROM subscribethread WHERE threadid='$mergethreadid'");


There's no update being issued. I believe the following code will solve the problem:

REPLACE the above code with:


// Bug fix: Merge threads does not update thread subscription - Aug 12, 2002 - Paul
// $DB_site->query("DELETE FROM subscribethread WHERE threadid='$mergethreadid'");
$DB_site->query("UPDATE subscribethread SET threadid='$threadid' WHERE threadid='$mergethreadid'");
// End bug fix: merge threads does not update thread subscription


My only concern would be a situation where the thread was merged with a thread in a forum that the user no longer has access to. Is this a valid concern?

Paul

Paul
Mon 12th Aug '02, 6:59pm
It appears that the above would be a valid concern as sendnotification() does not check permissions before sending out e-mails. We'll need to put in some if-else statements. I'll work on this in a little bit.

Paul

Mike Sullivan
Mon 12th Aug '02, 7:44pm
Try replacing the original line with this batch of code:

// move subscribed users without making duplicate entries
$subusers = $DB_site->query("SELECT user.userid, usergroupid FROM subscribethread,user WHERE subscribethread.userid=user.userid AND subscribethread.threadid='$threadid'");
$subuserlist = '0';
while ($thissubuser = $DB_site->fetch_array($subusers)) {
if ($mergethreadinfo['forumid']!=$threadinfo['forumid']) {
$perms = getpermissions($threadinfo['forumid'], $thissubuser['userid'], $thissubuser['usergroupid']);
if ($perms['canview'] AND ($threadinfo['postuserid'] == $thissubuser['userid'] OR perms['canviewothers'])) {
$subuserlist .= ",$thissubuser[userid]";
}
} else {
$subuserlist .= ",$thissubuser[userid]";
}
}
$DB_site->query("UPDATE subscribethread SET threadid='$threadid' WHERE threadid='$mergethreadid' AND userid NOT IN ($subuserlist)");
$DB_site->query("DELETE FROM subscribethread WHERE threadid='$mergethreadid'");

Paul
Tue 13th Aug '02, 2:01am
Thanks Mike! :) We'll try it out and see how it goes.

Paul
Tue 13th Aug '02, 7:47am
Eeek!

I get a parse error on this line:

if ($perms['canview'] AND ($threadinfo['postuserid'] == $thissubuser['userid'] OR perms['canviewothers'])) {


:: stares at code ::

Taking out OR perms['canviewothers'] makes it go away.. what the heck is canviewothers? ;)

Paul

Edit: Nevermind... There's a missing $... duh ;)

Paul
Tue 13th Aug '02, 7:55am
Use this code:


// move subscribed users without making duplicate entries
$subusers = $DB_site->query("SELECT user.userid, usergroupid FROM subscribethread,user WHERE subscribethread.userid=user.userid AND subscribethread.threadid='$threadid'");
$subuserlist = '0';
while ($thissubuser = $DB_site->fetch_array($subusers)) {
if ($mergethreadinfo['forumid']!=$threadinfo['forumid']) {
$perms = getpermissions($threadinfo['forumid'], $thissubuser['userid'], $thissubuser['usergroupid']);
if ($perms['canview'] AND ($threadinfo['postuserid'] == $thissubuser['userid'] OR $perms['canviewothers'])) {
$subuserlist .= ",$thissubuser[userid]";
}
} else {
$subuserlist .= ",$thissubuser[userid]";
}
}
$DB_site->query("UPDATE subscribethread SET threadid='$threadid' WHERE threadid='$mergethreadid' AND userid NOT IN ($subuserlist)");
$DB_site->query("DELETE FROM subscribethread WHERE threadid='$mergethreadid'");