Parse error - unexpected 'finally' in Upload.php

Parse error - unexpected 'finally' in Upload.php

equinox22equinox22 Posts: 17Questions: 5Answers: 0

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

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954

    I'm not familiar with PHP but it seems that the finally keyword was added in PHP 5.5. This tutorial indicates that finally was introduced in 5.5. @allan will need to comment since it sounds like you can't upgrade.

    Kevin

  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin

    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

  • equinox22equinox22 Posts: 17Questions: 5Answers: 0

    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

    Strict Standards: Static function DataTables\Database\Query::connect() should not be abstract in
    

    I take that it's one or the other?

    Thanks

  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin

    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

  • equinox22equinox22 Posts: 17Questions: 5Answers: 0

    I've just updated to 2.1.0 but still get the strict standard error

    Strict Standards: Static function DataTables\Database\Query::connect() should not be abstract in /var/www/html/staff/lib/Database/Query.php on line 188
    

    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

  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin

    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

  • equinox22equinox22 Posts: 17Questions: 5Answers: 0

    Hi Allan,

    That's great, thanks very much for taking a look.

    Cheers

  • equinox22equinox22 Posts: 17Questions: 5Answers: 0

    Hi Allan,

    I was wondering if you’ve had chance to consider this?

    Best wishes

  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin
    Answer ✓

    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

  • equinox22equinox22 Posts: 17Questions: 5Answers: 0

    That's got it working :smile:

    Thanks for taking the time to take a look and introduce a fix!

Sign In or Register to comment.