Hi,

I'm getting this error:

Parse error: syntax error, unexpected '0' (T_LNUMBER), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in MY-FEATURE.features.inc on line 12

I want to override a rule. I have PHP 5.4 installed. I'm getting this error with the latest beta- and dev-version.

CommentFileSizeAuthor
#1 3220.png93.83 KBMiff
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Peter Majmesku’s picture

Issue summary: View changes

Typo

Miff’s picture

FileSize
93.83 KB

Have experienced same behavior.

Miff’s picture

Issue summary: View changes

Typo

rob_johnston’s picture

Issue summary: View changes

I also occasionally get parse errors. In my case, the line number of the error points directly to the problem. I have visibility rules on a panel that are set with a wildcard such as a URL of '*/rcc/*. A change to the feature will generate a comment like:

*/rcc/*'; /* WAS: '*/rcc-ccr/*

The problem is that the comment is not escaped. This can easily be corrected by replacing all occurrences of '*/' with '*\/'.

milesw’s picture

Same problem when trying to export Elysia Cron rules which contain a number of asterisks and slashes.

Example that causes a parse error:

/**
 * Implements hook_default_elysia_cron_rules_alter().
 */
function myfeature_default_elysia_cron_rules_alter(&$data) {
  if (isset($data['feeds_cron'])) {
    $data['feeds_cron']->rule = '*/2 * * * *'; /* WAS: '*/3 * * * *' */
  }
  if (isset($data['job_scheduler_cron'])) {
    $data['job_scheduler_cron']->rule = '*/2 * * * *'; /* WAS: '*/3 * * * *' */
  }
}
rootwork’s picture

Priority: Normal » Major

I'm seeing this too. It's particularly troublesome because it short-circuits both the site and Drush, so there's not even a way to clear the site's cache if you fix it by escaping the comments. You have to edit the site database to disable the feature, then remove the code entirely, then clear caches, then move the feature back (with escaped comments) and then re-enable it.

It would be really nice to see this bug get fixed.

jlea9378’s picture

The issue described in comments #2, 3 and 4 seem to be different from the issue described in the original post and comment #1.

Personally, I'm experiencing the issue described in the OP and comment #1. Has anyone come up with a solution yet?

jlea9378’s picture

In my override module that I created, I had this code and was getting the parse error described above:

  if (isset($data['rules_og_member_active'])) {
    $data['rules_og_member_active']->0 = Array; /* WAS: '' */
    $data['rules_og_member_active']->1 = Array; /* WAS: '' */
    $data['rules_og_member_active']->2 = Array; /* WAS: '' */
    $data['rules_og_member_active']->3 = Array; /* WAS: '' */
  }
  if (isset($data['rules_og_member_pending'])) {
    $data['rules_og_member_pending']->0 = Array; /* WAS: '' */
    $data['rules_og_member_pending']->1 = Array; /* WAS: '' */
    $data['rules_og_member_pending']->2 = Array; /* WAS: '' */
    $data['rules_og_member_pending']->3 = Array; /* WAS: '' */
  }
  if (isset($data['rules_og_new_content'])) {
    $data['rules_og_new_content']->0 = Array; /* WAS: '' */
    $data['rules_og_new_content']->1 = Array; /* WAS: '' */
    $data['rules_og_new_content']->2 = Array; /* WAS: '' */
  }

Replacing the above code with the following code resolved the parse error for me:

  if (isset($data['rules_og_member_active'])) {
    $data['rules_og_member_active']->{0} = array(); /* WAS: '' */
    $data['rules_og_member_active']->{1} = array(); /* WAS: '' */
    $data['rules_og_member_active']->{2} = array(); /* WAS: '' */
    $data['rules_og_member_active']->{3} = array(); /* WAS: '' */
  }
  if (isset($data['rules_og_member_pending'])) {
    $data['rules_og_member_pending']->{0} = array(); /* WAS: '' */
    $data['rules_og_member_pending']->{1} = array(); /* WAS: '' */
    $data['rules_og_member_pending']->{2} = array(); /* WAS: '' */
    $data['rules_og_member_pending']->{3} = array(); /* WAS: '' */
  }
  if (isset($data['rules_og_new_content'])) {
    $data['rules_og_new_content']->{0} = array(); /* WAS: '' */
    $data['rules_og_new_content']->{1} = array(); /* WAS: '' */
    $data['rules_og_new_content']->{2} = array(); /* WAS: '' */
  }

  • mpotter committed 4cc008a on 7.x-2.x
    Issue #2009084 by jepSter: Fixed Parse error: syntax error, unexpected '...
mpotter’s picture

Status: Active » Fixed

Converting the numeric keys to {0} is fixed in 4cc008a and 87f3943.

Can't reproduce the issue with array() being exported as Array. Features override specifically looks for arrays and outputs empty arrays as array().

  • mpotter committed 87f3943 on 7.x-2.x
    Issue #2009084 by jepSter: Fixed Parse error: syntax error, unexpected '...

Status: Fixed » Closed (fixed)

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