From: Tim Düsterhus Date: Thu, 2 Jun 2022 10:08:36 +0000 (+0200) Subject: Simplify RoutingCacheBuilder::getCustomUrls() X-Git-Tag: 6.0.0_Alpha_1~1214 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ffc766d43a1845c35741737522e0fc53b6aadc8d;p=GitHub%2FWoltLab%2FWCF.git Simplify RoutingCacheBuilder::getCustomUrls() By creating the arrays for all known abbreviations early we can avoid checking the existence of them over and over again. --- 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 0c6548ef3b..905bbe935d 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php @@ -239,6 +239,11 @@ class RoutingCacheBuilder extends AbstractCacheBuilder return $data; } + foreach (ApplicationHandler::getInstance()->getAbbreviations() as $abbreviation) { + $data['lookup'][$abbreviation] = []; + $data['reverse'][$abbreviation] = []; + } + // fetch pages with a controller and a custom url $sql = "SELECT controller, controllerCustomURL, @@ -270,11 +275,6 @@ class RoutingCacheBuilder extends AbstractCacheBuilder $packageID = $row['applicationPackageID']; $abbreviation = ApplicationHandler::getInstance()->getAbbreviation($packageID); - if (!isset($data['lookup'][$abbreviation])) { - $data['lookup'][$abbreviation] = []; - $data['reverse'][$abbreviation] = []; - } - if (isset($row['controller'])) { $data['lookup'][$abbreviation][$customUrl] = $row['controller']; $data['reverse'][$abbreviation][$this->classNameToControllerName($row['controller'])] = $customUrl; @@ -289,10 +289,6 @@ class RoutingCacheBuilder extends AbstractCacheBuilder foreach ($this->brokenControllers as $type => $brokenControllers) { foreach ($brokenControllers as $application => $controllers) { foreach ($controllers as $key => $value) { - if (!isset($data[$type][$application])) { - $data[$type][$application] = []; - } - if (!isset($data[$type][$application][$key])) { $data[$type][$application][$key] = $value; }