From: Tim Düsterhus Date: Fri, 26 Feb 2021 13:32:30 +0000 (+0100) Subject: Update Google Fonts when upgrading to 5.4 X-Git-Tag: 5.4.0_Alpha_1~218 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4210e13f1f4bb27a41345f0a6950e8ccc292c988;p=GitHub%2FWoltLab%2FWCF.git Update Google Fonts when upgrading to 5.4 Resolves #4034 --- diff --git a/com.woltlab.wcf/package.xml b/com.woltlab.wcf/package.xml index 932197b82d..242d2117da 100644 --- a/com.woltlab.wcf/package.xml +++ b/com.woltlab.wcf/package.xml @@ -117,5 +117,8 @@ tar cvf com.woltlab.wcf/files_pre.tar -C wcfsetup/install/files/ \ acp/update_com.woltlab.wcf_5.4_migrate_rank_images.php + + + acp/update_com.woltlab.wcf_5.4_update_google_font.php diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_update_google_font.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_update_google_font.php new file mode 100644 index 0000000000..e2f7646d42 --- /dev/null +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_update_google_font.php @@ -0,0 +1,24 @@ + + * @package WoltLabSuite\Core + */ + +use wcf\system\background\BackgroundQueueHandler; +use wcf\system\background\job\DownloadGoogleFontBackgroundJob; + +$families = \glob(WCF_DIR . 'font/families/*/font.css'); + +foreach ($families as $css) { + $family = \basename(\dirname($css)); + + BackgroundQueueHandler::getInstance()->enqueueIn( + new DownloadGoogleFontBackgroundJob($family), + 10 * 60 + ); +} diff --git a/wcfsetup/install/files/lib/system/background/job/DownloadGoogleFontBackgroundJob.class.php b/wcfsetup/install/files/lib/system/background/job/DownloadGoogleFontBackgroundJob.class.php new file mode 100644 index 0000000000..5718275257 --- /dev/null +++ b/wcfsetup/install/files/lib/system/background/job/DownloadGoogleFontBackgroundJob.class.php @@ -0,0 +1,48 @@ + + * @package WoltLabSuite\Core\System\Background\Job + * @since 5.4 + */ +final class DownloadGoogleFontBackgroundJob extends AbstractBackgroundJob +{ + /** + * @inheritDoc + */ + const MAX_FAILURES = 5; + + /** + * @var string + */ + protected $family; + + public function __construct(string $family) + { + $this->family = $family; + } + + /** + * @return int every 10 minutes + */ + public function retryAfter() + { + return 10 * 60; + } + + /** + * @inheritDoc + */ + public function perform() + { + FontManager::getInstance()->downloadFamily($this->family); + } +}