Menu

#247 PHP-function create_function() has been deprecated

Development Strand
open
nobody
PHP 7.2 (1)
5
2022-04-22
2017-12-06
Alex
No

The PHP-function create_function() has been deprecated as of PHP 7.2.0 (https://wiki.php.net/rfc/deprecations_php_7_2#create_function), but is still used in GeSHI:

library/geshi/geshi.php: //$list = preg_replace_callback('#(?<=^|\:|\|)\w+?(\w+)(?:\|.+\1)+(?=\|)#', create_function(
library/geshi/geshi.php: $callback_2 = create_function('$matches', 'return "[" . str_replace("|", "", $matches[1]) . "]";');

Discussion

  • Pat

    Pat - 2019-01-13

    Hello,

    We have the same in my enterprise. Here is the warning:

    Deprecated function : Function create_function() is deprecated dans GeSHi->_optimize_regexp_list_tokens_to_string() (ligne 4736 dans /home/admin/web/domain.com/public_html/sites/all/libraries/geshi/geshi.php
    
     
  • MichaeL

    MichaeL - 2022-04-22

    Hello,

    a simple fix reads

        if (!isset($callback_2)) {
            // create_function has been removed in php8 --> replaced by anonymous function
            //$callback_2 = create_function('$matches', 'return "[" . str_replace("|", "", $matches[1]) . "]";');
            $callback_2 = function($matches) {
                return (count($matches) > 1) ? "[" . str_replace("|", "", $matches[1]) . "]" : "[]";
            };
        }
    

    regards
    Micha

     

Log in to post a comment.

MongoDB Logo MongoDB