From e05b8ecc05dc6791960d67352fd2dba10cffe22a Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 20 Nov 2016 16:10:26 +0100 Subject: [PATCH] Stop using deprecated `Callback` class --- .../lib/system/exporter/Kunena3xExporter.class.php | 5 ++--- files/lib/system/exporter/MyBB16xExporter.class.php | 9 ++++----- files/lib/system/exporter/SMF2xExporter.class.php | 5 ++--- files/lib/system/exporter/VB3or4xExporter.class.php | 5 ++--- files/lib/system/exporter/VB5xExporter.class.php | 5 ++--- files/lib/system/exporter/XF12xExporter.class.php | 13 ++++++------- 6 files changed, 18 insertions(+), 24 deletions(-) diff --git a/files/lib/system/exporter/Kunena3xExporter.class.php b/files/lib/system/exporter/Kunena3xExporter.class.php index cca1592..b2f2032 100644 --- a/files/lib/system/exporter/Kunena3xExporter.class.php +++ b/files/lib/system/exporter/Kunena3xExporter.class.php @@ -3,7 +3,6 @@ namespace wcf\system\exporter; use wcf\data\user\group\UserGroup; use wcf\system\importer\ImportHandler; use wcf\system\request\LinkHandler; -use wcf\system\Callback; use wcf\system\Regex; use wcf\util\FileUtil; use wcf\util\PasswordUtil; @@ -500,7 +499,7 @@ class Kunena3xExporter extends AbstractExporter { if ($quoteRegex === null) { $quoteRegex = new Regex('\[quote="(.*?)" post=(\d+)\]', Regex::CASE_INSENSITIVE); - $quoteCallback = new Callback(function ($matches) { + $quoteCallback = function ($matches) { $username = str_replace(["\\", "'"], ["\\\\", "\'"], $matches[1]); $postID = $matches[2]; @@ -512,7 +511,7 @@ class Kunena3xExporter extends AbstractExporter { $postLink = str_replace(["\\", "'"], ["\\\\", "\'"], $postLink); return "[quote='".$username."','".$postLink."']"; - }); + }; } // use proper WCF 2 bbcode diff --git a/files/lib/system/exporter/MyBB16xExporter.class.php b/files/lib/system/exporter/MyBB16xExporter.class.php index d11ae7f..4b949da 100644 --- a/files/lib/system/exporter/MyBB16xExporter.class.php +++ b/files/lib/system/exporter/MyBB16xExporter.class.php @@ -11,7 +11,6 @@ use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\database\DatabaseException; use wcf\system\importer\ImportHandler; use wcf\system\request\LinkHandler; -use wcf\system\Callback; use wcf\system\Regex; use wcf\system\WCF; use wcf\util\ArrayUtil; @@ -1304,7 +1303,7 @@ class MyBB16xExporter extends AbstractExporter { if ($videoRegex === null) { $videoRegex = new Regex('\[video=[a-z]+\]'); $quoteRegex = new Regex('\[quote=\'(.*?)\' pid=\'(\d+)\' dateline=\'\d+\'\]'); - $quoteCallback = new Callback(function ($matches) { + $quoteCallback = function ($matches) { $username = str_replace(["\\", "'"], ["\\\\", "\'"], $matches[1]); $postID = $matches[2]; @@ -1316,9 +1315,9 @@ class MyBB16xExporter extends AbstractExporter { $postLink = str_replace(["\\", "'"], ["\\\\", "\'"], $postLink); return "[quote='".$username."','".$postLink."']"; - }); + }; $imgRegex = new Regex('\[img(?:=(\d)x\d)?(?: align=(left|right))?\](?:\r\n?|\n?)(https?://(?:[^<>"\']+?))\[/img\]'); - $imgCallback = new Callback(function ($matches) { + $imgCallback = function ($matches) { $escapedLink = str_replace(["\\", "'"], ["\\\\", "\'"], $matches[3]); if ($matches[1] && $matches[2]) { return "[img='".$escapedLink."',".$matches[2].",".$matches[1]."][/img]"; @@ -1332,7 +1331,7 @@ class MyBB16xExporter extends AbstractExporter { else { return "[img]".$matches[3]."[/img]"; } - }); + }; $attachmentRegex = new Regex('\[attachment=([0-9]+)\]'); } diff --git a/files/lib/system/exporter/SMF2xExporter.class.php b/files/lib/system/exporter/SMF2xExporter.class.php index 1f0c4cb..4b02853 100644 --- a/files/lib/system/exporter/SMF2xExporter.class.php +++ b/files/lib/system/exporter/SMF2xExporter.class.php @@ -7,7 +7,6 @@ use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\database\DatabaseException; use wcf\system\importer\ImportHandler; use wcf\system\request\LinkHandler; -use wcf\system\Callback; use wcf\system\Regex; use wcf\system\WCF; use wcf\util\ArrayUtil; @@ -1373,7 +1372,7 @@ class SMF2xExporter extends AbstractExporter { if ($sizeRegex === null) { $quoteRegex = new Regex('\[quote author=(.*?) link=topic=\d+\.msg(\d+)#msg\\2 date=\d+\]'); - $quoteCallback = new Callback(function ($matches) { + $quoteCallback = function ($matches) { $username = str_replace(["\\", "'"], ["\\\\", "\'"], $matches[1]); $postID = $matches[2]; @@ -1385,7 +1384,7 @@ class SMF2xExporter extends AbstractExporter { $postLink = str_replace(["\\", "'"], ["\\\\", "\'"], $postLink); return "[quote='".$username."','".$postLink."']"; - }); + }; $sizeRegex = new Regex('\[size=(8|10|12|14|18|24|34)pt\]'); } diff --git a/files/lib/system/exporter/VB3or4xExporter.class.php b/files/lib/system/exporter/VB3or4xExporter.class.php index 46592c3..0a2021b 100644 --- a/files/lib/system/exporter/VB3or4xExporter.class.php +++ b/files/lib/system/exporter/VB3or4xExporter.class.php @@ -9,7 +9,6 @@ use wcf\data\user\option\UserOption; use wcf\system\database\DatabaseException; use wcf\system\importer\ImportHandler; use wcf\system\request\LinkHandler; -use wcf\system\Callback; use wcf\system\Regex; use wcf\system\WCF; use wcf\util\ArrayUtil; @@ -1972,7 +1971,7 @@ class VB3or4xExporter extends AbstractExporter { if ($quoteRegex === null) { $quoteRegex = new Regex('\[quote=(.*?);(\d+)\]', Regex::CASE_INSENSITIVE); - $quoteCallback = new Callback(function ($matches) { + $quoteCallback = function ($matches) { $username = str_replace(["\\", "'"], ["\\\\", "\'"], $matches[1]); $postID = $matches[2]; @@ -1984,7 +1983,7 @@ class VB3or4xExporter extends AbstractExporter { $postLink = str_replace(["\\", "'"], ["\\\\", "\'"], $postLink); return "[quote='".$username."','".$postLink."']"; - }); + }; $mediaRegex = new Regex('\[video=([a-z]+);([a-z0-9-_]+)\]', Regex::CASE_INSENSITIVE); } diff --git a/files/lib/system/exporter/VB5xExporter.class.php b/files/lib/system/exporter/VB5xExporter.class.php index ded2ffe..d57d484 100644 --- a/files/lib/system/exporter/VB5xExporter.class.php +++ b/files/lib/system/exporter/VB5xExporter.class.php @@ -5,7 +5,6 @@ use wcf\data\user\group\UserGroup; use wcf\system\database\DatabaseException; use wcf\system\importer\ImportHandler; use wcf\system\request\LinkHandler; -use wcf\system\Callback; use wcf\system\Regex; use wcf\system\WCF; use wcf\util\FileUtil; @@ -756,7 +755,7 @@ class VB5xExporter extends AbstractExporter { if ($quoteRegex === null) { $quoteRegex = new Regex('\[quote=(.*?);n(\d+)\]', Regex::CASE_INSENSITIVE); - $quoteCallback = new Callback(function ($matches) { + $quoteCallback = function ($matches) { $username = str_replace(["\\", "'"], ["\\\\", "\'"], $matches[1]); $postID = $matches[2]; @@ -768,7 +767,7 @@ class VB5xExporter extends AbstractExporter { $postLink = str_replace(["\\", "'"], ["\\\\", "\'"], $postLink); return "[quote='".$username."','".$postLink."']"; - }); + }; $imgRegex = new Regex('\[img width=(\d+) height=\d+\](.*?)\[/img\]'); $mediaRegex = new Regex('\[video=([a-z]+);([a-z0-9-_]+)\]', Regex::CASE_INSENSITIVE); diff --git a/files/lib/system/exporter/XF12xExporter.class.php b/files/lib/system/exporter/XF12xExporter.class.php index 6ef27dc..76f4779 100644 --- a/files/lib/system/exporter/XF12xExporter.class.php +++ b/files/lib/system/exporter/XF12xExporter.class.php @@ -10,7 +10,6 @@ use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\exception\SystemException; use wcf\system\importer\ImportHandler; use wcf\system\request\LinkHandler; -use wcf\system\Callback; use wcf\system\Regex; use wcf\system\WCF; use wcf\util\FileUtil; @@ -1520,7 +1519,7 @@ class XF12xExporter extends AbstractExporter { if ($mediaRegex === null) { $mediaRegex = new Regex('\[media=(youtube|vimeo|dailymotion)\]([a-zA-Z0-9_-]+)', Regex::CASE_INSENSITIVE); - $mediaCallback = new Callback(function ($matches) { + $mediaCallback = function ($matches) { switch ($matches[1]) { case 'youtube': $url = 'https://www.youtube.com/watch?v='.$matches[2]; @@ -1534,10 +1533,10 @@ class XF12xExporter extends AbstractExporter { } return '[media]'.$url; - }); + }; $userRegex = new Regex('\[user=(\d+)\](.*?)\[/user\]', Regex::CASE_INSENSITIVE); - $userCallback = new Callback(function ($matches) { + $userCallback = function ($matches) { $userLink = LinkHandler::getInstance()->getLink('User', [ 'userID' => $matches[1], 'forceFrontend' => true @@ -1546,10 +1545,10 @@ class XF12xExporter extends AbstractExporter { $userLink = str_replace(["\\", "'"], ["\\\\", "\'"], $userLink); return "[url='".$userLink."']".$matches[2]."[/url]"; - }); + }; $quoteRegex = new Regex('\[quote=("?)(?P[^,\]\n]*)(?:, post: (?P\d+)(?:, member: \d+)?)?\1\]', Regex::CASE_INSENSITIVE); - $quoteCallback = new Callback(function ($matches) { + $quoteCallback = function ($matches) { if (isset($matches['username']) && $matches['username']) { $username = str_replace(["\\", "'"], ["\\\\", "\'"], $matches['username']); @@ -1567,7 +1566,7 @@ class XF12xExporter extends AbstractExporter { return "[quote='".$username."']"; } return "[quote]"; - }); + }; } $message = $mediaRegex->replace($message, $mediaCallback); -- 2.20.1