Posted by coupet on December 23, 2006 at 4:24am
Jump to:
| Project: | dependantDropdown |
| Version: | 5.x-1.0-beta |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /usr/local/apache/htdocs/sitename.com/drupal474/modules/dependantDropdown/dependantDropdown.module on line 79
Note: drupal 4.7.4
Comments
#1
The error comes in this line:
foreach ($form as $fieldname => &$field)
It seems that this syntax is not accepted: "=> &$"
What is your PHP version?
Do you know what is drupal policy towards php versions?
I'll take a look how to refactor the code so it'll work on previous versions.
hed
#2
Quoted from here:
In this case i think you could just do
<?php$selectField = &$form[$fieldname][$filter]
?>
instead of
<?php$selectField = &$field[$filter];
?>
and drop the reference in the foreach.
#3
Server is setup as follows:
PHP Version 4.4.0
Apache/1.3.33 (Unix) PHP/4.4.0 FrontPage/5.0.2.2635 mod_throttle/3.1.2 mod_ssl/2.8.22 OpenSSL/0.9.7a
#4
scroogie answer is right i guess,
now does any of you guys know how do i maintain two branches in CVS to post this fix?
because my CVS version is already forwarded to 5
tnx,
hed
#5
CVS Branches
http://drupal.org/node/17570
#6
Looking forward for a patch
#7
A patch?
I'm missing something
i opened another branch for 4.7 and fixed it there
My main branch is 5.0 compatible
I must admit that i don't understand those releases.
#8
I downloaded and installed both 4.7 releases on 1/05/2006 and getting same parse error.
#9
Ive changed this function and it works for me on php 4.4.4:
<?phpfunction dependantDropdown_connect_filtering_field(&$form){
foreach ($form['#filteringMatch'] as $filter => $filtered) {
$selectField = NULL;
if (isset($form[$filter])) {
$form[$filter]['key']['#attributes']['title'] = $filtered;
$form[$filter]['key']['#attributes']['class'] = "filteringField";
} else {
$newform=array();
foreach ($form as $fieldname => $field){
$newform[$fieldname]=$field;
if ($field['#type'] == 'fieldset' && isset($field[$filter])){
$newform[$fieldname][$filter]['key']['#attributes']['title'] = $filtered;
$newform[$fieldname][$filter]['key']['#attributes']['class'] = "filteringField";
}
}
$form=$newform;
}
}
}
?>
#10
The latest 5.x version download has the same problem:
Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /srv/www/vhosts/swlspaces.com/subdomains/d5/httpdocs/sites/all/modules/dependantDropdown/dependantDropdown.module on line 69replacing the line
foreach ($form as $fieldname => &$field) {with
foreach (array_keys($form) as $fieldname) {$field =& $form[$fieldname];
makes the error go away ... will test now if it works as expected.