News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Syntax error running the upgrade.php script

Started by MBGreen, May 04, 2024, 12:40:30 PM

Previous topic - Next topic

MBGreen

Hi there,

i'm in the process of upgrading our version of SMF to the latest version (2.1.4).  I'm at the step where you run upgrade.php..and it fails immediately with the following syntax error.

Parse error: syntax error, unexpected '{' in /home/thejetsh/public_html/upgrade.php on line 1101

I opened the script and found the piece of code it's complaining about, but i don't see any issues with the syntax...am i overlooking something?  This is the block of code i'm referring to (I labeled the offending curly brace in red font).  Please help.
// PHP currently has a terrible handling with unserialize in which errors are fatal and not catchable.  Lets borrow some code from the RFC that intends to fix this
// https://wiki.php.net/rfc/improve_unserialize_error_handling
try {
    set_error_handler(static function ($severity, $message, $file, $line) {
throw new \ErrorException($message, 0, $severity, $file, $line);
});
$ser_test = @unserialize($modSettings['attachmentUploadDir']);
} catch (\Throwable $e) {
$ser_test = false;
[color=red]} finally {[/color]
restore_error_handler();
}

MBGreen

I ended up commenting out that entire block of code, and was able to bring up the UI on the upgrade utility. 

Arantor

How old is your version of PHP? It sounds far too old to be running SMF 2.1.4...

Finally blocks were added in PHP 5.5 but SMF 2.1 wants at least PHP 7 if I remember correctly. If you're failing on a finally block, that suggests something very very old is running.

MBGreen

Yeah...i discovered i was running PHP 5.4.  I asked our webhost to upgrade it the latest version php 7.

Arantor

7.4 is no longer in support from the PHP team itself, see if you can ask for PHP 8.0 or 8.1 which should be supported by SMF.

Sir Osis of Liver

Php 5.4 went eol over eight years ago, 7.4 in Nov 2022.  Currently supported versions are 8.1, 8.2, 8.3.  If php 7 is latest version your host offers, time to move to better host.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

shawnb61

I suggest 8.2 (& it's what I use on my forum).
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Advertisement: