From d6c8e5a8f94a99fcf176f53577c8a11b6eab3796 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 27 May 2022 14:19:50 +0200 Subject: [PATCH] DRY up abbreviation retrieval in RoutingCacheBuilder::getCustomUrls() --- .../builder/RoutingCacheBuilder.class.php | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) 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 0a25021a5d..49026d194f 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php @@ -270,42 +270,39 @@ class RoutingCacheBuilder extends AbstractCacheBuilder $cmsPageID = $matches[1]; } - $abbreviations = []; foreach ($rows as $row) { $customUrl = FileUtil::removeLeadingSlash(FileUtil::removeTrailingSlash($row['controllerCustomURL'])); $packageID = $row['applicationPackageID']; - if (!isset($abbreviations[$packageID])) { - $abbreviations[$packageID] = ApplicationHandler::getInstance()->getAbbreviation($packageID); - } + $abbreviation = ApplicationHandler::getInstance()->getAbbreviation($packageID); - if (!isset($data['lookup'][$abbreviations[$packageID]])) { - $data['lookup'][$abbreviations[$packageID]] = []; - $data['reverse'][$abbreviations[$packageID]] = []; + if (!isset($data['lookup'][$abbreviation])) { + $data['lookup'][$abbreviation] = []; + $data['reverse'][$abbreviation] = []; } if (isset($row['controller'])) { - $data['lookup'][$abbreviations[$packageID]][$customUrl] = $row['controller']; - $data['reverse'][$abbreviations[$packageID]][$this->classNameToControllerName($row['controller'])] = $customUrl; + $data['lookup'][$abbreviation][$customUrl] = $row['controller']; + $data['reverse'][$abbreviation][$this->classNameToControllerName($row['controller'])] = $customUrl; } else { $cmsIdentifier = '__WCF_CMS__' . $row['pageID'] . '-' . ($row['languageID'] ?: 0); // Discard the custom url if this CMS page is the landing page of its associated app. if ( - !empty($landingPages[$abbreviations[$packageID]]) - && $landingPages[$abbreviations[$packageID]][0] === '__WCF_CMS__' . $row['pageID'] + !empty($landingPages[$abbreviation]) + && $landingPages[$abbreviation][0] === '__WCF_CMS__' . $row['pageID'] && !$row['languageID'] ) { $customUrl = ''; } - $data['reverse'][$abbreviations[$packageID]][$cmsIdentifier] = $customUrl; + $data['reverse'][$abbreviation][$cmsIdentifier] = $customUrl; - if ($cmsPageID && $abbreviations[$packageID] === 'wcf') { + if ($cmsPageID && $abbreviation === 'wcf') { if ($customUrl === '' && $cmsPageID != $row['pageID']) { continue; } } - $data['lookup'][$abbreviations[$packageID]][$customUrl] = $cmsIdentifier; + $data['lookup'][$abbreviation][$customUrl] = $cmsIdentifier; } } -- 2.20.1