Fixed Custom Warning: Title length limit not checked

lazy llama

Well-known member
If you go to warn a user, select a Custom Warning and put more than 150 characters in the text box you get a server error:
Zend_Db_Statement_Mysqli_Exception: Mysqli statement execute error : Data too long for column 'title' at row 1 - library/Zend/Db/Statement/Mysqli.php:214
Just needs a length check before writing it to the database.
Not an exciting bug, and only mods or admins will experience it.
 
I can confirm this.
Fix is as follows, in case anyone feels it important enough.

Add the code in red.

XenForo_DataWriter_Warning:

Rich (BB code):
protected function _getFields()
{
return array(​
'xf_warning' => array(​
<...>​
'title' => array('type' => self::TYPE_STRING, 'required' => true,​
'requiredError' => 'please_enter_valid_title', 'maxLength' => 150
),​
<...>​
)​
);​
}
 
Confirmed here as well. The fix Chris posted is correct. Though technically you could get away with up to 255 characters. That field is a varchar(255).
 
Back
Top Bottom