From: Tim Düsterhus Date: Wed, 13 Mar 2019 14:13:51 +0000 (+0100) Subject: Migrate the attachment's storage location in AttachmentRebuildDataWorker X-Git-Tag: 5.2.0_Alpha_1~219^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=529886e2533586ca8c9938e30067d50a365ccba9;p=GitHub%2FWoltLab%2FWCF.git Migrate the attachment's storage location in AttachmentRebuildDataWorker see #2840 --- 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) {} }