Skip to content
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

Merged
merged 3 commits into from
Jun 27, 2018
Merged

Fixes #3170 MySQL error with strict mode if message too long - Extended #3286

merged 3 commits into from
Jun 27, 2018

Conversation

effone
Copy link
Member

@effone effone commented Jun 26, 2018

Covered field types for MySQL
Revised settings description.

@effone effone added the b:1.8 Branch: 1.8.x label Jun 26, 2018
@effone effone added this to the 1.8.16 milestone Jun 26, 2018
@effone effone requested review from euantorano and Shade- June 26, 2018 09:26
$limit = max($limit, $dblimit);
}

if(strlen($post['message']) > $limit && (!is_moderator($post['fid'], "", $post['uid']) || $limit == $dblimit))
Copy link
Contributor

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.

Copy link
Contributor

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'];
Copy link
Contributor

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;
			}

Copy link
Member Author

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.

Copy link
Member

@euantorano euantorano left a 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.

@euantorano euantorano merged commit afbb47a into mybb:feature Jun 27, 2018
@effone effone deleted the message-length branch June 27, 2018 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
b:1.8 Branch: 1.8.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants