Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
- Drupal 7
- Php 5.3.18
When we use drush to revert feature there is always an openlayer error :
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: syntax error, unexpected T_FUNCTION in /raid/www/cg-somme/www/nne/sites/all/modules/contrib/openlayers/openlayers.module, line 596
Parse error: syntax error, unexpected T_FUNCTION in /raid/www/cg-somme/www/nne/sites/all/modules/contrib/openlayers/openlayers.module on line 596
This error appear for each 'anonym function' in an array filter (4 times lines 596, 647, 677, 764:
$layers = array_filter($layers, <strong>function($layer)</strong> {
return (!isset($layer->disabled) || !$layer->disabled);
});
When i create a function before that i called by her name it works.. no syntax error.. How can we fixed that for the community.. :
This is ok :
function openlayer_test_array_filter($layer) {
return (!isset($layer->disabled) || !$layer->disabled);
};
function openlayers_layer_types($reset = FALSE, $include_disabled = FALSE) {
ctools_include('plugins');
$layers = ctools_get_plugins('openlayers', 'layer_types');
if (!$include_disabled) {
$layers = array_filter($layers, 'openlayer_test_array_filter');
}
return array_filter($layers, 'openlayers_layer_definition_check');
}
Thanks ! :)
Comments
Comment #1
gghh2 CreditAttribution: gghh2 commentedA better way is to add this function on the top of the .module :
And replace the four occurencies of array filter by :
Line 596, 647, 677 and 764
Comment #2
PolHello,
Anonymous function are supported since PHP 5.3.0, could you double check your PHP installation and report please ?
Thanks.
Comment #3
gghh2 CreditAttribution: gghh2 commentedI confirm Php 5.3.18. :(
Do you test with drush and features ?
Comment #4
poeticdevel CreditAttribution: poeticdevel commentedHaving the same issue with Aegir and any drush command executed with this version of OpenLayers enabled.
I have 75 sites installed with different versions of OpenLayers and this is the only version generating the following error:
Drush command terminated abnormally due to an unrecoverable error. Error: syntax error, unexpected T_FUNCTION in /data/disk/o1/static/xxxxxx/sites/sitename.com/modules/openlayers/openlayers.module, line 596.
Thanks.
Comment #5
PolSee #2112007: Remove anonymous functions so OpenLayers runs on PHP 5.2.
Comment #6
edwoodjigga CreditAttribution: edwoodjigga commentedbeen following this but i guess my codes are not same.... i will try a patch. thanx
Comment #7
poeticdevel CreditAttribution: poeticdevel commentedHas there been an update or patch for this issue with 7.x-2.0-beta7 as noted in #4 above?
Thanks!