From 74ee82c67ef8f3ae1f2adcc63e7c76cc26b60f19 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 24 Jun 2019 12:34:28 +0200 Subject: [PATCH] Application overrides with custom urls for "system" pages See #2934 --- .../cache/builder/RoutingCacheBuilder.class.php | 12 +++++++++++- .../files/lib/system/request/ControllerMap.class.php | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) 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 3d1ea7719e..0490a1037f 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php @@ -74,7 +74,7 @@ class RoutingCacheBuilder extends AbstractCacheBuilder { $languageIDs[] = $language->languageID; } - $sql = "SELECT pageID, pageType, controller, applicationPackageID, overrideApplicationPackageID + $sql = "SELECT pageID, pageType, controller, controllerCustomURL, applicationPackageID, overrideApplicationPackageID FROM wcf".WCF_N."_page WHERE overrideApplicationPackageID IS NOT NULL"; $statement = WCF::getDB()->prepareStatement($sql); @@ -88,6 +88,16 @@ class RoutingCacheBuilder extends AbstractCacheBuilder { $controller = preg_replace('/(?:Action|Form|Page)$/', '', array_pop($tmp)); $data['lookup'][$overrideApplication][$controller] = $application; $data['reverse'][$application][$controller] = $overrideApplication; + + $controllerCustomURL = $row['controllerCustomURL']; + if ($controllerCustomURL) { + $data['lookup'][$overrideApplication][$controllerCustomURL] = $application; + + // Copy the custom url to the new application. + if (isset($customUrls['reverse'][$application][$controller])) { + $customUrls['reverse'][$overrideApplication][$controller] = $customUrls['reverse'][$application][$controller]; + } + } } else { foreach ($languageIDs as $languageID) { diff --git a/wcfsetup/install/files/lib/system/request/ControllerMap.class.php b/wcfsetup/install/files/lib/system/request/ControllerMap.class.php index e26d1b3129..da289fcb60 100644 --- a/wcfsetup/install/files/lib/system/request/ControllerMap.class.php +++ b/wcfsetup/install/files/lib/system/request/ControllerMap.class.php @@ -134,6 +134,10 @@ class ControllerMap extends SingletonFactory { * @return array empty array if there is no exact match */ public function resolveCustomController($application, $controller) { + if (isset($this->applicationOverrides['lookup'][$application][$controller])) { + $application = $this->applicationOverrides['lookup'][$application][$controller]; + } + if (isset($this->customUrls['lookup'][$application]) && isset($this->customUrls['lookup'][$application][$controller])) { $data = $this->customUrls['lookup'][$application][$controller]; if (preg_match('~^__WCF_CMS__(?P\d+)-(?P\d+)$~', $data, $matches)) { -- 2.20.1