Fixing The Database.php Upgrade Issue

Started by Skhilled, February 25, 2017, 06:04:52 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


The problem? The database is not upgraded to the same version as the files are when upgrading SMF. You may get an error hen you try to install or upgrade a mod that checks the db version and get an error stating,"Your database might require an upgrade. If you upgrade the database the error might go away." There's also a problem if you need to upgrade the database and need to run Upgrade.php to fix it.

But, when you run Upgrade.php, it stalls on the very first screen and shows text that you cannot read and you can go no further. You will see the following screen.

If you click "SKIP" or "Try English" or "Click here to try again." nothing will happen!

This has been happening since the upgrade from SMF 1.0 to 1.1 many years ago and absolutely refuses to fix it and doesn't even bother to look into the problem. Basically, it's useless! So why have an upgrade utility when it doesn't work and the developers refuse to fix it so that it works properly?

Well, I've fixed it, finally! I'm not sure if this is a "proper coding fix" but it works! Basically, I've edited a few files so the current code will accept those files and will proceed with the upgrade as it should. Personally, I think the code should account for the current coding in the files (without changing them) so it can proceed with the upgrade but that may require much more coding work. I'm not a good coder so I can't really say. But what I'm about to show you will work and you may safely upgrade your database!

Here's what you need to do!

I initially thought the issue may be related to the UTF setting in the upgrade procedure but it wasn't. The error shown when you run upgrade.php states that the language files are not up to date. Since the language files are pretty straight forward with very little php coding, I figured there should be something in them that was causing it and may possibly lead me to it. I opened a file and the very first line is this:

// Version: 2.0; XXXXX

The XXXXX = the first name of the language file such as Admin.english.php. In that particular file you'll find:

// Version: 2.0; Admin - get it? Basically, it parses the first part of the filename in the line of code.

So, I used Notepad++ to search all of the files in the /Language folder for "// Version:". The results should show me every file that has it in it. All of the language files have it so it showed them all to me in a list. Only 2 of the files were different:

index.english.php and ManagePaid.english.php

The first had "// Version: 2.0.12;" and the second had "// Version: 2.0.10;". All of the rest of the SMF files had "2.0" only. So, I changed the numbers to 2.0.13 to see if it would work. If not, then I'd change them to "2.0" like the others. It worked!!! You can now run upgrade.php and actually upgrade your database properly!

I do think that the files should be "2.0" like the rest because come the next upgrade it may not work if they are different. I think the dev(s) who was working on the files specifically numbered them to avoid confusion and they got into the final package instead of changing them to "2.0" again.

So to recap, you need to edit the following files so that they read like the rest:

index.english.php and ManagePaid.english.php

Change "// Version: 2.0.12;" and "// Version: 2.0.10;" to "// Version: 2.0;". Then the upgrade should work as expected!

You may experience this issue again when SMF upgrades again and does not fix this issue. But at least you'll know what to do and how to solve the problem!  :dancebun: