Hello,

I am getting the following error on one site when using drush commands..

Parse error: syntax error, unexpected T_FUNCTION in /data/www/../../sites/all/modules/contrib/webform/webform.module on line 4401

I have tried everything I can imagine (eg disable/enable module, delete module and data then re-install, try different module versions, run db updates etc etc.) with no luck.

I am hoping somebody here might understand what that error means and give some advice on how to fix it. Many thanks

Comments

DanChadwick’s picture

Status: Active » Fixed

I'm venture that your download has been corrupted. I assure you that 4.7 does not have any parse errors. I would replace it with a freshly-downloaded copy.

Anonymous’s picture

I encountered the same error today while uploading a site. The error seems to happen with web form 7.x-4.7 and PHP 5.2. Switching to PHP 5.5 solved the issue for me (version 5.3 should work as well as that's the version mentioned in the webform.info file).

It might be useful to mention PHP 5.3 under "Requirements" in README.txt.

DanChadwick’s picture

Category: Support request » Task

That's a good idea. I'm not going to duplicate the requirements from the project page in the readme, but rather reference the project page. That way it will always be updated.

Committed to 7.x-4.x and 8.x.

pyxio’s picture

Hi I can assure you it is not a php error. Webform runs fine on other sites on the same server. So I simply do not understand what is causing this on one particular site. I will keep you posted of my findings. cheers kevin

DanChadwick’s picture

@drupalstrap -- That line of code is an anonymous function. There are only 2 reasons I know of why PHP choke on an anonymous function.

1) Use of PHP < 5.3, where anonymous functions aren't supported.
2) Use of an opcode cache that doesn't support anonymous function. APC works. Searching the issue queue will reveal another that doesn't, whose name escapes me at the moment.

I'd venture that your other functioning sites either a) aren't displaying components b) are using an older version of webform, c) are using a newer version of PHP or d) aren't using the same op code cache.

  • DanChadwick committed 3c68d83 on 8.x-4.x
    Issue #2467239: Reference project page in README.txt for requirements.
    

  • DanChadwick committed f69b05b on 7.x-4.x
    Issue #2467239: Reference project page in README.txt for requirements.
    
pyxio’s picture

@DanChadwick thanks for the suggestions. i will report back once i solve it. cheers kevin

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

arlingtonvoicellc’s picture

I have hit the same issue. Can confirm I'm using PHP 5.5. Only Webform module is breaking the website. Uninstalled the module and then reinstalled most recent version. Same error.

Parse error: syntax error, unexpected T_FUNCTION in ../sites/all/modules/webform/webform.module on line 4606

arlingtonvoicellc’s picture

Priority: Normal » Major
Status: Closed (fixed) » Active
pyxio’s picture

yes. it is a php compatibility issue. i ended up using an earlier version of webform. it works but i have notices that i should upgrade the module due to security issue of the older one. but i can't update it because then the site breaks. so keeping the older one for now. cheers

arlingtonvoicellc’s picture

Thanks Drupalstrap. Going to try an older version. I should note that the most recent version was working just fine on my WAMP. It was only when I migrated to a live server that it broke. My WAMP is using PHP 5.3.1.

DanChadwick’s picture

Priority: Major » Normal
Status: Active » Closed (fixed)

It's your installation. Disable or update eAccelerator. See http://php.net/manual/en/functions.anonymous.php#113422

The syntax in Webform is correct for PHP 5.3 and higher.

arlingtonvoicellc’s picture

Call me crazy, but it seems backwards to push out a module update that requires you to turn off default settings on a server. Shouldn't the module adapt to the server, not the other way around?

DanChadwick’s picture

It's a bug in eAccelerator, which has been (apparently) been fixed. Webform requires PHP 5.3. The affected version of eAccelerator doesn't support all of PHP 5.3 -- specifically anonymous functions.

eAccelerator is not a "default setting" of a server. It is add-on software (presumably added by a host company, and not kept up-to-date).

If you installed an add-on to Microsoft Word and it made Word crash every time you typed "Drupal", would stop writing about Drupal or would you remove or update the add-on?

arlingtonvoicellc’s picture

Adding an update here for anyone who has hit the same problem.

Because my client's website is on shared hosting, I had to disable the eaccelerator module through .htaccess.

Create an .htaccess file and add the following code:

<IfModule eaccelerator>
php_flag eaccelerator.enable 0
php_flag eaccelerator.optimizer 0
</ifModule>

Then upload this to the WEBROOT folder (aka public_html) of your server.

All of the articles I found online did not include the "IfModule" part of the above code. Without that part, it kept crashing the server with a 500 error. Hope this helps someone in the future.

rwilson0429’s picture

The project page says that the 7.x-4.x requires php >=5.3. Since drush runs from the command line. I would check the php version of your CLI. At the command line where you normally run drush commands, type php -v. If the version is <5.3, that is probably the cause of the issue.

The php version that your website is running on is not necessarily the same version that your SSH or your CLI is running.

A workaround is to disable webforms when you need to perform drush operations that aren't webform specific. You can always re-enable after your drush operations are completed.

karolus’s picture

There may be another solution, depending on your Web host's setup. For my issue here, the server was running PHP 5.2, hence the error. No GUI method to fix, but adding this to the .htaccess file at the Web root (public_html) fixed it right up:

# Use PHP54CGI as default
        AddHandler fcgid54-script .php

Hope this can help for some.

korn3lius’s picture

I also encounter the same problem here. Fortunately, It solved. The problem in my case is differrent php version used by drupal site and drush. After I corrected my drush php version in bash_profile with the same with drupal site php. Drush is working properly.

kerrycurtain’s picture

@arlingtonvoicellc

Thanks very much for this piece on code, we have been down for over 3 days now and your sweet piece of code has returned us back to a visible domain.

Funksmaname’s picture

#19 worked for me, thanks