Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solving PHP 7.2 deprecation of create_function. #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions difflib.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,9 @@ public function __construct($data, $linepos) {
$data = str_replace(array(' ', ' ', ' ') , ' ', $data);

// Tags replaced with equal number of spaces
$data = preg_replace_callback('/<.*?'.'>/', create_function(
'$matches', 'return preg_replace("/./"," ", $matches[0]);'), $data);
$data = preg_replace_callback('/<.*?'.'>/', function($matches) {
return preg_replace("/./"," ", $matches[0]);
}, $data);

// 2. Analyse string so that each space-separated thing
// is counted as a 'word' (note these may not be real words,
Expand Down Expand Up @@ -409,8 +410,9 @@ function ouwiki_diff_html_to_lines($content) {
// Get rid of all script, style, object tags (that might contain non-text
// outside tags)
$content = preg_replace_callback(
'^(<script .*?</script>)|(<object .*?</object>)|(<style .*?</style>)^i', create_function(
'$matches', 'return preg_replace("/./"," ",$matches[0]);'), $content);
'^(<script .*?</script>)|(<object .*?</object>)|(<style .*?</style>)^i', function($matches) {
return preg_replace("/./"," ",$matches[0]);
}, $content);

// Get rid of all ` symbols as we are going to use these for a marker later.
$content = preg_replace('/[`]/', ' ', $content);
Expand All @@ -424,8 +426,9 @@ function ouwiki_diff_html_to_lines($content) {
}
$taglist .= "<$blocktag>|<\\/$blocktag>";
}
$content = preg_replace_callback('/(('.$taglist.')\s*)+/i', create_function(
'$matches', 'return "`".preg_replace("/./"," ",substr($matches[0],1));'), $content);
$content = preg_replace_callback('/(('.$taglist.')\s*)+/i', function($matches) {
return "`".preg_replace("/./"," ",substr($matches[0],1));
}, $content);

// Now go through splitting each line
$lines = array();
Expand Down Expand Up @@ -697,7 +700,9 @@ function ouwiki_diff($file1, $file2) {
*/
function ouwiki_diff_add_markers($html, $words, $markerclass, $beforetext, $aftertext) {
// Sort words by start position
usort($words, create_function('$a,$b', 'return $a->start-$b->start;'));
usort($words, function($a, $b) {
return $a->start-$b->start;
});

// Add marker for each word. We use an odd tag name which will
// be replaced by span later, this for ease of replacing
Expand Down
4 changes: 3 additions & 1 deletion locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,9 @@ function ouwiki_display_subwiki_selector($subwiki, $ouwiki, $cm, $context, $cour
switch($ouwiki->subwikis) {
case OUWIKI_SUBWIKIS_GROUPS:
$groups = groups_get_activity_allowed_groups($cm);
uasort($groups, create_function('$a,$b', 'return strcasecmp($a->name,$b->name);'));
uasort($groups, function($a, $b) {
return strcasecmp($a->name,$b->name);
});
$wikifor = htmlspecialchars($groups[$subwiki->groupid]->name);

// Do they have more than one?
Expand Down