Minor SimplePortal Database Change Mod

Started by Burke ♞ Knight, September 08, 2014, 10:48:25 PM

Previous topic - Next topic

Burke ♞ Knight

There seems to be a limit on how many characters you can add to a custom page.

Its quite annoying because it cut off somewhere in the middle of a HTML page i had made, making the page look horrible.

It seems that SP uses the TEXT type for the body of pages, which restricts you to about 65,000 characters. You can change this, however.

You can use phpMyAdmin, go to your database and open the {prefix}sp_pages table. It should look something like this:


Now, click on the edit (the pencil) button next to the body value, which should take you to a page like this:


Now you can change the type from TEXT to MEDIUMTEXT (which can store about 16 million characters) or LONGTEXT (which can store over 4 billion characters).




Now, since I am still new to doing mods that deal with database changes, how would I make this into a mod, for people that do not like to modify the database themselves?

Arantor

QuoteNow you can change the type from TEXT to MEDIUMTEXT (which can store about 16 million characters) or LONGTEXT (which can store over 4 billion characters).

Two things: firstly, it's not 16 million / 4 billion characters, it's 16 million / 4 billion bytes where characters take up 1-3 bytes.

Secondly, while those are the theoretical limits, you're invariably going to find it start to flake out beyond about 850,000 bytes and by 1 million it should flake out on anything but specially configured servers.


Doing it as a mod is evil voodoo by way of the $smcFunc['db_change_column'] command. You will find an example of this exact change in ManagePosts.php:

$smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext'));

Requires db_extend('packages') having been run, will largely be ignored on PostgreSQL and if there's a search index on it (unlikely) things could very well go sideways. I'd suggest just talking to the SP folks about getting it changed on a more permanent basis since there's no meaningful drawbacks to using MEDIUMTEXT vs TEXT if fulltext indexes aren't relevant.
Holder of controversial views, all of which my own.


Burke ♞ Knight


Advertisement: