Remove reverse lookup for RoutingCacheBuilder::getCaseInsensitiveControllers()
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 2 Jun 2022 10:42:36 +0000 (12:42 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 2 Jun 2022 10:42:36 +0000 (12:42 +0200)
This reverse lookup is not used, drop it to simplify the logic.

wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php
wcfsetup/install/files/lib/system/request/ControllerMap.class.php

index d2a219ab4c757fcdf7716af119876bfaf1ff4685..fa8b25bc31517cd50e4b82a1f25a51cc8a5ae40e 100644 (file)
@@ -130,10 +130,7 @@ class RoutingCacheBuilder extends AbstractCacheBuilder
      */
     protected function getCaseInsensitiveControllers()
     {
-        $data = [
-            'lookup' => [],
-            'reverse' => [],
-        ];
+        $data = [];
 
         if (!PACKAGE_ID) {
             return $data;
@@ -142,6 +139,11 @@ class RoutingCacheBuilder extends AbstractCacheBuilder
         $applications = ApplicationHandler::getInstance()->getApplications();
         foreach ($applications as $application) {
             $abbreviation = $application->getAbbreviation();
+
+            $data[$abbreviation] = ['acp' => [], 'frontend' => []];
+            $this->brokenControllers['lookup'][$abbreviation] = [];
+            $this->brokenControllers['reverse'][$abbreviation] = [];
+
             $directory = Application::getDirectory($abbreviation);
             foreach (['lib', 'lib/acp'] as $libDirectory) {
                 foreach (['action', 'form', 'page'] as $pageType) {
@@ -192,21 +194,10 @@ class RoutingCacheBuilder extends AbstractCacheBuilder
                             $ciController = \implode('-', \array_map('strtolower', $parts));
                             $className = $abbreviation . '\\' . ($libDirectory === 'lib/acp' ? 'acp\\' : '') . $pageType . '\\' . $filename;
 
-                            if (!isset($data['lookup'][$abbreviation])) {
-                                $data['lookup'][$abbreviation] = ['acp' => [], 'frontend' => []];
-                            }
-                            $data['lookup'][$abbreviation][$libDirectory === 'lib' ? 'frontend' : 'acp'][$ciController] = $className;
-                            $data['reverse'][$filename] = $ciController;
+                            $data[$abbreviation][$libDirectory === 'lib' ? 'frontend' : 'acp'][$ciController] = $className;
 
                             if ($isBrokenController) {
-                                if (!isset($this->brokenControllers['lookup'][$abbreviation])) {
-                                    $this->brokenControllers['lookup'][$abbreviation] = [];
-                                }
                                 $this->brokenControllers['lookup'][$abbreviation][$ciController] = $className;
-
-                                if (!isset($this->brokenControllers['reverse'][$abbreviation])) {
-                                    $this->brokenControllers['reverse'][$abbreviation] = [];
-                                }
                                 $this->brokenControllers['reverse'][$abbreviation][\preg_replace(
                                     '~(?:Page|Form|Action)$~',
                                     '',
index 3b2c15eef746ff425f99ba99cd04d64b01f7d7b3..e484385a050f49ea201b2144fd1417b80aefab1d 100644 (file)
@@ -362,8 +362,8 @@ class ControllerMap extends SingletonFactory
     protected function getLegacyClassData($application, $controller, $isAcpRequest)
     {
         $environment = $isAcpRequest ? 'acp' : 'frontend';
-        if (isset($this->ciControllers['lookup'][$application][$environment][$controller])) {
-            $className = $this->ciControllers['lookup'][$application][$environment][$controller];
+        if (isset($this->ciControllers[$application][$environment][$controller])) {
+            $className = $this->ciControllers[$application][$environment][$controller];
 
             if (\preg_match('~\\\\(?P<controller>[^\\\\]+)(Action|Form|Page)$~', $className, $matches)) {
                 return [