Migrate the attachment's storage location in AttachmentRebuildDataWorker
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 13 Mar 2019 14:13:51 +0000 (15:13 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 13 Mar 2019 14:14:34 +0000 (15:14 +0100)
see #2840

wcfsetup/install/files/lib/data/attachment/Attachment.class.php
wcfsetup/install/files/lib/system/worker/AttachmentRebuildDataWorker.class.php

index 49667aeaf97d33402b585d56c4f926d7ac82bb09..f739ea934ee3daf19933896acc6e37697f7046ab 100644 (file)
@@ -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.
         * 
index 3cfc067dd599722f17e00e17214cec67fb79da92..4c066f66b8b19e5da10060b66b3859cc49219223 100644 (file)
@@ -45,6 +45,7 @@ class AttachmentRebuildDataWorker extends AbstractRebuildDataWorker {
                        try {
                                $action = new AttachmentAction([$attachment], 'generateThumbnails');
                                $action->executeAction();
+                               $attachment->migrateStorage();
                        }
                        catch (SystemException $e) {}
                }