ebsco / edsapi-drupal-plugin

A Drupal modules for the EBSCO Discovery Services API
Apache License 2.0
1 stars 3 forks source link

Security / PHP 7.2 compatibility: create_function() is deprecated #22

Open jameswilson opened 6 years ago

jameswilson commented 6 years ago

The function create_function() has been deprecated in PHP 7.2 due to security issues.

The following PHP warning is displayed when viewing a detail record page:

Deprecated function: Function create_function() is deprecated in auto_link() (line 1515 of modules/contrib/edsapi-drupal8-plugin/ebsco.module).
auto_link('XXXXXXXXXXXX') (Line: 1254)
template_preprocess_ebsco_result(Array, 'ebsco_result', Array) (Line: 284)
...

The suggested fix is to replace this:

https://github.com/ebsco/edsapi-drupal8-plugin/blob/f6c435f262c1d8ee0d9777b2591803139e99087b/ebsco.module#L1513-L1520

With an anonymous function. Code example with preg_replace_callback here

abbydrury commented 2 years ago

This still appears in the 8.x and 9.x branches.