From 529886e2533586ca8c9938e30067d50a365ccba9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 13 Mar 2019 15:13:51 +0100 Subject: [PATCH] Migrate the attachment's storage location in AttachmentRebuildDataWorker see #2840 --- .../files/lib/data/attachment/Attachment.class.php | 12 ++++++++++++ .../worker/AttachmentRebuildDataWorker.class.php | 1 + 2 files changed, 13 insertions(+) diff --git a/wcfsetup/install/files/lib/data/attachment/Attachment.class.php b/wcfsetup/install/files/lib/data/attachment/Attachment.class.php index 49667aeaf9..f739ea934e 100644 --- a/wcfsetup/install/files/lib/data/attachment/Attachment.class.php +++ b/wcfsetup/install/files/lib/data/attachment/Attachment.class.php @@ -7,6 +7,7 @@ use wcf\system\request\IRouteController; use wcf\system\request\LinkHandler; use wcf\system\WCF; use wcf\util\FileUtil; +use wcf\util\StringUtil; /** * Represents an attachment. @@ -149,6 +150,17 @@ class Attachment extends DatabaseObject implements IRouteController, IThumbnailF return $this->getLocationHelper($location); } + /** + * Migrates the storage location of this attachment. + */ + public function migrateStorage() { + foreach ([$this->getLocation(), $this->getThumbnailLocation(), $this->getThumbnailLocation('tiny')] as $location) { + if (!StringUtil::endsWith($location, '.bin')) { + rename($location, $location.'.bin'); + } + } + } + /** * Returns the appropriate location with or without extension. * diff --git a/wcfsetup/install/files/lib/system/worker/AttachmentRebuildDataWorker.class.php b/wcfsetup/install/files/lib/system/worker/AttachmentRebuildDataWorker.class.php index 3cfc067dd5..4c066f66b8 100644 --- a/wcfsetup/install/files/lib/system/worker/AttachmentRebuildDataWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/AttachmentRebuildDataWorker.class.php @@ -45,6 +45,7 @@ class AttachmentRebuildDataWorker extends AbstractRebuildDataWorker { try { $action = new AttachmentAction([$attachment], 'generateThumbnails'); $action->executeAction(); + $attachment->migrateStorage(); } catch (SystemException $e) {} } -- 2.20.1