Author Topic: SMF database upgrade issue (php7+)  (Read 1511 times)

Offline huns

  • Semi-Newbie
  • *
  • Posts: 42
SMF database upgrade issue (php7+)
« on: October 10, 2017, 10:37:21 AM »
So I have seen errors in the Log. When I checked the page that threw the error, it said my database is older and I should upgrade. So be it.

The upgrade did not go seamlessly.

[proxy_fcgi:error] [pid 4708:tid 139985273456384] AH01071: Got error 'PHP message: PHP Fatal error:  Uncaught Error: Call to undefined function set_magic_quotes_runtime() in /var/www/upgrade.php:812\nStack trace:\n#0 /var/www/upgrade.php(122): loadEssentialData()\n#1 {main}\n  thrown in /var/www/upgrade.php on line 812\n'

But I found this topic:

I did this edit:
"add this in upgrade.php
before line 812:
if (function_exists ('set_magic_quotes_runtime'))"

And then the upgrade kinda run, but at the end it resulted in an 500 error again. Here is the error:
[proxy_fcgi:error] [pid 4708:tid 139985273456384] [client ] AH01071: Got error 'PHP message: PHP Notice:  Undefined index: session_var in /var/www/Sources/Load.php on line 1604\nPHP message: PHP Notice:  Undefined index: session_value in /var/www/Sources/Load.php on line 1605\nPHP message: PHP Notice:  Undefined index: htmlspecialchars in /var/www/Sources/Load.php on line 1607\nPHP message: PHP Fatal error:  Uncaught Error: Function name must be a string in /var/www/Sources/Load.php:1607\nStack trace:\n#0 /var/www/Sources/Errors.php(288): loadTheme()\n#1 /var/www/Sources/Errors.php(161): setup_fatal_error_context('Incorrect strin...')\n#2 /var/www/Sources/Subs-Db-mysql.php(1423): fatal_error('Incorrect strin...', false)\n#3 /var/www/Sources/Subs-Db-mysql.php(1171): SMF_DB_MySQLi->error('\\n\\t\\t\\tUPDATE qsm_...', Object(mysqli))\n#4 /var/www/Sources/ScheduledTasks.php(1296): SMF_DB_MySQLi->query('substring', '\\n\\t\\t\\tUPDATE qsm_...', Array)\n#5 /var/www/upgrade.php(1941): scheduled_fetchSMfiles()\n#6 /var/www/upgrade.php(689): DeleteUpgrade()\n#7 {main}\n  thrown in /var/www/Sources/Load.php on line 1607\n', referer:

