Use ControllerMap::transformController() in RoutingCacheBuilder::getCaseInsensitiveCo...
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 27 Jun 2022 13:10:54 +0000 (15:10 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 27 Jun 2022 14:53:49 +0000 (16:53 +0200)
The implementation is absolutely identical and thus can and should be unified.

A behavioral change without any externally visible effect is introduced: For
`TAJAXException` the last part (`Exception`) is no longer stripped. This is
completely irrelevant, as `ControllerMap::getLegacyClassData()` ignores all
classNames that do not end in Action, Form, or Page.

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

index 794b95eddb6d1ce4e3d50b1b71f128dc7ec0ba2f..16619e646b7674f6d55bc882665153ff3a821654 100644 (file)
@@ -150,34 +150,10 @@ class RoutingCacheBuilder extends AbstractCacheBuilder
 
                         // search for files with two consecutive upper-case letters but ignore interfaces such as `IPage`
                         if (!\preg_match('~^I[A-Z][a-z]~', $filename) && \preg_match('~[A-Z]{2,}~', $filename)) {
-                            $parts = \preg_split(
-                                '~([A-Z][a-z0-9]+)~',
-                                $filename,
-                                -1,
-                                \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY
+                            $ciController = ControllerMap::transformController(
+                                \preg_replace('/(Action|Form|Page)$/', '', $filename)
                             );
 
-                            // drop the last part containing `Action` or `Page`
-                            \array_pop($parts);
-
-                            // fix for invalid pages that would cause single character fragments
-                            $sanitizedParts = [];
-                            $tmp = '';
-                            foreach ($parts as $part) {
-                                if (\strlen($part) === 1) {
-                                    $tmp .= $part;
-                                    continue;
-                                }
-
-                                $sanitizedParts[] = $tmp . $part;
-                                $tmp = '';
-                            }
-                            if ($tmp) {
-                                $sanitizedParts[] = $tmp;
-                            }
-                            $parts = $sanitizedParts;
-
-                            $ciController = \implode('-', \array_map('strtolower', $parts));
                             $className = $abbreviation . '\\' . ($libDirectory === 'lib/acp' ? 'acp\\' : '') . $pageType . '\\' . $filename;
 
                             $data[$abbreviation][$libDirectory === 'lib' ? 'frontend' : 'acp'][$ciController] = $className;