Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: Adrek on January 11, 2013, 01:15:57 AM

Title: Custom subject length
Post by: Adrek on January 11, 2013, 01:15:57 AM
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=3607)

Mod allows you to change maximum subject length in topics. By default subject can have 80 characters, with this mod you can choose between 1 and 255 characters.

This mod is licensed under a CC BY-NC-ND 3.0 (http://creativecommons.org/licenses/by-nc-nd/3.0/)
Title: Re: Custom subject length
Post by: Shambles on January 11, 2013, 05:48:57 AM
Looks useful, well done :)

Being a pedantic sod, though, I noticed a small typo in your package-info.xml "readme" line

Code (find) Select
With this mod you can choose subject length is topics.

Code (replace) Select
With this mod you can choose subject length in topics.
Title: Re: Custom subject length
Post by: Adrek on January 11, 2013, 05:55:15 AM
Thanks, I thought that I fixed it ::)

//and it is fixed, this two lines are the same?
Title: Re: Custom subject length
Post by: Arantor on January 11, 2013, 07:25:38 AM
There are a number of issues with this.

Firstly, if the user uninstalls and reinstalls the mod, any value they will previously have set will be replaced; the installer should bring $modSettings into scope, then check whether $modSettings['max_subject_length_mod'] is emptybefore calling to change it.

The second, and much more serious issue, is that if a user does set this to quite a high value (I'm thinking 200+), there is a very real possibility that the size of the database field will truncate content anyway.

Simple case to replicate: set the limit to 255, type in 255 characters of which only one needs to be a ' or a " and the end of that will be cut off. Just as plenty of instances of multi-byte characters may well be truncated too if they are entity-form.

But you can't just make the column bigger either - MySQL 5.0.3 or higher will be required to make the subject > 255 in size, and you can't make it a text column because of how badly that will damage performance in other places (especially the board and message indexes)