Skip to content

Commit e15c5dd

Browse files
committed
geshi: fix an incompatibility with PHP 8
Per https://sourceforge.net/p/geshi/bugs/247/, fix an incompatibility in geshi with PHP 8. Signed-off-by: Jeff Squyres <jeff@squyres.com>
1 parent 405fec4 commit e15c5dd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

includes/geshi.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4695,7 +4695,15 @@ protected function _optimize_regexp_list_tokens_to_string(&$tokens, $recursed =
46954695
// TODO: a|bb|c => [ac]|bb
46964696
static $callback_2;
46974697
if (!isset($callback_2)) {
4698-
$callback_2 = create_function('$matches', 'return "[" . str_replace("|", "", $matches[1]) . "]";');
4698+
# JMS: This is the last release of Geshi; there has
4699+
# been no new version since 2017. However, it has a
4700+
# problem with PHP 8. Got this fix from
4701+
# https://sourceforge.net/p/geshi/bugs/247/.
4702+
// create_function has been removed in php8 --> replaced by anonymous function
4703+
//$callback_2 = create_function('$matches', 'return "[" . str_replace("|", "", $matches[1]) . "]";');
4704+
$callback_2 = function($matches) {
4705+
return (count($matches) > 1) ? "[" . str_replace("|", "", $matches[1]) . "]" : "[]";
4706+
};
46994707
}
47004708
$list = preg_replace_callback('#\(\?\:((?:.\|)+.)\)#', $callback_2, $list);
47014709
}

0 commit comments

Comments
 (0)