Remove dead branch in RequestHandler::handleDefaultController()
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 22 Jun 2022 13:48:41 +0000 (15:48 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 22 Jun 2022 13:48:41 +0000 (15:48 +0200)
It turns out that that the third and last remaining change of
000c0c8a26491708b2af995bdd6f0e627cc75161 is also broken.

After effectively reverting / removing the logic in the other two files
modified by that commit in e0976fcfdbeeafc80bc202f80ae2f946326d465d and
416dafddb18a3e82750c6e8ca089d4f9132b39dc, this commit cleans up the last
change.

Since 000c0c8a26491708b2af995bdd6f0e627cc75161 is is impossible for this
redirect to happen and the reason is simple:

The logic will only ever be executed for non-CMS pages, as these are the only
ones where `->lookupDefaultController()` returns an application.

The `controller` return value of `->lookupDefaultController()` will contain the
`routePart` (i.e. `board-list`). However the application overrides are keyed by
the controller name (i.e. `BoardList`), causing the lookup to always fail,
resulting in the given `$application` being returned as-is in `$override`. As
both values are identical, the branch will never be taken and the redirect will
never be executed.

wcfsetup/install/files/lib/system/request/RequestHandler.class.php

index 697347879b23dd69cdf9203b94f46ede577b7e08..8e18084f9e15c4a8d6fa0dcb00ad5747311597df 100644 (file)
@@ -251,25 +251,6 @@ final class RequestHandler extends SingletonFactory
     protected function handleDefaultController(string $application, array $routeData): array
     {
         $data = ControllerMap::getInstance()->lookupDefaultController($application);
-        if (!empty($data['application']) && $data['application'] !== $application) {
-            $override = ControllerMap::getInstance()->getApplicationOverride($application, $data['controller']);
-            if ($application !== $override) {
-                HeaderUtil::redirect(
-                    LinkHandler::getInstance()->getLink(
-                        ControllerMap::getInstance()->resolve(
-                            $data['application'],
-                            $data['controller'],
-                            false
-                        )['controller'],
-                        ['application' => $data['application']]
-                    ),
-                    true,
-                    true
-                );
-
-                exit;
-            }
-        }
 
         // copy route data
         foreach ($data as $key => $value) {