Parse error - unexpected 'finally' in Upload.php
Parse error - unexpected 'finally' in Upload.php
Hi,
I tried to access one of my tables and got an error prompting to look at http://datatables.net/tn/1.
When I had a look at the output in the developer tools, this is what it says.
Parse error: syntax error, unexpected 'finally' (T_STRING), expecting catch (T_CATCH) in /var/www/html/staff/Editor/Upload.php on line 447
The code in question is
// Database
if ( $this->_dbTable ) {
foreach ( $this->_dbFields as $column => $prop ) {
// We can't know what the path is, if it has moved into place
// by an external function - throw an error if this does happen
if ( ! is_string( $this->_action ) &&
($prop === self::DB_SYSTEM_PATH || $prop === self::DB_WEB_PATH )
) {
$this->_error = "Cannot set path information in database ".
"if a custom method is used to save the file.";
return false;
}
}
// Commit to the database
$id = $this->_dbExec( $upload, $editor->db() );
}
// Perform file system actions
return $this->_actionExec( $upload, $id );
} finally {
if ($tempFile !== false) {
@fclose($tempFile);
}
}
}
I'm not sure how to go about fixing this. Other tables on my site behave fine. It is worth nothing that I've just stepped down from php 8.1 on my development server to php 5.4 on the production server, which I am not in control of, so I'm running Editor 2.0.6.
Any help would be greatly appreciated.
Thanks
This question has an accepted answers - jump to answer
Answers
I'm not familiar with PHP but it seems that the
finally
keyword was added in PHP 5.5. This tutorial indicates thatfinally
was introduced in 5.5. @allan will need to comment since it sounds like you can't upgrade.Kevin
Hi,
Looks like you are using an old version of the PHP libraries for Editor there. Update to 2.0.8 or newer (2.1.0 is the current release at the time of writing this), and it will be fixed there. The fix was committed here.
Allan
Hi,
Thanks for getting back to me both.
I've upgraded to 2.0.8 @allan but then immediately remembered why I had to change to 2.0.6 due to the following error where it was suggested to use this version in this thread
I take that it's one or the other?
Thanks
The 2.1.0 libraries have been tested in strict mode and show work smoothly. Is 2.1.0 an option for you? I just checked your license and you should have access to the latest version.
Allan
I've just updated to 2.1.0 but still get the strict standard error
I did run 2.1.0 on the development server (php 8.1) and it ran smoothly, but a direct copy of the files to the product server produces this error on php 5.4.
Thanks
Bother - sorry. It was 8.1 in strict mode I checked it with, while 5.4 was in standard mode. This is one of those weird situations in PHP where the "correct thing to do" is actually rejected by the old strict mode.
Let me have a little think about how to correctly handle this...
Allan
Hi Allan,
That's great, thanks very much for taking a look.
Cheers
Hi Allan,
I was wondering if you’ve had chance to consider this?
Best wishes
Hi,
Yes in fact . I've just committed a small change that addresses this error. I've been running it in Docker with an Apache and PHP 5.4 container and it appears to be happy now. It isn't technically correct, but that doesn't matter - it works in 5.4+ now.
I found this SO thread on this topic which is quite interesting.
I'll do an Editor patch release with this change soon, but until then, that little tweak in your
Database/Query.php
file will fix it.Allan
That's got it working
Thanks for taking the time to take a look and introduce a fix!