VeggieMeat / search_api_elasticsearch

Clone of project at drupal.org/project/search_api_elasticsearch for better CI options than what D.O offers
16 stars 8 forks source link

Elastica Module Has Implicit Dependency on PHP 5.4 #30

Closed VeggieMeat closed 10 years ago

VeggieMeat commented 10 years ago

Original issue: https://www.drupal.org/node/2307529

Hi,

While indexing some taxonomy term fields, I noticed that terms with single digit term IDs (e.g. "5"), were being indexed properly, but terms with 2+ digit term IDs (e.g "37") were not. The multiple digit term IDs were being truncated to just the first digit when being added to the index, so "37" would just become "3".

I tracked it down to line 250 in the modules/elastica/includes/SearchApiElasticsearchElastica.inc file, which relies on the PHP 5.4 behavior of accessing strings as arrays (see Example #10). Since I'm using PHP 5.3, isset($token['value')] returns TRUE, and when $token is "37", $token['value'] ends up being "3", not "37".

It looks to me like there are two options:

1) Search API Elasticsearch Elastica could declare an explicit dependency on PHP 5.4 in the module .info file to match the use of PHP 5.4-specific behavior in the module.

2) Since the Elastica client depends on PHP >= 5.3.3, I'd prefer that Search API Elasticsearch match that requirement, and any code that relies on PHP 5.4 be replaced with PHP 5.3 code.

I'll be attaching patches that implement option #2.

Thanks for Search API Elasticsearch!
-G