$file = $this->parameters['uploads']['favicon'];
if ($file !== null) {
- $fileLocation = $file->getLocation();
- if (($imageData = \getimagesize($fileLocation)) === false) {
- throw new \InvalidArgumentException('The given favicon is not an image');
- }
- $extension = ImageUtil::getExtensionByMimeType($imageData['mime']);
- $newName = "favicon-template." . $extension;
- $newLocation = $style->getAssetPath() . $newName;
- \rename($fileLocation, $newLocation);
+ if (!$file->isProcessed()) {
+ $fileLocation = $file->getLocation();
+ if (($imageData = \getimagesize($fileLocation)) === false) {
+ throw new \InvalidArgumentException('The given favicon is not an image');
+ }
+ $extension = ImageUtil::getExtensionByMimeType($imageData['mime']);
+ $newName = "favicon-template." . $extension;
+ $newLocation = $style->getAssetPath() . $newName;
+ \rename($fileLocation, $newLocation);
- // Create browser specific files.
- $adapter = ImageHandler::getInstance()->getAdapter();
- $adapter->loadFile($newLocation);
- foreach ($images as $filename => $length) {
- $thumbnail = $adapter->createThumbnail($length, $length);
- $adapter->writeImage($thumbnail, $style->getAssetPath() . $filename);
- // Clear thumbnail as soon as possible to free up the memory.
- $thumbnail = null;
- }
+ $file->setProcessed($newLocation);
- // Create ICO file.
- require(WCF_DIR . 'lib/system/api/chrisjean/php-ico/class-php-ico.php');
- (new \PHP_ICO($newLocation, [
- [16, 16],
- [32, 32],
- ]))->save_ico($style->getAssetPath() . "favicon.ico");
+ // Create browser specific files.
+ $adapter = ImageHandler::getInstance()->getAdapter();
+ $adapter->loadFile($file->getLocation());
+ foreach ($images as $filename => $length) {
+ $thumbnail = $adapter->createThumbnail($length, $length);
+ $adapter->writeImage($thumbnail, $style->getAssetPath() . $filename);
+ // Clear thumbnail as soon as possible to free up the memory.
+ $thumbnail = null;
+ }
- (new StyleEditor($style))->update([
- 'hasFavicon' => 1,
- ]);
+ // Create ICO file.
+ require(WCF_DIR . 'lib/system/api/chrisjean/php-ico/class-php-ico.php');
+ (new \PHP_ICO($file->getLocation(), [
+ [16, 16],
+ [32, 32],
+ ]))->save_ico($style->getAssetPath() . "favicon.ico");
- $file->setProcessed($newLocation);
- $hasFavicon = true;
+ (new StyleEditor($style))->update([
+ 'hasFavicon' => 1,
+ ]);
+
+ $hasFavicon = true;
+ }
} else {
foreach ($images as $filename => $length) {
\unlink($style->getAssetPath() . $filename);