From: Alexander Ebert Date: Wed, 27 Sep 2023 12:05:09 +0000 (+0200) Subject: Refresh the license file when searching for updates X-Git-Tag: 6.0.0_RC_2~3^2~9 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=261fcf074e06d6371aef68d0b675bf9713345ef2;p=GitHub%2FWoltLab%2FWCF.git Refresh the license file when searching for updates --- diff --git a/wcfsetup/install/files/lib/data/package/update/PackageUpdateAction.class.php b/wcfsetup/install/files/lib/data/package/update/PackageUpdateAction.class.php index 1371c38bf0..0b2f0c490a 100644 --- a/wcfsetup/install/files/lib/data/package/update/PackageUpdateAction.class.php +++ b/wcfsetup/install/files/lib/data/package/update/PackageUpdateAction.class.php @@ -13,6 +13,7 @@ use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\exception\NamedUserException; use wcf\system\exception\SystemException; use wcf\system\exception\UserInputException; +use wcf\system\package\license\LicenseApi; use wcf\system\package\PackageInstallationScheduler; use wcf\system\package\PackageUpdateDispatcher; use wcf\system\package\PackageUpdateUnauthorizedException; @@ -610,6 +611,12 @@ class PackageUpdateAction extends AbstractDatabaseObjectAction { PackageUpdateDispatcher::getInstance()->refreshPackageDatabase([], $this->parameters['ignoreCache']); + // Try to update the cached license data to check for recent purchases. + if (LicenseApi::hasLicenseCredentials()) { + $licenseApi = LicenseApi::fetchFromRemote(); + $licenseApi->updateLicenseFile(); + } + $updates = PackageUpdateDispatcher::getInstance()->getAvailableUpdates(); $url = ''; if (!empty($updates)) { diff --git a/wcfsetup/install/files/lib/system/cronjob/GetUpdateInfoCronjob.class.php b/wcfsetup/install/files/lib/system/cronjob/GetUpdateInfoCronjob.class.php index 55d938e0c7..9d0bde92ed 100644 --- a/wcfsetup/install/files/lib/system/cronjob/GetUpdateInfoCronjob.class.php +++ b/wcfsetup/install/files/lib/system/cronjob/GetUpdateInfoCronjob.class.php @@ -4,6 +4,7 @@ namespace wcf\system\cronjob; use wcf\data\cronjob\Cronjob; use wcf\system\language\LanguageFactory; +use wcf\system\package\license\LicenseApi; use wcf\system\package\PackageUpdateDispatcher; use wcf\system\WCF; @@ -40,5 +41,21 @@ class GetUpdateInfoCronjob extends AbstractCronjob WCF::setLanguage($currentLanguage); } } + + $this->refreshLicenseFile(); + } + + /** + * Refresh the license file to update any recently made purchases. + */ + private function refreshLicenseFile(): void + { + try { + $licenseApi = LicenseApi::fetchFromRemote(); + $licenseApi->updateLicenseFile(); + } catch (\Throwable) { + // This is a “silent” operation that should not interrupt the + // execution of cronjobs in case of an error. + } } }