Thread tagged as: Problem, Error

PHP error after 2.8.26 update

I'm getting the following PHP error after 2.8.24 -> 2.8.26 update.

mod_fcgid: stderr: PHP Parse error:  syntax error, unexpected '[', expecting ')' in /home/horshampub/public_html/perch/core/lib/PerchFieldTypes.class.php on line 1465

I know I am on old PHP version here and I will update that/move the site shortly. In the meantime, I have rolled back to previous commit.

My short diagnostic report

Perch: 2.8.24, PHP: 5.3.3, MySQL: 5.0.95, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.24), assets (2.8.24), categories (2.8.24), perch_blog (5.0), perch_forms (1.8.3)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_forms', ); ?>
PERCH_PATH: /home/horshampub/public_html/perch
PERCH_CORE: /home/horshampub/public_html/perch/core
PERCH_RESFILEPATH: /home/horshampub/public_html/perch/resources
Image manipulation: GD
PHP limits: Max upload 8M, Max POST 8M, Memory: 64M, Total max file upload: 8M
F1: dc1fef2ad0fcd9f943c02ebb43d85dbc
Resource folder writeable: Yes
DOCUMENT_ROOT: /home/horshampub/public_html
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php

Is this problem caused by array syntax difference between PHP5.3 and 5.4?

Clive Walker

Clive Walker 22 points

  • 5 years ago

I have upgraded server to PHP 5.5 and problem is resolved.

Drew McLellan

Drew McLellan 2638 points
Perch Support

We'll get that patched, thanks.

I just got the same error after upgrading to 2.8.26. However, I can't yet upgrade this site to PHP 5.5. I've therefore temporarily replaced PerchFieldTypes.class.php with the file from the previous Perch version (2.8.25) and this has fixed the error. But I don't know if its going to introduce other problems though?

Update - it DOES cause other problems. I just tried updating a region in Perch Admin and I get an error.

Looking forward to the patch. Can I reinstall 2.8.25 /core folder to the site without causing issues, in the meantime?

Update - no updates had been done for a few days so I reverted the database and /core to 2.8.25

However I've now discovered that selecting 'Page Options' in version 2.8.25 and PHP 5.3 causes this error ...

Parse error: syntax error, unexpected '[', expecting ')' in /home/foxychoc/public_html/perch/core/apps/content/modes/page.edit.pre.php on line 57

So, maybe a similar problem to the one Clive has found?

I've temporarily got around this by adding an .htaccess file to the /perch folder, containing an AddHandler to force Perch Admin to use PHP 5.5 while the remainder of the site runs PHP 5.3 for now. Posted here in case anyone else hits this one.

I'm in the same position; getting this error but not in a position to upgrade PHP at the moment. Do you have an ETA for when this will be fixed?

Thanks :)

Hi Linda. Can your hosting setup provide more than one PHP version, selectable by an 'AddHandler' in the .htaccess file. If so, you could do as I have and set the PHP level to its current value for the website but a higher level for Perch Admin.

Hi Graham,

I have no idea, but I'm trying not to fiddle with this server too much; don't ask why :) The site doesn't need to go live for a little while, so if it can be fixed in the code without running more than one version then I'd rather do that.

Hi all, is there a quick and easy hack to fix this. I am working on quite a restricted clients server and am running PHP 5.3.6 and can't upgrade it. Will an older installation work?

The site i'm doing is extremely basic but i need to get something done urgently.



Hi Rik,

I haven't tested extensively, but I stripped out the file_is_acceptable() function from PerchFieldTypes.class.php (v2.8.26), and the call to it further up the same file, and it seems to work. (I compared it with the same file from v2.8.13.) Haven't looked at the page.edit.pre.php issue yet, but suspect it's a similar issue.

So remove/comment out this code (starting at line 1455 in my editor):

private function _file_is_acceptable($file)
        if (!PERCH_VERIFY_UPLOADS) return true;

        if (isset($file['error'])) {
            if ($file['error']!=UPLOAD_ERR_OK) {
                return false;

        $File = new PerchAssetFile([
                        'file_path' => $file['tmp_name'],
                        'file_name' => $file['name'],
                        'size'      => $file['size'],

        $result = $File->is_acceptable_upload($this->Tag, $this->accept_types);

        if (!$result) PerchUtil::debug($File->get_errors(), 'notice');

        #error_log(print_r($File->get_errors(), 1));

       return $result;


and the same with this line (994 in my editor):

if ($this->_file_is_acceptable($_FILES[$item_id])) {

then remove the three lines AFTER:

$Perch->event('assets.upload_image', new PerchAssetFile($profile));

ie. remove these (starting at 1013 my editor):


            $target = false;

Let me know how you get on!

Thanks so much Linda, I am just waiting to see if I can get the server updated then i'll give this a go.

I'll let you know how I get on!


In case it helps Rik or anyone else, the page.edit.pre.php issue can be fixed by removing/commenting out these two lines (56 and 57 in my editor):

            $data['pageSortPath'] = PerchUtil::strip_file_extension(str_replace(['/'.PERCH_DEFAULT_DOC], [''], $data['pagePath']));

Hi all, this is still frustrating me.

My clients server cannot be upgraded to PHP5.5 and I have tried the above with no prevail.

Is there anywhere I can download older versions of Perch and give that a try.

I did a fresh install on the server this morning and configured the database, etc fine. I logged into the back-end, etc. However when I load the site's index.php I still get the 500 error and the following in the logs.

[14-Mar-2016 10:29:59] PHP Parse error:  syntax error, unexpected '[', expecting ')' in /perch/core/lib/PerchFieldTypes.class.php on line 1465

Any other ideas please? Thanks!!

I have copies of 2.8.25 and 2.8.20 if either of these help.

it would appear the latest patch has fixed this issue. has for me anyway.