phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

Thread owner bug

Goto page Previous  1, 2
 
Search this topic... | Search phpBB2 Discussion... | Search Box
Register or Login to Post    Index » phpBB2 Discussion  Previous TopicPrint TopicNext Topic
Author Message
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 449
Location: Québec


flag
PostPosted: Mon Jul 02, 2012 12:51 pm 
Post subject: Re: Thread owner bug

hoimyr wrote:
Do we need to test other things just to be shure that everything is working?

Yes, we'll need to check in detail which cases need the first part of the fix to apply to them (if ( $mode == 'editpost' ) // Should other modes be added? delete_poll? topicreview?)
Basically, I would say everything that a mod can do to someone else's post/every type of post.

drathbun wrote:
if an admin edits the first post of an existing topic, then no notification should be sent. It's just an edit.(...)
But editing should not trigger a notification...

Editing does not send a notification, but adds the mod/admin to the notification list for that thread. So when there is a reply, they receive an unwanted notification. And of course on the other side there's the actual user's notifications that get changed in some cases.
Back to top
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Mon Jul 02, 2012 2:32 pm 
Post subject: Re: Thread owner bug

Ok when i did all the tests again after the new code-changes the result was exactly the same as last time. icon_confused.gif So the admin that edits still gets mail i many cases.
Will go over all the edits again and do all the tests a second time just to be shure.

edit: reinstalling and testing done. No change of result.
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 729
Location: Texas


flag
PostPosted: Mon Jul 02, 2012 2:46 pm 
Post subject: Re: Thread owner bug

Salvatos wrote:
Editing does not send a notification, but adds the mod/admin to the notification list for that thread. So when there is a reply, they receive an unwanted notification. And of course on the other side there's the actual user's notifications that get changed in some cases.

Weird. I've never noticed this as an issue. I will do some testing on the codebase used here and see if it works the same way.

_________________
phpBBDoctor Blog
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 729
Location: Texas


flag
PostPosted: Mon Jul 02, 2012 8:02 pm 
Post subject: Re: Thread owner bug

I created a topic as "drathbun" and marked it to notify me on replies. The row in the phpbb_topics_watch table looked like this:
Code:
+----------+---------+---------------+
| topic_id | user_id | notify_status |
+----------+---------+---------------+
|      923 |     103 |             0 |
+----------+---------+---------------+

User 103 is drathbun, and topic 923 is the new topic I created in the off-topic area.

Next I logged in as the admin and edited the topic. When I checked the topic_watch record it looked identical. Then I posed a reply as the admin, which should trigger the notify process. When I checked the row of the topic watch table it looked like this:
Code:
+----------+---------+---------------+
| topic_id | user_id | notify_status |
+----------+---------+---------------+
|      923 |     103 |             1 |
+----------+---------+---------------+

That is as expected. I logged back in to the site as user "drathbun" and read the topic, which flipped the switch back to zero.

Code:
+----------+---------+---------------+
| topic_id | user_id | notify_status |
+----------+---------+---------------+
|      923 |     103 |             0 |
+----------+---------+---------------+


So nothing is broken on this site, as everything is behaving as expected.

What I suspect is happening is that on some boards there is a MOD that is getting confused by when to update the phpbb_topics_watch table.

The edit I did was for text only. I did not try to reset the "notify me" checkbox as the admin. I am going to test that next.

[Edit]
When I reset the "notify me" tag as the administrator, it did not override the setting selected by the original user.

[Edit 2]
When I reset any of the post attributes like "Enable BBCode" or "Show Signature" then they took. But the admin could not reset the "notify me on replies" setting. I don't know if that's a bug or not, but it's the opposite of what the rest of you are reporting. I should point out that the base code for this site is fairly old, so there may have been a bug fix or patch in an interim release that affected this process. All security patches were applied as they were released, but I did not always apply functional changes unless I knew what they were fixing. So this site may not behave as a standard phpBB2 site would.

_________________
phpBBDoctor Blog
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 729
Location: Texas


flag
PostPosted: Mon Jul 02, 2012 8:27 pm 
Post subject: Re: Thread owner bug

Here is what I have observed after further inspection. The code (which I believe is the same as pointed out previously in this topic) is responsible for checking the "Notify me on replies" checkbox during posting or edits. First, check the state of the form. If we are submitting or refreshing the screen we obtain the value from the form only:
Code:
if ( $submit || $refresh )
{
        $notify_user = ( !empty($HTTP_POST_VARS['notify']) ) ? TRUE : 0;
}

If we're not submitting or refreshing the screen, then we go check the phpbb_topic_watch table to see if the user that owns the post is currently watching the topic. Note that as previously observed in this topic, this query uses the $userdata['user_id'] value, which means it looks to see if the editing user is watching this topic.
Code:
else
{
        if ( $mode != 'newtopic' && $userdata['session_logged_in'] )
        {
                $sql = "SELECT topic_id
                        FROM " . TOPICS_WATCH_TABLE . "
                        WHERE topic_id = $topic_id
                                AND user_id = " . $userdata['user_id'];
                if ( !($result = $db->sql_query($sql)) )
                {
                        message_die(GENERAL_ERROR, 'Could not obtain topic watch information', '', __LINE__, __FILE__, $sql);
                }

What's next? If a row is returned, then we set the notify checkbox accordingly. If no row is returned, then we set the notify flag based on the user's preference.
Code:
                $notify_user = ( $db->sql_fetchrow($result) ) ? TRUE : $userdata['user_notify'];
        }
        else
        {
                $notify_user = ( $userdata['session_logged_in'] ) ? $userdata['user_notify'] : 0;
        }
}

That code doesn't do anything but check the status of the HTML form field and default it to either the current form value, the current watch value, or the user profile setting in that order.

