Advertisement:

Author Topic: Custom subject length  (Read 3397 times)

Offline phantomm

  • Sophist Member
  • *****
  • Posts: 1,064
  • Gender: Male
    • pages/smfpl/171860759503032 on Facebook
    • Polish ElkArte community
Custom subject length
« on: January 11, 2013, 01:15:57 AM »
Link to Mod

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
Polskie wsparcie SMF na simplemachines.org

My mods

Offline Sh@mbles

  • SMF Hero
  • ******
  • Posts: 4,894
  • Gender: Male
    • i30 Owners Club
Re: Custom subject length
« Reply #1 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.

Offline phantomm

  • Sophist Member
  • *****
  • Posts: 1,064
  • Gender: Male
    • pages/smfpl/171860759503032 on Facebook
    • Polish ElkArte community
Re: Custom subject length
« Reply #2 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?
Polskie wsparcie SMF na simplemachines.org

My mods

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 69,123
    • StoryBB/StoryBB on GitHub
Re: Custom subject length
« Reply #3 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)
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

Nothing turns to hate so bitter as what once was love.