Phamlp on PHP 8: polyfill for create_function()

Created on 24 February 2024, 4 months ago

Problem/Motivation

On PHP 8, the shipped Phamlp has a fatal error due to create_function() not being defined.

Steps to reproduce

Run Sasson 2.x on PHP 8.

Temporary resolution

Add this polyfill in a .module file:

if (!function_exists('create_function')) {
  // Polyfill to get Phamlp running in PHP 8.0+
  // Code taken from https://github.com/php5friends/polyfill-create_function/blob/master/create_function.php
  function create_function($args, $code)
  {
    static $i; 
  
    $namespace = 'SOME-UNIQUE-VALUE';

    do {
      $i++;
      $name = "__{$namespace}_lambda_{$i}";
    } while (\function_exists($name));

    eval("function {$name}({$args}) { {$code} }");

    return $name;
  }
}
πŸ’¬ Support request
Status

Active

Version

2.10

Component

Miscellaneous

Created by

πŸ‡¨πŸ‡΄Colombia jedihe

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024