Skip to content

Commit

Permalink
geshi: fix an incompatibility with PHP 8
Browse files Browse the repository at this point in the history
Per https://sourceforge.net/p/geshi/bugs/247/, fix an incompatibility
in geshi with PHP 8.

Signed-off-by: Jeff Squyres <[email protected]>
  • Loading branch information
jsquyres committed Dec 4, 2024
1 parent 405fec4 commit e15c5dd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion includes/geshi.php
Original file line number Diff line number Diff line change
Expand Up @@ -4695,7 +4695,15 @@ protected function _optimize_regexp_list_tokens_to_string(&$tokens, $recursed =
// TODO: a|bb|c => [ac]|bb
static $callback_2;
if (!isset($callback_2)) {
$callback_2 = create_function('$matches', 'return "[" . str_replace("|", "", $matches[1]) . "]";');
# JMS: This is the last release of Geshi; there has
# been no new version since 2017. However, it has a
# problem with PHP 8. Got this fix from
# https://sourceforge.net/p/geshi/bugs/247/.
// 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]) . "]" : "[]";
};
}
$list = preg_replace_callback('#\(\?\:((?:.\|)+.)\)#', $callback_2, $list);
}
Expand Down

0 comments on commit e15c5dd

Please sign in to comment.