Bug #416

Group Promotions not Working or 'Broke'?

Added by Nick Palmer over 2 years ago. Updated about 2 years ago.

Status:Closed Start date:08/20/2009
Priority:Normal Due date:
Assignee:Ryan Gordon % Done:

100%

Category:Task System
Target version:1.4.10
Reproducibility:Always Database Type:
Reported In MyBB Version:1.4.8 Database Version:
PHP Version: SQA assignments:
Browser:

Description

I was trying out a new idea I came up with, it may sound rather weird though but anyway, basically I set it so anyone with 0 posts gets moved to a specific rank, and then anyone who has more than 0 posts would get their rank changed back (or their group). But it mest up, it changed people who had more than 0 posts to the rank I wanted it to set it to if they didn't have any posts which isn't what I wanted... So I double checked I defined everything properly and re-tried it, and no such luck. I'm not sure whats wrong with it, I'm using the latest version of MyBB anyway not sure what else to state so if I left some information out please feel free to ask me more. Also, I saw someone else had a problem with Group Promotions mine's rather different from his but still I'm guessing there must be a bug in group promotions altogether?

Anyway thanks for reading and thanks for your help in advanced. =]

Associated revisions

Revision 4535
Added by Ryan Gordon about 2 years ago

Fixes Group Promotions not Working or 'Broke'? (fixes:416)

History

Updated by Michael Schlechtinger over 2 years ago

  • Status changed from New to Confirmed

The promotion system only works with values greater than 0 at the moment.

Possible fix: Open inc/tasks/promotions.php and search for:

if(in_array('postcount', $requirements) && intval($promotion['posts']) > 0 && !empty($promotion['posttype']))

Replace with:
if(in_array('postcount', $requirements) && intval($promotion['posts']) >= 0 && !empty($promotion['posttype']))

Search for:
if(in_array('reputation', $requirements) && intval($promotion['reputations']) > 0 && !empty($promotion['reputationtype']))

Replace with:
if(in_array('reputation', $requirements) && intval($promotion['reputations']) >= 0 && !empty($promotion['reputationtype']))

Updated by Ryan Gordon over 2 years ago

Michael Schlechtinger wrote:

The promotion system only works with values greater than 0 at the moment.

Possible fix: Open inc/tasks/promotions.php and search for:
[...]
Replace with:
[...]
Search for:
[...]
Replace with:
[...]

That's a bad fix imho. I don't even think this should be fixed because there is no good way to fix this. Michael, If you leave a promotion configuration field blank then intval'ing it will make it show "0" and then that will cause your statement to become true even if it was not intended.

Updated by Michael Schlechtinger over 2 years ago

Ryan Gordon wrote:

That's a bad fix imho. I don't even think this should be fixed because there is no good way to fix this. Michael, If you leave a promotion configuration field blank then intval'ing it will make it show "0" and then that will cause your statement to become true even if it was not intended.

I already thought about this, too. Can't we just use somthing like this?

if(in_array('postcount', $requirements) && ctype_digit($promotion['posts']) && $promotion['posts'] >= 0 && !empty($promotion['posttype']))

On the other hand I'm not sure why someone would promote a user with 0 posts. You can just alter the permissions of the default registered group and promote the user if he has made some posts.

Updated by Ryan Gordon over 2 years ago

That's still would be a hacky wordaround to me at best

Updated by Martin Madsen over 2 years ago

What about checking if the user inputed something in the promotion field, if they didn't set it to -1? (I don't have the correct code right now though)

Updated by Ryan Gordon about 2 years ago

  • Category set to Task System
  • Status changed from Confirmed to Assigned
  • Assignee set to Ryan Gordon
  • Target version set to 1.4.10

We should check the input before we intval the input with a "strict" comparison (===)

I definately want my fix tested for this by SQA thoroughly before we release MyBB 1.4.10

Updated by Ryan Gordon about 2 years ago

Actually, I looked at the code again and since you must specifically select which criteria applies we can change this pretty easily without repercussion.

Updated by Ryan Gordon about 2 years ago

  • Status changed from Assigned to Resolved
  • % Done changed from 0 to 100

Applied in changeset r4535.

Updated by Sourav Mukherjee about 2 years ago

Ryan Gordon wrote:

Applied in changeset r4535.

It is still not working.

If I set the conditions for promoting user on basis of post count it works, but if I set the conditions for promoting user on basis of reputation it does not work.

I have also tested it by disabling all other reputation mod.

My Server environment:
Operating system- Linux
Apache 2.2.12
PHP 5.2.10
MySQL 5.0.84

Updated by Ryan Gordon about 2 years ago

Sourav Mukherjee wrote:

Ryan Gordon wrote:

Applied in changeset r4535.

It is still not working.

If I set the conditions for promoting user on basis of post count it works, but if I set the conditions for promoting user on basis of reputation it does not work.

I have also tested it by disabling all other reputation mod.

My Server environment:
Operating system- Linux
Apache 2.2.12
PHP 5.2.10
MySQL 5.0.84

You're not testing it properly then. The fix is correct

Updated by Sourav Mukherjee about 2 years ago

I downloaded the the php and replaced the original one that comes with Mybb1.9 and I have double checked the promotion conditions but it is just not working. It only does not work when I use the reputation count.

I edited one or two of my user`s reputation directly from database. Do you think that that might effect the system?

Updated by Matt Rogowski about 2 years ago

Possibly, seeing as there is also a reputations table that contains the details of the rep. Never edit stuff in the database like this, you'll only end up breaking stuff. If it isn't an option on the user end, don't try and change it unless you really know what you're doing.

Updated by Michael Schlechtinger about 2 years ago

  • Status changed from Resolved to Closed

It's working fine. Please note that the promotion task only affects users that were active since the last run of the task.

Updated by Sourav Mukherjee about 2 years ago

Michael Schlechtinger wrote:

It's working fine. Please note that the promotion task only affects users that were active since the last run of the task.

I did`nt know that. Then I think the problem is solved.
Thanks for the replies guys..

Updated by Oliver Howell about 2 years ago

If this function worked for negative reputations (i.e. reputation below zero) then this could be really useful for fighting spammers.

See http://community.mybboard.net/thread-55904-post-397334.html#pid397334

Also available in: Atom PDF