Fixed XF301VB: Add redirects for announcement.php URLs

Steffen

Well-known member
I think the forum is an appropriate redirect target because the importer turns announcements into notices.

Diff:
diff --git a/src/addons/XF301VB/Mvc/Router.php b/src/addons/XF301VB/Mvc/Router.php
index c42c5adbd..27917e7e8 100644
--- a/src/addons/XF301VB/Mvc/Router.php
+++ b/src/addons/XF301VB/Mvc/Router.php
@@ -128,6 +128,7 @@ class Router extends \XF\Mvc\Router
             case 'printthread.php':
             case 'showpost.php':
             case 'forumdisplay.php':
+            case 'announcement.php':
             case 'member.php':
             case 'attachment.php':
             case 'private.php':
diff --git a/src/addons/XF301VB/Pub/Controller/Redirect.php b/src/addons/XF301VB/Pub/Controller/Redirect.php
index 21e610e04..456b38f45 100644
--- a/src/addons/XF301VB/Pub/Controller/Redirect.php
+++ b/src/addons/XF301VB/Pub/Controller/Redirect.php
@@ -20,6 +20,11 @@ class Redirect extends Controller
         return $this->redirectContent($params, 'node', 'XF:Node', 'forums', $oldId);
     }
 
+    public function actionAnnouncement(ParameterBag $params)
+    {
+        return $this->rerouteController(__CLASS__, 'forum', $params);
+    }
+
     public function actionForumFeed(ParameterBag $params)
     {
         $oldId = $params->forum_id;
 

jkilbride

New member
@Steffen The code above fails on requests like this: announcement.php?s=3197cb9546da32356b6eeecb6e642306&f=10, which I have seen in my logs. Borrowing from the code you have for external.php, I added this and it seems to work for all cases:

Code:
case 'announcement.php':
{
    $forum_id = $request->get('f');
    if ($forum_id) {
        return $this->newRedirectRoute('announcement', [
            'id_name' => 'f',
            'content_id' => $forum_id
        ]);
    } else {
        return $this->newRedirectRoute('simple-redirect', [
            'route_path' => 'forums'
        ]);
    }
}
 
Top