From: Tim Düsterhus Date: Wed, 11 May 2022 10:01:17 +0000 (+0200) Subject: Remove code paths that are only taken if `->isMultiDomainSetup()` returns `true` X-Git-Tag: 6.0.0_Alpha_1~1291^2~10 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ea662ea9d28f7b178eb65a324ee9ba7613dc7fa2;p=GitHub%2FWoltLab%2FWCF.git Remove code paths that are only taken if `->isMultiDomainSetup()` returns `true` see #4295 --- diff --git a/wcfsetup/install/files/acp/templates/applicationEdit.tpl b/wcfsetup/install/files/acp/templates/applicationEdit.tpl deleted file mode 100644 index fc43a29835..0000000000 --- a/wcfsetup/install/files/acp/templates/applicationEdit.tpl +++ /dev/null @@ -1,113 +0,0 @@ -{include file='header' pageTitle='wcf.acp.application.edit'} - -
-
-

{lang}wcf.acp.application.edit.title{/lang}

-
- - -
- -{include file='formError'} - -{if $success|isset} -

{lang}wcf.global.success.edit{/lang}

-{/if} - -
-
-

{lang}wcf.acp.application.domain{/lang}

- - -
-
- - {if $errorField == 'domainName'} - - {if $errorType == 'empty'} - {lang}wcf.global.form.error.empty{/lang} - {else} - {lang}wcf.acp.application.domainName.error.{$errorType}{/lang} - {/if} - - {/if} - {lang}wcf.acp.application.domainName.description{/lang} -
- - - -
-
- - {lang}wcf.acp.application.domainPath.description{/lang} - {if $errorField == 'domainPath'} - - {if $errorType == 'empty'} - {lang}wcf.global.form.error.empty{/lang} - {else} - {lang}wcf.acp.application.domainPath.error.{$errorType}{/lang} - {/if} - - {/if} -
- - -
-
-
- - {lang}wcf.acp.application.landingPage.description{/lang} -
-
- - {event name='domainFields'} -
- -
-
-

{lang}wcf.acp.application.cookie{/lang}

-

{lang}wcf.acp.application.cookie.warning{/lang}

-
- - -
-
- - {if $errorField == 'cookieDomain'} - - {if $errorType == 'empty'} - {lang}wcf.global.form.error.empty{/lang} - {else} - {lang}wcf.acp.application.cookieDomain.error.{$errorType}{/lang} - {/if} - - {/if} -
- - - {event name='cookieFields'} -
- - {event name='sections'} - -
- - {csrfToken} -
-
- -{include file='footer'} diff --git a/wcfsetup/install/files/acp/templates/applicationManagement.tpl b/wcfsetup/install/files/acp/templates/applicationManagement.tpl index 8e826aab1b..d3057d3b1f 100644 --- a/wcfsetup/install/files/acp/templates/applicationManagement.tpl +++ b/wcfsetup/install/files/acp/templates/applicationManagement.tpl @@ -14,68 +14,62 @@ {/hascontent} -{if $isMultiDomainSetup} -
{lang}wcf.acp.application.multiDomain{/lang}
-{/if} - {include file='formNotice' action='edit'}
- {if !$isMultiDomainSetup} -
-

{lang}wcf.acp.application.management.domain{/lang}

+
+

{lang}wcf.acp.application.management.domain{/lang}

- -
-
-
- https:// - -
- {if $errorField == 'domainName'} - - {if $errorType == 'empty'} - {lang}wcf.global.form.error.empty{/lang} - {else} - {lang}wcf.acp.application.management.domainName.error.{$errorType}{/lang} - {/if} - - {/if} - {lang}wcf.acp.application.management.domainName.description{/lang} -
- + +
+
+
+ https:// + +
+ {if $errorField == 'domainName'} + + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.application.management.domainName.error.{$errorType}{/lang} + {/if} + + {/if} + {lang}wcf.acp.application.management.domainName.description{/lang} +
+ - -
-
- - {if $errorField == 'cookieDomain'} - - {if $errorType == 'empty'} - {lang}wcf.global.form.error.empty{/lang} - {else} - {lang}wcf.acp.application.management.cookieDomain.error.{$errorType}{/lang} - {/if} - - {/if} - {lang}wcf.acp.application.management.cookieDomain.description{/lang} -
- -
+ +
+
+ + {if $errorField == 'cookieDomain'} + + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.application.management.cookieDomain.error.{$errorType}{/lang} + {/if} + + {/if} + {lang}wcf.acp.application.management.cookieDomain.description{/lang} +
+ +
- {* Keep the cookie domain in sync if it was previously identical. *} - {if $domainName === $cookieDomain} - - {/if} + domainName.addEventListener("input", () => { + cookieDomain.value = domainName.value; + }); + })(); + {/if}
diff --git a/wcfsetup/install/files/lib/acp/form/ApplicationEditForm.class.php b/wcfsetup/install/files/lib/acp/form/ApplicationEditForm.class.php deleted file mode 100644 index 1e761a9ce6..0000000000 --- a/wcfsetup/install/files/lib/acp/form/ApplicationEditForm.class.php +++ /dev/null @@ -1,273 +0,0 @@ - - * @package WoltLabSuite\Core\Acp\Form - */ -class ApplicationEditForm extends AbstractForm -{ - /** - * @inheritDoc - */ - public $activeMenuItem = 'wcf.acp.menu.link.application.management'; - - /** - * viewable application object - * @var ViewableApplication - */ - public $application; - - /** - * cookie domain - * @var string - */ - public $cookieDomain = ''; - - /** - * domain name - * @var string - */ - public $domainName = ''; - - /** - * domain path - * @var string - */ - public $domainPath = ''; - - /** - * landing page id - * @var int - */ - public $landingPageID = 0; - - /** - * @inheritDoc - */ - public $neededPermissions = ['admin.configuration.canManageApplication']; - - /** - * application package id - * @var int - */ - public $packageID = 0; - - /** - * @inheritDoc - */ - public $templateName = 'applicationEdit'; - - /** - * nested list of page nodes - * @var \RecursiveIteratorIterator - */ - public $pageNodeList; - - /** - * @inheritDoc - */ - public function readParameters() - { - parent::readParameters(); - - if (!ApplicationHandler::getInstance()->isMultiDomainSetup()) { - throw new IllegalLinkException(); - } - - if (isset($_REQUEST['id'])) { - $this->packageID = \intval($_REQUEST['id']); - } - $this->application = new ViewableApplication(new Application($this->packageID)); - if (!$this->application->packageID) { - throw new IllegalLinkException(); - } - - $this->pageNodeList = (new PageNodeTree())->getNodeList(); - } - - /** - * @inheritDoc - */ - public function readFormParameters() - { - parent::readFormParameters(); - - if (isset($_POST['cookieDomain'])) { - $this->cookieDomain = StringUtil::trim($_POST['cookieDomain']); - } - if (isset($_POST['domainName'])) { - $this->domainName = StringUtil::trim($_POST['domainName']); - } - if (isset($_POST['domainPath'])) { - $this->domainPath = StringUtil::trim($_POST['domainPath']); - } - if (isset($_POST['landingPageID'])) { - $this->landingPageID = \intval($_POST['landingPageID']); - } - } - - /** - * @inheritDoc - */ - public function readData() - { - parent::readData(); - - if (empty($_POST)) { - $this->cookieDomain = $this->application->cookieDomain; - $this->domainName = $this->application->domainName; - $this->domainPath = $this->application->domainPath; - $this->landingPageID = $this->application->landingPageID; - } - } - - /** - * @inheritDoc - */ - public function validate() - { - parent::validate(); - - if (empty($this->domainName)) { - throw new UserInputException('domainName'); - } else { - $regex = new Regex('^https?\://'); - $this->domainName = FileUtil::removeTrailingSlash($regex->replace($this->domainName, '')); - $this->cookieDomain = FileUtil::removeTrailingSlash($regex->replace($this->cookieDomain, '')); - - // domain may not contain path components - $regex = new Regex('[/#\?&]'); - if ($regex->match($this->domainName)) { - throw new UserInputException('domainName', 'containsPath'); - } elseif ($regex->match($this->cookieDomain)) { - throw new UserInputException('cookieDomain', 'containsPath'); - } - - // strip port from cookie domain - $regex = new Regex(':[0-9]+$'); - $this->cookieDomain = $regex->replace($this->cookieDomain, ''); - - // check if cookie domain shares the same domain (may exclude subdomains) - if (!\str_ends_with($regex->replace($this->domainName, ''), $this->cookieDomain)) { - throw new UserInputException('cookieDomain', 'invalid'); - } - } - - // add slashes - $this->domainPath = FileUtil::addLeadingSlash(FileUtil::addTrailingSlash($this->domainPath)); - - // search for other applications with the same domain and path - $sql = "SELECT packageID - FROM wcf" . WCF_N . "_application - WHERE domainName = ? - AND domainPath = ? - AND packageID <> ?"; - $statement = WCF::getDB()->prepareStatement($sql, 1); - $statement->execute([ - $this->domainName, - $this->domainPath, - $this->application->packageID, - ]); - $row = $statement->fetchArray(); - if ($row) { - WCF::getTPL()->assign('conflictApplication', PackageCache::getInstance()->getPackage($row['packageID'])); - throw new UserInputException('domainPath', 'conflict'); - } - - if ($this->landingPageID) { - $page = new Page($this->landingPageID); - if (!$page->pageID) { - throw new UserInputException('landingPageID'); - } elseif ($page->requireObjectID || $page->excludeFromLandingPage || $page->isDisabled) { - throw new UserInputException('landingPageID', 'invalid'); - } - } - } - - /** - * @inheritDoc - */ - public function save() - { - parent::save(); - - // save application - $this->objectAction = new ApplicationAction([$this->application->getDecoratedObject()], 'update', [ - 'data' => \array_merge($this->additionalFields, [ - 'cookieDomain' => \mb_strtolower($this->cookieDomain), - 'domainName' => \mb_strtolower($this->domainName), - 'domainPath' => $this->domainPath, - 'landingPageID' => ($this->landingPageID ?: null), - ]), - ]); - $this->objectAction->executeAction(); - - $this->saved(); - - if ($this->application->packageID === 1) { - if ($this->landingPageID) { - (new Page($this->landingPageID))->setAsLandingPage(); - } else { - $sql = "UPDATE wcf" . WCF_N . "_page - SET isLandingPage = ? - WHERE isLandingPage = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute([ - 0, - 1, - ]); - } - } - - // re-calculate cookie settings - ApplicationHandler::rebuild(); - - // reset caches to reflect new landing page - ApplicationCacheBuilder::getInstance()->reset(); - RoutingCacheBuilder::getInstance()->reset(); - - // show success message - WCF::getTPL()->assign('success', true); - } - - /** - * @inheritDoc - */ - public function assignVariables() - { - parent::assignVariables(); - - WCF::getTPL()->assign([ - 'application' => $this->application, - 'cookieDomain' => $this->cookieDomain, - 'domainName' => $this->domainName, - 'domainPath' => $this->domainPath, - 'packageID' => $this->packageID, - 'pageNodeList' => $this->pageNodeList, - 'landingPageID' => $this->landingPageID, - ]); - } -} diff --git a/wcfsetup/install/files/lib/acp/form/ApplicationManagementForm.class.php b/wcfsetup/install/files/lib/acp/form/ApplicationManagementForm.class.php index 559997aaaa..85412bad42 100644 --- a/wcfsetup/install/files/lib/acp/form/ApplicationManagementForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/ApplicationManagementForm.class.php @@ -11,7 +11,6 @@ use wcf\system\application\ApplicationHandler; use wcf\system\cache\builder\ApplicationCacheBuilder; use wcf\system\cache\builder\PageCacheBuilder; use wcf\system\cache\builder\RoutingCacheBuilder; -use wcf\system\exception\PermissionDeniedException; use wcf\system\exception\UserInputException; use wcf\system\Regex; use wcf\system\WCF; @@ -98,36 +97,29 @@ final class ApplicationManagementForm extends AbstractForm { parent::validate(); - if (ApplicationHandler::getInstance()->isMultiDomainSetup()) { - // Changes to the domain for all apps are only possible for setups using the same domain. - if (!empty($this->cookieDomain) || !empty($this->domainName)) { - throw new PermissionDeniedException(); - } - } else { - if (empty($this->domainName)) { - throw new UserInputException('domainName'); - } + if (empty($this->domainName)) { + throw new UserInputException('domainName'); + } - $regex = new Regex('^https?\://'); - $this->domainName = FileUtil::removeTrailingSlash($regex->replace($this->domainName, '')); - $this->cookieDomain = FileUtil::removeTrailingSlash($regex->replace($this->cookieDomain, '')); + $regex = new Regex('^https?\://'); + $this->domainName = FileUtil::removeTrailingSlash($regex->replace($this->domainName, '')); + $this->cookieDomain = FileUtil::removeTrailingSlash($regex->replace($this->cookieDomain, '')); - // domain may not contain path components - $regex = new Regex('[/#\?&]'); - if ($regex->match($this->domainName)) { - throw new UserInputException('domainName', 'containsPath'); - } elseif ($regex->match($this->cookieDomain)) { - throw new UserInputException('cookieDomain', 'containsPath'); - } + // domain may not contain path components + $regex = new Regex('[/#\?&]'); + if ($regex->match($this->domainName)) { + throw new UserInputException('domainName', 'containsPath'); + } elseif ($regex->match($this->cookieDomain)) { + throw new UserInputException('cookieDomain', 'containsPath'); + } - // strip port from cookie domain - $regex = new Regex(':[0-9]+$'); - $this->cookieDomain = $regex->replace($this->cookieDomain, ''); + // strip port from cookie domain + $regex = new Regex(':[0-9]+$'); + $this->cookieDomain = $regex->replace($this->cookieDomain, ''); - // check if cookie domain shares the same domain (may exclude subdomains) - if (!\str_ends_with($regex->replace($this->domainName, ''), $this->cookieDomain)) { - throw new UserInputException('cookieDomain', 'invalid'); - } + // check if cookie domain shares the same domain (may exclude subdomains) + if (!\str_ends_with($regex->replace($this->domainName, ''), $this->cookieDomain)) { + throw new UserInputException('cookieDomain', 'invalid'); } foreach ($this->landingPageID as $landingPageID) { @@ -154,27 +146,23 @@ final class ApplicationManagementForm extends AbstractForm $this->applicationList = new ViewableApplicationList(); $this->applicationList->readObjects(); - if (!ApplicationHandler::getInstance()->isMultiDomainSetup()) { - $core = ApplicationHandler::getInstance()->getApplicationByID(1); - $this->domainName = $core->domainName; - $this->cookieDomain = $core->cookieDomain; - } + $core = ApplicationHandler::getInstance()->getApplicationByID(1); + $this->domainName = $core->domainName; + $this->cookieDomain = $core->cookieDomain; } public function save() { parent::save(); - if (!ApplicationHandler::getInstance()->isMultiDomainSetup()) { - $sql = "UPDATE wcf" . WCF_N . "_application - SET domainName = ?, - cookieDomain = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute([ - $this->domainName, - $this->cookieDomain, - ]); - } + $sql = "UPDATE wcf" . WCF_N . "_application + SET domainName = ?, + cookieDomain = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute([ + $this->domainName, + $this->cookieDomain, + ]); $sql = "UPDATE wcf" . WCF_N . "_application SET landingPageID = ? @@ -231,7 +219,6 @@ final class ApplicationManagementForm extends AbstractForm 'applicationList' => $this->applicationList, 'cookieDomain' => $this->cookieDomain, 'domainName' => $this->domainName, - 'isMultiDomainSetup' => ApplicationHandler::getInstance()->isMultiDomainSetup(), 'pageNodeList' => $this->pageNodeList, 'pageList' => $pageList->getObjects(), ]); diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index 1d593a1f04..924f3c92e4 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -1183,14 +1183,6 @@ class WCF { if (!ENABLE_DESKTOP_NOTIFICATIONS) { return false; - } elseif (ApplicationHandler::getInstance()->isMultiDomainSetup()) { - $application = ApplicationHandler::getInstance()->getApplicationByID(1); - - $currentApplication = ApplicationHandler::getInstance()->getActiveApplication(); - if ($currentApplication->domainName != $application->domainName) { - // different domain - return false; - } } return true; diff --git a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php index 5dbcb3f313..77f5a1a1c8 100644 --- a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php @@ -92,10 +92,7 @@ class RequestHandler extends SingletonFactory $this->checkOfflineMode(); - if ( - $this->isACPRequest() - && !ApplicationHandler::getInstance()->isMultiDomainSetup() - ) { + if ($this->isACPRequest()) { \header('referrer-policy: same-origin'); \header('cross-origin-opener-policy: same-origin'); \header('cross-origin-resource-policy: same-site'); diff --git a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php index b71e9fdf80..13142222c9 100644 --- a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php +++ b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php @@ -8,7 +8,6 @@ use wcf\data\session\SessionEditor; use wcf\data\style\StyleAction; use wcf\data\user\User; use wcf\data\user\UserEditor; -use wcf\system\application\ApplicationHandler; use wcf\system\cache\builder\SpiderCacheBuilder; use wcf\system\cache\builder\UserGroupOptionCacheBuilder; use wcf\system\cache\builder\UserGroupPermissionCacheBuilder; @@ -489,25 +488,15 @@ final class SessionHandler extends SingletonFactory // and it is supported by default in common JavaScript frameworks. // 2) We want to set the SameSite=lax parameter. // 3) We don't want the HttpOnly parameter. - $sameSite = $cookieDomain = ''; - if (ApplicationHandler::getInstance()->isMultiDomainSetup()) { - // We need to specify the cookieDomain in a multi domain set-up, because - // otherwise no cookies are sent to subdomains. - $cookieDomain = HeaderUtil::getCookieDomain(); - $cookieDomain = ($cookieDomain !== null ? '; domain=' . $cookieDomain : ''); - } else { - // SameSite=lax is not supported in a multi domain set-up, because - // it breaks cross-application requests. - $sameSite = '; SameSite=lax'; - } + $sameSite = '; SameSite=lax'; if (!HTTP_SEND_X_FRAME_OPTIONS) { $sameSite = '; SameSite=none'; } \header( - 'set-cookie: XSRF-TOKEN=' . \rawurlencode($xsrfToken) . '; path=/' . $cookieDomain . (RouteHandler::secureConnection() ? '; secure' : '') . $sameSite, + 'set-cookie: XSRF-TOKEN=' . \rawurlencode($xsrfToken) . '; path=/' . (RouteHandler::secureConnection() ? '; secure' : '') . $sameSite, false ); } diff --git a/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php b/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php index d465453dfb..5ed839f0d6 100644 --- a/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php +++ b/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php @@ -523,26 +523,18 @@ final class StyleCompiler extends SingletonFactory } EOT; - if (ApplicationHandler::getInstance()->isMultiDomainSetup()) { - $content .= <<<'EOT' - @function getFont($filename, $family: "/", $version: "") { - @return "../font/getFont.php?family=" + $family + "&filename=" + $filename + "&v=" + $version; + $content .= <<<'EOT' + @function getFont($filename, $family: "/", $version: "") { + @if ($family != "") { + $family: "families/" + $family + "/"; } -EOT; - } else { - $content .= <<<'EOT' - @function getFont($filename, $family: "/", $version: "") { - @if ($family != "") { - $family: "families/" + $family + "/"; - } - @if ($version != "") { - $version: "?v=" + $version; - } - - @return "../font/" + $family + $filename + $version; + @if ($version != "") { + $version: "?v=" + $version; } + + @return "../font/" + $family + $filename + $version; + } EOT; - } if (!empty($variables['wcfFontFamilyGoogle'])) { $content .= $this->getGoogleFontScss($variables['wcfFontFamilyGoogle']); diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index b23d22676f..d539a96fde 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -77,14 +77,6 @@ - Die Unterstützung für Installationen mit mehreren Domains wird eingestellt.

-


-

Es wird dringend empfohlen die Apps auf eine gemeinsame Domain zu verschieben, bitte passen Sie dazu die Domain- und Pfadkonfiguration der installierten Apps an:

-]]>
@@ -5565,5 +5557,6 @@ Benachrichtigungen auf {PAGE_TITLE|phra + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 9a7355b3a3..6795efaed8 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -77,14 +77,6 @@ - The support for setups with multiple domains is discontinued.

-


-

It is strongly recommended to consolidate all apps on a shared domain, please adjust the domain and path settings for these apps:

-
]]> @@ -5567,5 +5559,6 @@ your notifications on {PAGE_TITLE|phras +