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:

<?php
$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 :

<?php
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

A better way is to add this function on the top of the .module :

<?php
function _openlayer_array_filter($param){
   return (!isset(
$param->disabled) || !$param->disabled);
}
?>

And replace the four occurencies of array filter by :

Line 596, 647, 677 and 764

<?php
if (!$include_disabled) {
   
$layers = array_filter($layers, '_openlayer_array_filter');
  }
?>

<?php
 
if (!$include_disabled) {
   
$behaviors = array_filter($behaviors, '_openlayer_array_filter');
  }
?>

<?php
 
if (!$include_disabled) {
   
$styles = array_filter($styles, '_openlayer_array_filter');
  }
?>

<?php
 
if (!$include_disabled) {
   
$maps = array_filter($maps, '_openlayer_array_filter');
  }
?>

Status:Active» Fixed

Hello,

Anonymous function are supported since PHP 5.3.0, could you double check your PHP installation and report please ?

Thanks.

I confirm Php 5.3.18. :(

Do you test with drush and features ?

Status:Fixed» Needs review

Having 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.

Status:Needs review» Closed (duplicate)

been following this but i guess my codes are not same.... i will try a patch. thanx

Has there been an update or patch for this issue with 7.x-2.0-beta7 as noted in #4 above?

Thanks!