Now how does the row get inserted / updated / deleted from the phpbb_topics_watch table? That takes place in the includes/functions_post.php code, in the notify_user() function. In each case there is a check that makes sure that the post owning user and the editing user are the same.

So I conclude that in the standard code, or at least in the code in use on this site, it is not possible for a moderator or admin to alter the notify setting for another user by editing their post. I think that's the way it should be. Also when an admin edits a post in a topic, it should NOT (in my opinion) set up a watch for the admin on that topic simply by editing a post. The admin should either watch the topic using the standard feature (link) or add a post of their own.

Bottom line, I think it's working as designed. I checked the 2.0.23 code and it seems to match, at least in the areas that are impacted by this. I did not do a thorough review.

_________________
phpBBDoctor Blog
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 449
Location: Québec


flag
PostPosted: Mon Jul 02, 2012 9:49 pm 
Post subject: Re: Thread owner bug

drathbun wrote:
What I suspect is happening is that on some boards there is a MOD that is getting confused by when to update the phpbb_topics_watch table. (...)
So I conclude that in the standard code, or at least in the code in use on this site, it is not possible for a moderator or admin to alter the notify setting for another user by editing their post.

But Hoimyr stated that he performed his tests on a clean 2.0.23, and regardless of the code, the results speak for themselves. The second column (mod/admin) should show NO in every case, as you said, yet they don't.

I was going to type a lot of stuff here but let me just post my conclusions.

First, the Always setting is mostly irrelevant. Unless I missed something, all it does is tick the checkbox for you when you create a new post. If you manually change it, the checkbox status prevails, as the test demonstrates. So the user behaviour is fine, minus one exception I'll get back to later.

Second, mods/admins should never be notified. The test shows that they are added to the list when their Always option is on, never mind the checkbox. I can't check right now, but I would wager that that comes from the user_notification function, because it adds $userdata[user_id] regardless of the posting mode, but the $notify_user variable is probably part of it as well. I'll have to look into it.

Third is the exception I mentioned. This needs to be tested, but mods/admins can change the checkbox status. I suspect this may be where the original complaint came from. If an admin edits a post where the user is notified and unticks the checkbox because they don't want a notification, it possibly turns the notification off for the user. Though with what I've seen in the code I'm not sure that's the case, but I'd rather let the tests verify that.

In other words... we need more thorough tests.
Back to top
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Tue Jul 03, 2012 3:37 am 
Post subject: Re: Thread owner bug

Thanks for the check drathbun.

I can give you both the acces codes, ftp, sql and everything for my testsite. If you need. There you can go crazy with testing. Install, delete everything aso. I dont use it anyways. Just dont remove the frontpage and link to this site icon_wink.gif You can contact me on: thomas [at] 3dhue [dot] no.
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 729
Location: Texas


flag
PostPosted: Tue Jul 03, 2012 9:53 am 
Post subject: Re: Thread owner bug

Well, that raises an interesting point. I did not check to see if an email was actually sent. All I did was check the status of the database record. But again, edits should not trigger a notify email, only new posts will.
_________________
phpBBDoctor Blog
Back to top
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Tue Jul 03, 2012 11:30 am 
Post subject: Re: Thread owner bug

The edits do not generate mails. But when someone replies to the post that is idited. Something happens to the ownership when it is edited..
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 729
Location: Texas


flag
PostPosted: Tue Jul 03, 2012 12:27 pm 
Post subject: Re: Thread owner bug

That's why I checked the database. The notify emails are driven by the existing of a row in the phpbb_topics_watch table, and specifically by the status of the notify_status field in that table. If there is no row in the table, then no notification email will be sent.

I will go back and redo my test and check for actual emails being sent.

_________________
phpBBDoctor Blog
Back to top
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Wed Jul 11, 2012 5:58 pm 
Post subject: Re: Thread owner bug

Ok did you get any mails from the tests on your board? I did some testing on the database this time. Dont know if it helps anything.
Im testing with 3 users, fresh install, all different emails.


I watched the tables when:

1. user id 3 (normal user) make post
2. admin edits (id 2)
The "Notify me" ticked on in post.


1. Tables updated, rows, (more info):
phpbb_forums, 1
phpbb_posts, 49 (poster_id: 3)
phpbb_posts_text, 49
phpbb_search_wordlist, 81
phpbb_search_wordmatch, 110
phpbb_sessions, 1
phpbb_topics, 27
phpbb_topics_watch, 26 (#26, topic_id: 27, user_id: 3, notify_status: 0)
phpbb3_users, 4 (user_notify: 0,0,1,0) ..second is admin, third is the user.


2. Tables updated, rows:
phpbb_posts_text, 49
phpbb_search_wordlist, 82
phpbb_search_wordmatch, 110
phpbb_topics, 27
phpbb_topics_watch, 27 (#27, topic_id: 27, user_id: 2, notify_status: 0) <--it did change here
phpbb_users, 4 (user_notify: 0,0,1,0)


...and test 3. User id 4 reply on post. User id 2 (admin) and 3 got mail.
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 729
Location: Texas


flag
PostPosted: Thu Jul 12, 2012 10:15 am 
Post subject: Re: Thread owner bug

I have not redone my tests yet. I have a deadline to make to release my new code, so am spending time working on that rather than other stuff right now.
_________________
phpBBDoctor Blog
Back to top
Display posts from previous:   
Register or Login to Post    Index » phpBB2 Discussion  Previous TopicPrint TopicNext Topic
Page 2 of 2 All times are GMT - 4 Hours
Goto page Previous  1, 2
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0757 seconds using 16 queries. (SQL 0.0137 Parse 0.0011 Other 0.0610)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo