SimpleMachines / SMF

Simple Machines Forum — SMF in short — is free and open-source community forum software, delivering professional grade features in a package that allows you to set up your own online community within minutes!
https://www.simplemachines.org/
Other
595 stars 255 forks source link

Convert to TEXT fails if data too long #6763

Open sbulen opened 3 years ago

sbulen commented 3 years ago

Description

The Forum Maintenance function to convert from MEDIUMTEXT to TEXT claims it will truncate values in order to complete: image

But it doesn't, instead, it errors out: image

I think this is a byproduct of converting SMF to strict mode. Without strict mode, it will truncate. It needs to explicitly truncate now.

Steps to reproduce

  1. Use the Admin | Maintenance | Database | Convert to MEDIUMTEXT function
  2. Add data that exceeds 65535 bytes
  3. Use the Admin | Maintenance | Database | Convert to TEXT function

Environment (complete as necessary)

Additional information/references

Reported on forum here: https://www.simplemachines.org/community/index.php?topic=577205.msg4089531#msg4089531

jdarwood007 commented 3 years ago

Should we allow mediumtext to text then if a truncation would occur? Even with a warning, its a very dangerous option and there is no recovery from this. Data will be lost.

If we do allow it, I think the message needs appended info indicating data will be truncated and is not recoverable without a working backup.

sbulen commented 3 years ago

We could add more alarming text, for sure.

We could also remove it entirely. I think in nearly all cases, folks are going from TEXT to MEDIUMTEXT, not the other way around. In this example, user was testing behavior & alternating between TEXT vs MEDIUMTEXT, not actually moving their db back to TEXT.

Sesquipedalian commented 3 years ago

We could also remove it entirely. I think in nearly all cases, folks are going from TEXT to MEDIUMTEXT, not the other way around. In this example, user was testing behavior & alternating between TEXT vs MEDIUMTEXT, not actually moving their db back to TEXT.

This seems like the best plan to me. Downgrading from MEDIUMTEXT to TEXT doesn't seem like something an admin would normally want to do in a production environment. If the admin needed to upgrade from TEXT to MEDIUMTEXT in the first place, they are unlikely to want to go back.