News:

Wondering if this will always be free?  See why free is better.

Main Menu

Potential error migrating from 1.1.13 to 2.1.2

Started by LunaticSoleil, July 08, 2022, 01:39:14 PM

Previous topic - Next topic

LunaticSoleil

Hello,

I found a potential error while migrating a SMF 1.1.13 forum up to 2.1.2 (in one step)

[08-Jul-2022 18:42:15 Europe/Berlin] PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function smf_mysql_insert_id(), 0 passed in /.../Forum2/upgrade.php(2184) : eval()'d code on line 53 and exactly 1 expected in /.../Forum2/upgrade-helper.php:417
Stack trace:
#0 /.../Forum2/upgrade.php(2184) : eval()'d code(53): smf_mysql_insert_id()
#1 /.../Forum2/upgrade.php(2184): eval()
#2 /.../Forum2/upgrade.php(1674): parse_sql('/home/bsw/web/w...')
#3 /.../Forum2/upgrade.php(357): DatabaseChanges()
#4 {main}
  thrown in /.../Forum2/upgrade-helper.php on line 417

I suppose the problem is in upgrade_2-0_mysql.sql around line 1726:

                if ($row['permission_mode'] == 1)
                {
                        // I know we could cache this, but I think we need to be practical - this is slow but guaranteed to work.
                        upgrade_query("
                                INSERT INTO {$db_prefix}permission_profiles
                                        (profile_name)
                                VALUES
                                        ('$row[name]')");
                        $board_updates[smf_mysql_insert_id()][] = $row['id_board'];
                }



smf_mysql_insert_id() requires an argument, but no argument is passed.

Kindred

???

Maybe I'm confused, but ---
 Why would you ask for an update to upgrade_2_0 if you are upgrading from 1.1.x?
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Illori

Quote from: Kindred on July 08, 2022, 03:14:27 PM???

Maybe I'm confused, but ---
 Why would you ask for an update to upgrade_2_0 if you are upgrading from 1.1.x?

I believe that is how the upgrade works. You need to be on 2.0 before 2.1.

Arantor

Quote from: Kindred on July 08, 2022, 03:14:27 PMWhy would you ask for an update to upgrade_2_0 if you are upgrading from 1.1.x?

Because that is how the upgrader works - it takes you through each stage that's relevant, e.g. 1.0 -> 1.1 -> 2.0 -> 2.1.
Holder of controversial views, all of which my own.



shawnb61

I believe this bug report is valid:
https://github.com/SimpleMachines/SMF/blob/b15b00bc075e59d25dfcdbc857b1aa5d3b608647/other/upgrade-helper.php#L419

That parameter is required (though unused in this instance...).  Interesting we haven't seen this before. 

To move past it, fow now, I would try removing the parameter from that call in the line of code shown above.
A question worth asking is born in experience & driven by necessity. - Fripp

Kindred

Quote from: Arantor on July 08, 2022, 04:18:50 PM
Quote from: Kindred on July 08, 2022, 03:14:27 PMWhy would you ask for an update to upgrade_2_0 if you are upgrading from 1.1.x?

Because that is how the upgrader works - it takes you through each stage that's relevant, e.g. 1.0 -> 1.1 -> 2.0 -> 2.1.

Ah...  since I've always kept up-to-date, I never knew that. I thought each upgrade was self contained not daisy-chained
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

LunaticSoleil

Quote from: shawnb61 on July 08, 2022, 04:53:34 PMI believe this bug report is valid:
hxxp:github.com/SimpleMachines/SMF/blob/b15b00bc075e59d25dfcdbc857b1aa5d3b608647/other/upgrade-helper.php#L419 [nonactive]

That parameter is required (though unused in this instance...).  Interesting we haven't seen this before. 

To move past it, fow now, I would try removing the parameter from that call in the line of code shown above.

I worked it around by adding a dummy parameter to the call. The update then continued without interruption. I suppose the parameter is there to keep the method signature aligned with the postgresql version - which would need the table name.

I shared this because it should be rather simple to fix it for SMF 2.1.3 (in case someone else is still using 1.1 and wants to do such a large upgrade too)

For the records: at the moment the used PHP version is 7.2 but it might get updated soon (there are some other components on the site that need to be checked for compatibility first)

Arantor

The reason you're the first to find it is because general advice has been (for some reason) to run a 1.1 to 2.0 upgrade on a lower PHP version where this issue is just a warning rather than a fatal error, then the 2.0 to 2.1 upgrade on a higher PHP version (but where that file won't get invoked)
Holder of controversial views, all of which my own.


