News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Strange issue with copied forum and database errors.

Started by GL700Wing, June 24, 2018, 08:40:19 AM

Previous topic - Next topic

Arantor

As in, if they add new columns, they should be using $smcFunc['db_add_column'] and be run through <database> which means SMF will pick it up for you - and offer you the choice to remove on uninstall. It's not particularly difficult to do.

For highly complex mods you can also do 'this is cleanup that must occur' (e.g. remove hooks) and 'this is cleanup that can occur' (e.g. removing settings) but doing it 'properly' requires quite some effort.

GigaWatt

I get it, I really do, but if you started doing something, like developing a mod, shouldn't you do it properly or not at all ???. At least that's my standpoint.
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Arantor

Well... it depends how far the rabbit hole you go, not to mention if it was a 1.1.x mod ported to 2.0, or a 2.0 RC mod ported to 2.0 final, but there's a point that is reasonable (using the tools to do 90% of the work for you) and going completely down the rabbit hole (making sure that even settings, a thing that most mods do not clean up, get cleaned up).

Though I'd point out that this very issue - columns not having default values - is completely avoidable by mod authors who only have to add a default value when adding their column to the database.

GigaWatt

Quote from: Arantor on June 25, 2018, 01:27:17 PM
Though I'd point out that this very issue - columns not having default values - is completely avoidable by mod authors who only have to add a default value when adding their column to the database.

Yeah, I was referring mostly to this case, things that might cause problems... although deleting columns and/or tables with settings is preferable, I don't consider it a must. Though, I'd like to have the option to do a complete clean up.
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Arantor

If you create a column with a default value that just gets added when a row is added, it's effectively dormant once the code is removed, so it's not really an issue in that respect.

But still, given that if the mod uses the tools available, SMF will do the clean up of new tables/new columns for you, there's not really that much excuse. One of the things I tried to do in SimpleDesk was provide it as a reference on how to write a large mod with a structured installer, and an example of 'required cleanup on uninstall' and 'optional cleanup on uninstall' steps, because it certainly can be done.

GigaWatt

As I said previously, I had trouble updating the previous version on my forum from those "dormant" columns and tables. Have no idea what actually caused most of the issues (I was just getting into all of this back then), but all of the errors were generated during the database conversion. Can't remember what they actually were, but I had to fix them one by one, and this lasted a little over a month (as I said, I was a beginner back then, now, I could probably do it in a day) with ups and downs, long pauses, try this and try that... but, I might add that I did it without writing a single post on this forum (yei :D). I joined SMF afterwards, just to be on top of things ;). It's easier to prevent something from happening then to deal with the consequences later ;).

And I hope somebody actually learned something from your mod, regarding code and database cleanup :).
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Arantor

Nah, I doubt anyone really learned anything from SimpleDesk except how to do very specific and complex stuff that no-one but me ever needed to figure out how to do.

GL700Wing

 
Quote from: GigaWatt on June 25, 2018, 09:13:52 AM
Most mod authors assume that you might come back to using the mod some day (if you happen to uninstall it), so in case you don't want to lose the data created by the previous install of the mod, they leave columns and/or tables in the database untouched ...
Given that very few mods offer an upgrade option for installing later versions I don't have an issue with this.




Quote from: Arantor on June 25, 2018, 01:22:04 PM
As in, if they add new columns, they should be using $smcFunc['db_add_column'] and be run through <database> which means SMF will pick it up for you - and offer you the choice to remove on uninstall./quote]
This isn't happening with the Topic Count On Display which I installed both on a brand new SMF 2.0.15 forum (ie, no mods previously installed) on the new host -'db_add_column' added an integer column without a default value and I am not given an option to remove the column when I uninstall the mod.

The code to modify the database in the mod package is as follows:
$column = array(
    'name' => 'topics',
    'type' => 'mediumint',
    'size' => 8
);
$smcFunc['db_add_column']('{db_prefix}members', $column);



Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

GL700Wing

As both website hosting plans are with the same hosting company but on different servers I lodged a support ticket a few days ago to report the discrepancy (ie, that "SQL strict mode" was configured differently on the two servers).

I received the following response from their technical support team a few hours ago:
QuoteSQL Strict mode should be disabled now.
The decision was made that due to most applications like WHMCS requiring SQL Strict mode disabled, we have chosen to disable this fleet wide.

I have confirmed that everything is now working as expected ...

[insert happy dance]

Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Aleksi "Lex" Kilpinen

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Advertisement: