Avatar

"edited by" in 2.3.7 Shows wrong if post is moved category (Bugs)

by Magma, Wednesday, December 07, 2016, 02:33 (2691 days ago)
edited by Magma, Wednesday, December 07, 2016, 02:38

Problem

If a post is edited by a moderator and moved to a different category the post is shown to be edited by the poster instead of by the moderator.

Example

User Chris posts a thread, Moderator Mark edits the post and clicks 'ok - submit' and it shows "edited by Moderator Mark" which is fine but if Moderator Mark edits the post and moves the post to a different category the post shows as "edited by User Chris" which is wrong.

Can you advise on what code needs changing?

Thanks

Avatar

"edited by" in 2.3.7 Shows wrong if post is moved category

by Micha ⌂, Wednesday, December 07, 2016, 19:56 (2690 days ago) @ Magma

Example

User Chris posts a thread, Moderator Mark edits the post and clicks 'ok - submit' and it shows "edited by Moderator Mark" which is fine but if Moderator Mark edits the post and moves the post to a different category the post shows as "edited by User Chris" which is wrong.

First test case:

1. A user create a new thread.
2. A mod edit this posting. --> "edited by mod" is shown
3. A mod changed the category --> "edited by mod" is shown
4. A mod changed the category AND edit the posting --> "edited by mod" is shown

Second test case

1. A user create a new thread.
2. A mod changed the category AND edit the posting --> "edited by mod" is shown

Can you advise on what code needs changing?

I'm sorry, I cannot reproduce your issue.

/Micha

--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences

Avatar

"edited by" in 2.3.7 Shows wrong if post is moved category

by Magma, Wednesday, December 07, 2016, 22:16 (2690 days ago) @ Micha
edited by Magma, Wednesday, December 07, 2016, 23:09

Apologies, I looked back on it and it's for guest posters.


1. A non registered user create a new thread.
2. A mod edit this posting. --> "edited by mod" is shown
3. A mod changed the category --> "edited by non registered user" is shown
4. A mod changed the category AND edit the posting --> "edited by non registered user" is shown


*edited to say it may be when it's moved category for a second time.

Avatar

confirmed: "edited by", wrong name if category is changed

by Auge ⌂, Thursday, December 08, 2016, 16:08 (2689 days ago) @ Magma

Hello

1. A non registered user create a new thread.
2. A mod edit this posting. --> "edited by mod" is shown
3. A mod changed the category --> "edited by non registered user" is shown

Until here I can confirm your observation. I create a thread as an unregistered user in one browser and alter the content of the entry as the admin in another browser. After this first edit the username of my admin-account is shown, if it's not disabled to show the admins name. After changing the category as the administrator in a second attempt, the name of the (unregistered) thread opener is shown in the entry-is-edited-message.

4. A mod changed the category AND edit the posting --> "edited by non registered user" is shown

After changing the content of the entry and altering the category again, the entry-is-edited-message says, that it was done by the admin, not by the thread opener.

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!

Avatar

confirmed: "edited by", wrong name if category is changed

by Magma, Thursday, December 08, 2016, 16:48 (2689 days ago) @ Auge

Hello

1. A non registered user create a new thread.
2. A mod edit this posting. --> "edited by mod" is shown
3. A mod changed the category --> "edited by non registered user" is shown


Until here I can confirm your observation. I create a thread as an unregistered user in one browser and alter the content of the entry as the admin in another browser. After this first edit the username of my admin-account is shown, if it's not disabled to show the admins name. After changing the category as the administrator in a second attempt, the name of the (unregistered) thread opener is shown in the entry-is-edited-message.


I have the forum set up so Guest's can post but not edit their post, so if a Guest post is edited or changed by a Moderator it should never ever show as "edited by Guest" but it does if you follow this chain of events that I posted.

1. A guest creates a new thread.
2. A mod changes the category AND edits the posting --> "edited by mod" is shown which is fine but
3. A mod changes only the category again --> "edited by guest" is shown

Avatar

confirmed: "edited by", wrong name if category is changed

by Auge ⌂, Thursday, December 08, 2016, 17:16 (2689 days ago) @ Magma

Hello

Did you read, what I wrote? :confused:

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!

Avatar

confirmed: "edited by", wrong name if category is changed

by Magma, Thursday, December 08, 2016, 18:26 (2689 days ago) @ Auge

I did read it but not exactly sure what you're saying? you're confirming the problem after the first 3 points

1. A non registered user create a new thread.
2. A mod edit this posting. --> "edited by mod" is shown
3. A mod changed the category --> "edited by non registered user" is shown

and then you say

4. A mod changed the category AND edit the posting --> "edited by non registered user" is shown

After changing the content of the entry and altering the category again, the entry-is-edited-message says, that it was done by the admin, not by the thread opener.

But point 4 should not even come into it?


The key fact is plain and simple, If I have the settings set for Guests not to be able to edit their posts it doesn't matter whether the moderator edits the content of the message or whether the moderator keeps moving the thread to different categories, it should at no point ever say it was "edited by guest" and it does.

Avatar

confirmed: "edited by", wrong name if category is changed

by Auge ⌂, Friday, December 09, 2016, 08:09 (2688 days ago) @ Magma

Hello

and then you say

4. A mod changed the category AND edit the posting --> "edited by non registered user" is shown

After changing the content of the entry and altering the category again, the entry-is-edited-message says, that it was done by the admin, not by the thread opener.

But point 4 should not even come into it?

What's wrong with stating an edit by the admin, in the case the admin does it? This is, what happened during my tests and thatswhy I had to disagree.

The key fact is plain and simple, If I have the settings set for Guests not to be able to edit their posts it doesn't matter whether the moderator edits the content of the message or whether the moderator keeps moving the thread to different categories, it should at no point ever say it was "edited by guest" and it does.

Yes, I agree and I confirmed your observations in the first three points. But I had to contradict your fourth point because my observations differed from yours.

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!

Avatar

"edited by" in 2.3.7 Shows wrong if post is moved category

by Magma, Thursday, December 08, 2016, 00:04 (2690 days ago) @ Micha
edited by Magma, Thursday, December 08, 2016, 00:10

Ok to explain again as I just got time to try it myself instead of my mod telling me, it seems to be a problem with guest threads, not registered user.

1. A guest creates a new thread.
2. A mod changed the category AND edit the posting --> "edited by mod" is shown
3. A mod changes only the category again --> "edited by guest" is shown

if you follow that you should be able to recreate the problem in 2.3.7

Thanks again

Avatar

"edited by" in 2.3.7 Shows wrong if post is moved category

by Micha ⌂, Thursday, December 08, 2016, 19:05 (2689 days ago) @ Magma

Hi,

okay, lets have a try with the following suggestion. In posting.inc.php look for the following lines (line 966ff)

if(isset($_SESSION[$settings['session_prefix'].'user_type']) && $_SESSION[$settings['session_prefix'].'user_type']==2 && $settings['dont_reg_edit_by_admin']==1 || ...
        {
         // unnoticed editing for admins and mods
         $edited_query = 'edited';
         $edited_by_query = 'edited_by';
         $locked_query = 'locked';
        }

I believe, the if-statement is the problem. Please replace it by the following one:

if(isset($_SESSION[$settings['session_prefix'].'user_type']) && $_SESSION[$settings['session_prefix'].'user_type']==2 && $settings['dont_reg_edit_by_admin']==1 || isset($_SESSION[$settings['session_prefix'].'user_type']) && $_SESSION[$settings['session_prefix'].'user_type']==1 && $settings['dont_reg_edit_by_mod']==1 || ($field['text']==$text && $field['subject']==$subject && ($field['user_id']>0 || $field['name']==$name && $field['location']==$location) && isset($_SESSION[$settings['session_prefix'].'user_type']) && ($_SESSION[$settings['session_prefix'].'user_type']==2 && $settings['dont_reg_edit_by_admin']==1 || $_SESSION[$settings['session_prefix'].'user_type']==1 && $settings['dont_reg_edit_by_mod']==1)))

Can you report your experience for several test cases?

Thank you
/Micha

--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences

Avatar

"edited by" in 2.3.7 Shows wrong if post is moved category

by Auge ⌂, Friday, December 09, 2016, 08:24 (2688 days ago) @ Micha

Hello

I believe, the if-statement is the problem.

Are you sure? The observation says, there is a wrong name/user_account shown. It says not, that the condition to show or show not edits by an admin or mod failed.

Please replace it by the following one:

if(isset($_SESSION[$settings['session_prefix'].'user_type']) && $_SESSION[$settings['session_prefix'].'user_type']==2 && $settings['dont_reg_edit_by_admin']==1 || isset($_SESSION[$settings['session_prefix'].'user_type']) && $_SESSION[$settings['session_prefix'].'user_type']==1 && $settings['dont_reg_edit_by_mod']==1 || ($field['text']==$text && $field['subject']==$subject && ($field['user_id']>0 || $field['name']==$name && $field['location']==$location) && isset($_SESSION[$settings['session_prefix'].'user_type']) && ($_SESSION[$settings['session_prefix'].'user_type']==2 && $settings['dont_reg_edit_by_admin']==1 || $_SESSION[$settings['session_prefix'].'user_type']==1 && $settings['dont_reg_edit_by_mod']==1)))

Holy shit! What a monster. :-)

I'll have a (confused) look into it too.

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!

Avatar

"edited by" in 2.3.7 Shows wrong if post is moved category

by Micha ⌂, Friday, December 09, 2016, 08:52 (2688 days ago) @ Auge

Hi,

I believe, the if-statement is the problem.


Are you sure?

Check it. ;-)

/Micha

--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences

Avatar

"edited by" in 2.3.7 Shows wrong if post is moved category

by Auge ⌂, Friday, December 09, 2016, 23:09 (2688 days ago) @ Micha

Hello

I believe, the if-statement is the problem.


Are you sure?

Check it. ;-)

I didn't check your solution until now. But I played a bit around in one of my own installations with an additional open browser tab with phpMyAdmin in it. I clearly can see, that every time, I edited an entry the row edited_by got the value 1. This is the only existing account, my own as the forums admin.

There is only one exception. If I only change the category and nothing else, the value of edited_by will be set to 0. As there is only one entry by an unregistered visitor and this is the edited one, the name of the editor is specified with the nema of the author of the entry.

The problem seems to be somewhere in the posting.inc.php. But that can wait until tomorrow. Here it's past twelve pm now. So everything can wait, except my bed. :-)

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!

Avatar

"edited by" in 2.3.7 Shows wrong if post is moved category

by Micha ⌂, Friday, December 09, 2016, 23:16 (2688 days ago) @ Auge

Hello,

So everything can wait, except my bed. :-)

so early :-P

/Micha

--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences

Avatar

"edited by" in 2.3.7 Shows wrong if post is moved category

by Auge ⌂, Saturday, December 10, 2016, 16:01 (2687 days ago) @ Micha

Hello

I believe, the if-statement is the problem.


Are you sure?

Check it. ;-)

Meanwhile I dit it (without a live test!). What bugs me is the logic of the single blocks. Let me formulate this with words.

If the acting user is an admin and his edits should not be mentioned or the acting user is an mod and his edits should not be mentioned or the content of the text and subject fields are not changed and the user-id stays the same or the name is unchanged and the location stays the same and the acting user is an admin and his edits should not be mentioned or the acting user is an mod and his edits should not be mentioned.

What the fuck!?

@Alex: what was your intention?

Not to forget the tail.

Else if the acting user is a registered user.

Else. <= That seems to be the block where an editing admin lands, if his actions should not be hidden and if he changes only the category.

I try to put the blocks into parenthesis, like I think it's logical for me. Please remind the additional parenthesis.

The user is an admin and his edits should not be mentioned:

 
(isset($_SESSION[$settings['session_prefix'].'user_type'])
 && $_SESSION[$settings['session_prefix'].'user_type'] == 2
 && $settings['dont_reg_edit_by_admin'] == 1)

The user is an admin and his edits should not be mentioned:

(isset($_SESSION[$settings['session_prefix'].'user_type'])
 && $_SESSION[$settings['session_prefix'].'user_type'] == 1
 && $settings['dont_reg_edit_by_mod'] == 1)

In both cases all three conditions have to apply. Thatswhy I think, the additional parenthesis to enclose these conditions are correct.

if ((isset($_SESSION[$settings['session_prefix'].'user_type'])
  && $_SESSION[$settings['session_prefix'].'user_type'] == 2
  && $settings['dont_reg_edit_by_admin'] == 1)
 or (isset($_SESSION[$settings['session_prefix'].'user_type'])
  && $_SESSION[$settings['session_prefix'].'user_type'] == 1
  && $settings['dont_reg_edit_by_mod'] == 1)
 /* additional conditions */)

At that point the additional condition block enters the game. Here it is:

or (the content of the text and subject fields are not changed and (the user-id stays the same or the name is unchanged) and the location stays the same and (the acting user is an admin and his edits should not be mentioned or the acting user is an mod and his edits should not be mentioned)).

IF ((text == text)
   AND (subject == subject)
   AND ((user_id == user_id) OR (name == name))
   AND (location == location)
   AND ((acting_user == admin) OR (acting_user == mod)))

What the heck should this special case stand for? And why should I give special attention to this case, where nothing changes and the acting admins or mods edits should stay hidden, exactly like in the first two conditions, that stated that we enters the block, when the acting admins or mods edits should stay hidden?

Is there something like a hidden, wonderful or mysterious feature, I miss?

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!

Avatar

"edited by" in 2.3.7 Shows wrong if post is moved category

by Micha ⌂, Saturday, December 10, 2016, 16:35 (2687 days ago) @ Auge

Hi,

What the heck should this special case stand for?

Afaik(!), changing the category of the posting is reported internally.

/Micha

--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences

Avatar

"edited by" in 2.3.7 Shows wrong if post is moved category

by Magma, Friday, December 09, 2016, 12:34 (2688 days ago) @ Micha

Replacing that code as posted brings site down when clicking 'New Topic'. Unable to handle request.

do I have to replace all of this

if(isset($_SESSION[$settings['session_prefix'].'user_type']) && $_SESSION[$settings['session_prefix'].'user_type']==2 && $settings['dont_reg_edit_by_admin']==1 || isset($_SESSION[$settings['session_prefix'].'user_type']) && $_SESSION[$settings['session_prefix'].'user_type']==1 && $settings['dont_reg_edit_by_mod']==1 || ($field['text']==$text && $field['subject']==$subject && ($field['user_id']>0 || $field['name']==$name && $field['location']==$location) && isset($_SESSION[$settings['session_prefix'].'user_type']) && ($_SESSION[$settings['session_prefix'].'user_type']==2 || $_SESSION[$settings['session_prefix'].'user_type']==1)))
        {
         // unnoticed editing for admins and mods
         $edited_query = 'edited';
         $edited_by_query = 'edited_by';
         $locked_query = 'locked';
        }
       elseif(isset($_SESSION[$settings['session_prefix'].'user_id']))
        {
         $edited_query = 'NOW()';
         $edited_by_query = intval($_SESSION[$settings['session_prefix'].'user_id']);
         $locked_query = 'locked';
        }
       else
        {
         $edited_query = 'NOW()';
         $edited_by_query = 0;
         $locked_query = $spam == 0 ? 'locked' : 1;
        }
 
       if($field['user_id']>0) // posting of a registered user edited
        {
Avatar

"edited by" in 2.3.7 Shows wrong if post is moved category

by Micha ⌂, Friday, December 09, 2016, 15:34 (2688 days ago) @ Magma

Hi,

do I have to replace all of this

Take a look at my suggestion at github.

Auge will validate this solution.

/Micha

--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences

RSS Feed of thread