-
-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #3170 MySQL error with strict mode if message too long - Extended #3286
Conversation
inc/datahandlers/post.php
Outdated
$limit = max($limit, $dblimit); | ||
} | ||
|
||
if(strlen($post['message']) > $limit && (!is_moderator($post['fid'], "", $post['uid']) || $limit == $dblimit)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition is not working well. If an administrator/moderator sends a message longer than $dblimit, this condition lets him post it because $limit is the post limit and not the db limit. You should remove the is_moderator condition here and move it where is $limit declared.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest you to change it with this:
if($limit > $dblimit)
{
$limit = $dblimit;
}
if(strlen($post['message']) > $limit)
{
$this->set_error("message_too_long", array($mybb->settings['maxmessagelength'], strlen($post['message']))); | ||
return false; | ||
} | ||
$limit = (int)$mybb->settings['maxmessagelength']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you should add the is_moderator condition:
if(!is_moderator($post['fid'], '', $post['uid']))
{
$limit = (int)$mybb->settings['maxmessagelength'];
}
else
{
$limit = 0;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic updated. Thanks for review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Covered field types for MySQL
Revised settings description.