Skip to content

Commit

Permalink
Enable the upgrade from 6.0 → 6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dtdesign committed Oct 14, 2024
1 parent af1490a commit 531a374
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
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;
use wcf\system\form\builder\field\MultilineTextFormField;
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;

/**
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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'],
];

Expand Down Expand Up @@ -168,9 +160,11 @@ private function checkRequiredPhpExtensions(): ?array
'dom',
'exif',
'gd',
'gmp',
'intl',
'libxml',
'mbstring',
'openssl',
'pdo_mysql',
'pdo',
'zlib',
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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.',
];
}
}
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion wcfsetup/install/files/lib/system/WCF.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 531a374

Please sign in to comment.