shawnb61

A question worth asking is born in experience & driven by necessity. - Fripp

Arantor

Quote from: shawnb61 on July 09, 2022, 09:56:33 AM2.0 has an equivalent error. 

Yes, I know, I even said as much.

As I said, the reason that in the years since 2.0 came out that this hasn't been the same headache for people is because they were running the upgrade on a lower PHP version than one that treats this as a fatal error.

Prior to PHP 7.1 omitting a mandatory argument was a warning, not an error; execution would continue. (The OP is on 7.2)

Given that most people coming from 1.1 would actually upgrade to 2.0 first on a lower PHP version (e.g. 5.x) they wouldn't run into this being a breaking problem.
Holder of controversial views, all of which my own.


LunaticSoleil

Quote from: Arantor on July 09, 2022, 10:03:38 AM
Quote from: shawnb61 on July 09, 2022, 09:56:33 AM2.0 has an equivalent error. 

Yes, I know, I even said as much.

As I said, the reason that in the years since 2.0 came out that this hasn't been the same headache for people is because they were running the upgrade on a lower PHP version than one that treats this as a fatal error.

Prior to PHP 7.1 omitting a mandatory argument was a warning, not an error; execution would continue. (The OP is on 7.2)

Given that most people coming from 1.1 would actually upgrade to 2.0 first on a lower PHP version (e.g. 5.x) they wouldn't run into this being a breaking problem.

Quote from the SMF 2.1 release announcement:

QuoteHow to upgrade to SMF 2.1

You can upgrade to SMF 2.1 from any previous version using the "Large Upgrade" package from the Download page.

I do not see any reason why anybody still on SMF 1.1 should upgrade to SMF 2.0 first unless there are some restrictions or "upgrade paths" in the documentation. If there is such an advice I probably missed it.

No intermediate stops mean easier upgrade. I already did quite a lot of upgrades of the "test" forum. Each "upgrade try" does cost about 2-3 minutes of "human time" to start the upgrade and about an half hour running the update unattended. Doing it that way is not much effort and efficient.

Upgrade seems to be ok now and real forum will be upgraded soon - "replaying" all actions in my "upgrade checklist" (which is written during the test upgrades)

I suppose most people with a large / huge forum will do it that way.

Anybody who is first upgrading to SMF 2.0 first would probably upgrade to SMF 2.0.19. If the SMF 1.1 PHP version is < 5.3 (incompatible with SMF 2.0.19)  he would install the most recent PHP version available in his distribution / hoster. According to the docs - SMF 2.0.19 is compatible with PHP 8.0.  I suppose most people will try to install PHP 8.0 and avoid installing any intermediate PHP versions just for upgrading.

Would an upgrade from SMF 1.1 to 2.0.19 using PHP 8.0 be affected?

I suggest that either the upgrade bug is fixed or a note is added to the upgrade packages that an intermediate update to 2.0 is required (or better deny a direct upgrade) . My first upgrade was incomplete because of this error without noticing it first. I first got the 30s warning (update step taking longer than 30s, please wait a bit longer then retry). The server replied with a 500 which was not displayed in the browser. After some mintutes I tried to resume the upgrade process - this time with success. (There is a safty measure in this migration step which prevents it from being executed twice so this error could not occur once again). Only some board permissions did not get migrated. The upgrade always got the "30s warning" at exact the same step - this was the main reason I started to investigate.

I hope that there are not much SMF 1.1 installations left but for those people a upgrade path note or a bugfix would be helpful. The SMF upgrade process is super easy and besides this little glitch it seems to work great - even when doing a huge jump in SMF versions. Upgrading some other software has been much more painful than upgrading SMF.

live627

Quote from: LunaticSoleil on July 09, 2022, 12:12:43 AMI shared this because it should be rather simple to fix it for SMF 2.1.3
Thanks, I've added a fix to 2.1.3.

Advertisement: