From 531a3748c914b3a3bed7eff5452c288c7384c7ad Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 14 Oct 2024 14:26:27 +0200 Subject: [PATCH] =?UTF-8?q?Enable=20the=20upgrade=20from=206.0=20=E2=86=92?= =?UTF-8?q?=206.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...PackageEnableUpgradeOverrideForm.class.php | 143 ++++-------------- .../lib/acp/page/PackageListPage.class.php | 8 +- .../server/PackageUpdateServer.class.php | 10 +- .../install/files/lib/system/WCF.class.php | 2 +- 4 files changed, 42 insertions(+), 121 deletions(-) diff --git a/wcfsetup/install/files/lib/acp/form/PackageEnableUpgradeOverrideForm.class.php b/wcfsetup/install/files/lib/acp/form/PackageEnableUpgradeOverrideForm.class.php index 1779a964eb6..484834982dd 100644 --- a/wcfsetup/install/files/lib/acp/form/PackageEnableUpgradeOverrideForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PackageEnableUpgradeOverrideForm.class.php @@ -5,7 +5,6 @@ use wcf\data\package\update\server\PackageUpdateServer; use wcf\form\AbstractForm; use wcf\form\AbstractFormBuilderForm; -use wcf\system\application\ApplicationHandler; use wcf\system\event\EventHandler; use wcf\system\exception\IllegalLinkException; use wcf\system\form\builder\field\BooleanFormField; @@ -13,6 +12,7 @@ use wcf\system\form\builder\field\RejectEverythingFormField; use wcf\system\form\builder\TemplateFormNode; use wcf\system\registry\RegistryHandler; +use wcf\system\request\RouteHandler; use wcf\system\WCF; /** @@ -66,14 +66,10 @@ protected function createForm() $issues = $this->getIssuesPreventingUpgrade(); - if (empty($issues) || $this->isEnabled()) { + if ($issues === [] || $this->isEnabled()) { $this->form->appendChildren([ TemplateFormNode::create('issues') ->templateName('packageEnableUpgradeOverrideSuccess'), - MultilineTextFormField::create('ckeditor5-license') - ->immutable() - ->label('CKEditor 5 FREE FOR OPEN SOURCE LICENSE AGREEMENT') - ->value('THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL CKSOURCE OR ITS LICENSORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.'), BooleanFormField::create('enable') ->label('wcf.acp.package.enableUpgradeOverride.enable') ->value(PackageUpdateServer::isUpgradeOverrideEnabled()), @@ -109,12 +105,8 @@ private function getIssuesPreventingUpgrade() $this->checkMinimumPhpVersion(), $this->checkMaximumPhpVersion(), $this->checkRequiredPhpExtensions(), - $this->checkPhpX64(), $this->checkMinimumDatabaseVersion(), - $this->checkMysqlNativeDriver(), - $this->checkForAppsWithDifferentDomains(), - $this->checkCacheSourceIsNotMemcached(), - $this->checkAttachmentStorage(), + $this->checkForTls(), ...$parameters['issues'], ]; @@ -168,9 +160,11 @@ private function checkRequiredPhpExtensions(): ?array 'dom', 'exif', 'gd', + 'gmp', 'intl', 'libxml', 'mbstring', + 'openssl', 'pdo_mysql', 'pdo', 'zlib', @@ -200,25 +194,6 @@ private function checkRequiredPhpExtensions(): ?array } } - private function checkPhpX64(): ?array - { - if (\PHP_INT_SIZE === 8) { - return null; - } - - if (WCF::getLanguage()->getFixedLanguageCode() === 'de') { - return [ - 'title' => 'Fehlende Unterstützung für 64-Bit Werte', - 'description' => 'Die eingesetzte PHP-Version wurde ohne die Unterstützung von 64-Bit Werten erstellt.', - ]; - } else { - return [ - 'title' => 'Missing support for 64-bit values', - 'description' => 'The PHP version being used was created without support for 64-bit values.', - ]; - } - } - private function checkMinimumDatabaseVersion(): ?array { $sqlVersion = WCF::getDB()->getVersion(); @@ -256,103 +231,27 @@ private function checkMinimumDatabaseVersion(): ?array } } - private function checkMysqlNativeDriver(): ?array - { - $sql = "SELECT 1"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(); - - if ($statement->fetchSingleColumn() === 1) { - return null; - } - - if (WCF::getLanguage()->getFixedLanguageCode() === 'de') { - return [ - 'title' => 'Inkompatibler Treiber für den Datenbank-Zugriff', - 'description' => 'Für den Zugriff auf die Datenbank wird der moderne „MySQL Native Driver“ benötigt.', - ]; - } else { - return [ - 'title' => 'Incompatible driver for the database access', - 'description' => 'The access to the database requires the modern “MySQL Native Driver”.', - ]; - } - } - - private function checkForAppsWithDifferentDomains(): ?array - { - $usesDifferentDomains = false; - $domainName = ''; - foreach (ApplicationHandler::getInstance()->getApplications() as $application) { - if ($domainName === '') { - $domainName = $application->domainName; - continue; - } - - if ($domainName !== $application->domainName) { - $usesDifferentDomains = true; - break; - } - } - - if (!$usesDifferentDomains) { - return null; - } - - if (WCF::getLanguage()->getFixedLanguageCode() === 'de') { - return [ - 'title' => 'Nutzung mehrerer Domains', - 'description' => 'Der Betrieb von Apps auf unterschiedlichen (Sub-)Domains wird nicht mehr unterstützt.', - ]; - } else { - return [ - 'title' => 'Using multiple domains', - 'description' => 'The support for apps running on different (sub)domains has been discontinued.', - ]; - } - } - - private function checkCacheSourceIsNotMemcached(): ?array + private function checkForTls(): ?array { - if (\CACHE_SOURCE_TYPE !== 'memcached') { + if (RouteHandler::secureConnection()) { return null; } - if (WCF::getLanguage()->getFixedLanguageCode() === 'de') { - return [ - 'title' => 'Eingestellte Unterstützung für Memcached', - 'description' => 'Memcached wird nicht mehr unterstützt, als Alternative bietet sich die Nutzung von „Redis“ an.', - ]; - } else { - return [ - 'title' => 'Discountinued support for Memcached', - 'description' => 'Memcached is no longer supported, it is recommended to switch to an alternative like “Redis”.', - ]; - } - } - - private function checkAttachmentStorage(): ?array - { - - if (!\defined('ATTACHMENT_STORAGE') || !ATTACHMENT_STORAGE) { + // @see RouteHandler::secureContext() + $host = $_SERVER['HTTP_HOST']; + if ($host === '127.0.0.1' || $host === 'localhost' || \str_ends_with($host, '.localhost')) { return null; } if (WCF::getLanguage()->getFixedLanguageCode() === 'de') { return [ - 'title' => 'Alternativer Speicherort für Dateianhänge', - 'description' => \sprintf( - "Die Unterstützung für einen alternativen Speicherort von Dateianhängen wird mit dem Upgrade entfernt. Es ist notwendig die Dateianhänge in das Standardverzeichnis '%s' zu verschieben und anschließend die PHP-Konstante 'ATTACHMENT_STORAGE' zu entfernen.", - WCF_DIR . 'attachments/', - ), + 'title' => 'Aufruf über HTTPS', + 'description' => 'Die Seite wird nicht über HTTPS aufgerufen. Wichtige Funktionen stehen dadurch nicht zur Verfügung, die für die korrekte Funktionsweise der Software erforderlich sind.', ]; } else { return [ - 'title' => 'Alternative storage location for attachments', - 'description' => \sprintf( - "The support for an alternative attachment storage location will be removed during the upgrade. It is required to move the attachments into the default directory '%s' and then to remove the PHP constant 'ATTACHMENT_STORAGE'.", - WCF_DIR . 'attachments/', - ), + 'title' => 'Access using HTTPS', + 'description' => 'The page is not accessed via HTTPS. Important features that are required for the proper operation of the software are therefore not available.', ]; } } @@ -364,15 +263,25 @@ public function save() { AbstractForm::save(); + $overrideKey = \sprintf( + "%s\0upgradeOverride_%s", + PackageUpdateServer::class, + WCF::AVAILABLE_UPGRADE_VERSION, + ); + $formData = $this->form->getData(); if ($formData['data']['enable']) { $this->isEnabled = true; - RegistryHandler::getInstance()->set('com.woltlab.wcf', PackageUpdateServer::class . "\0upgradeOverride", \TIME_NOW); + RegistryHandler::getInstance()->set('com.woltlab.wcf', $overrideKey, \TIME_NOW); } else { $this->isEnabled = false; - RegistryHandler::getInstance()->delete('com.woltlab.wcf', PackageUpdateServer::class . "\0upgradeOverride"); + RegistryHandler::getInstance()->delete('com.woltlab.wcf', $overrideKey); } + // Clear the legacy override. + RegistryHandler::getInstance()->delete('com.woltlab.wcf', self::class . "\0upgradeOverride"); + RegistryHandler::getInstance()->delete('com.woltlab.wcf', self::class . "\0upgradeOverride_6.0"); + PackageUpdateServer::resetAll(); $this->form->cleanup(); diff --git a/wcfsetup/install/files/lib/acp/page/PackageListPage.class.php b/wcfsetup/install/files/lib/acp/page/PackageListPage.class.php index 68b0b5401e0..5a3386243a5 100644 --- a/wcfsetup/install/files/lib/acp/page/PackageListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/PackageListPage.class.php @@ -87,10 +87,16 @@ public function assignVariables() $taintedApplications[$application->getPackage()->packageID] = $application; } + $availableUpgradeVersion = WCF::AVAILABLE_UPGRADE_VERSION; + // During the RC phase the upgrade should only be offered when the maintenance mode is enabled. + if (!\OFFLINE) { + $availableUpgradeVersion = null; + } + WCF::getTPL()->assign([ 'recentlyDisabledCustomValues' => LanguageFactory::getInstance()->countRecentlyDisabledCustomValues(), 'taintedApplications' => $taintedApplications, - 'availableUpgradeVersion' => WCF::AVAILABLE_UPGRADE_VERSION, + 'availableUpgradeVersion' => $availableUpgradeVersion, 'upgradeOverrideEnabled' => PackageUpdateServer::isUpgradeOverrideEnabled(), ]); } diff --git a/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php b/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php index dea4c3e22ac..07698a99824 100644 --- a/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php +++ b/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php @@ -376,14 +376,20 @@ final public static function isUpgradeOverrideEnabled(): bool return false; } - $override = RegistryHandler::getInstance()->get('com.woltlab.wcf', self::class . "\0upgradeOverride"); + $overrideKey = \sprintf( + "%s\0upgradeOverride_%s", + self::class, + WCF::AVAILABLE_UPGRADE_VERSION, + ); + + $override = RegistryHandler::getInstance()->get('com.woltlab.wcf', $overrideKey); if (!$override) { return false; } if ($override < TIME_NOW - 86400) { - RegistryHandler::getInstance()->delete('com.woltlab.wcf', self::class . "\0upgradeOverride"); + RegistryHandler::getInstance()->delete('com.woltlab.wcf', $overrideKey); // Clear package list cache to actually stop the upgrade from happening. self::resetAll(); diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index 13c7e2d7aa2..34305ac59d6 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -107,7 +107,7 @@ class WCF * @var ?string * @since 5.3 */ - public const AVAILABLE_UPGRADE_VERSION = null; + public const AVAILABLE_UPGRADE_VERSION = '6.1'; /** * list of currently loaded applications