Any ideas? :(

Offline Illori

  • Project Manager
  • SMF Master
  • *
  • Posts: 49,457
Re: SMF database upgrade issue (php7+)
« Reply #1 on: October 10, 2017, 10:40:44 AM »
why are you running the upgrade script? what are you upgrading from and to?

Offline huns

  • Semi-Newbie
  • *
  • Posts: 42
Re: SMF database upgrade issue (php7+)
« Reply #2 on: October 10, 2017, 12:39:19 PM »
Sorry for the late reply, I was not around my PC. And of course, thank you for the quick reply.

- I have been using SMF since 2.0.14. I kept using the large upgrade scripts to 2.07 or something like that. Then I switched to these Package Manager zip packages.
- Our forum was running the latest version (2.0.14), all is fine. But I never really went into the Log or checked it.
- So I went into the Log and it said something about PHP error and it was a link to "what's new" or something like that.
- Clicked the link, and the page said "your installation is new but your database is old, use the upgrade script..."
- Went and grabbed the full package, put it into the folder. Ran it.
- Error 500.
- Found the topic I posted, with a fix (basically an if that the script will just skip that command if it's not available.)
- As I wrote the script then ran a bit forward, but died on me at the very end. At the delete part more or less.
- Removed the upgrade.php after this "hiccup" and all seems well.

But it would be still great to be able to run the whole script without issues.
I reckon it's my PHP7.0 that I use. SMF itself runs great on it, but the upgrade script seems to be a bit outdated (not so 7.0 compatible.) 7.1 breaks SMF I know that, I rolled back to 7.0 once I gave it a try.

btw Stack information:
php: 7.0.22-0ubuntu0.17.04.1
ubuntu: 17.04
mysql: 5.7.19-0ubuntu0.17.04.1

I know, bit way too new, but we had to upgrade our stack. I would not have done it before 2.0.14, but it claimed to have full php7 support - and it also worked, so I went along. It worked great so far and even now after the botched upgrade it works fine as far as I can tell...

Update: Edited my post to reflect reality. I said I used 7.1 php, but it's 7.0 only.

Update #2: Yay for being lazy and never closing tabs.
This was the original message:

Expression #1 of ORDER BY clause is not in SELECT list, references column 'ourdatabase.t.id_last_msg' which is not in SELECT list; this is incompatible with DISTINCT
File: /var/www/Sources/Recent.php
Line: 1103

Note: It appears that your database may require an upgrade. Your forum's files are currently at version SMF 2.0.14, while your database is at version 2.0.9. The above error might possibly go away if you execute the latest version of upgrade.php.

« Last Edit: October 10, 2017, 12:55:18 PM by huns »

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 56,499
  • Gender: Male
    • Kindred-999 on GitHub
Re: SMF database upgrade issue (php7+)
« Reply #3 on: October 10, 2017, 08:30:04 PM »
The database version message is a red herring...  it's a generic message and is not actually correct. There have been no database changes in 2.0.x
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Bob Perry of Web Presence Consulting

  • Sr. Member
  • ****
  • Posts: 967
  • Gender: Male
  • (T)ogether (E)veryone (A)chieves (M)ore
    • Bobert921 on Facebook
    • on LinkedIn
    • @bperry921 on Twitter
    • Web Presence Consulting
Re: SMF database upgrade issue (php7+)
« Reply #4 on: October 11, 2017, 01:28:25 AM »
If it were me, I'd go into cpanel backend and back down the PHP version number to 5.6.3.xx, reupload the large upgrade package and do the manual upgrade a second time...

Best Regards,
Bob Perry

"The world is moving so fast these days that the man who says it can't be done is generally interrupted by someone doing it." Elbert Hubbard

Offline huns

  • Semi-Newbie
  • *
  • Posts: 42
Re: SMF database upgrade issue (php7+)
« Reply #5 on: October 22, 2017, 10:20:26 AM »
@Kindred: Well, but the log was full of errors, and if I visited a page like "last activity" it had just the php error saying I should upgrade my SMF. Having full blown errors and traces exposed to potential attackers did not seem like a good idea.

@Bob: It's a full blown machine and the whole stack had to be upgraded for HTTP/2 support. I don't think the old php would support the new Apache versions (or reverse, but you get the idea.) Reinstalling the entire machine and removing our http/2 support once again to support SMF.. but yeah it would be just as broken I guess. I would have to reinstall it somehow while keeping all our data... does not sound too much fun to me.


Since then our forums have been running in this half-broken state. Guess this is the end of our long run with Simple Machines Forum.
It was a nice ride, but I guess everything comes to an end at some point.
I will explore our options (time is running out, as soon as the next update is out with sec fixes we must move ASAP). So far I saw phpBB picked up some speed and there is NodeBB and Discourse too. Guess we will just have a vote about it or something. I'll miss ya SMF. :(

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,814
    • Arantor on GitHub
Re: SMF database upgrade issue (php7+)
« Reply #6 on: October 22, 2017, 10:51:26 AM »
It's nothing to do with PHP 7 whatsoever. I really wish people wouldn't make such pronouncements without understanding what's actually at fault here.

It's the fact you've upgraded to MySQL 5.7 after 5.7.5 and by default MySQL 5.7.5 runs more strictly than MySQL used to (e.g. 5.6), so things that were previously fine are now broken.

Need to remove the ONLY_FULL_GROUP_BY option from the SQL mode configuration in MySQL to fix it - or rewrite the offending queries.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

Offline boardhead

  • Semi-Newbie
  • *
  • Posts: 23
Re: SMF database upgrade issue (php7+)
« Reply #7 on: February 07, 2018, 10:30:07 AM »
Just to be specific:  For MySQL 5.7.21 this is the option I added when launching mysqld to fix this:

Code: [Select]
(ie. all the default modes except ONLY_FULL_GROUP_BY)

- Phil