From: Tim Düsterhus Date: Mon, 27 Jun 2022 13:10:54 +0000 (+0200) Subject: Use ControllerMap::transformController() in RoutingCacheBuilder::getCaseInsensitiveCo... X-Git-Tag: 6.0.0_Alpha_1~1140^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c404c8a9d6bb56bf9d36ba47f8a77b7948eedf91;p=GitHub%2FWoltLab%2FWCF.git Use ControllerMap::transformController() in RoutingCacheBuilder::getCaseInsensitiveControllers() 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. --- diff --git a/wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php index 794b95eddb..16619e646b 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php @@ -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;