Fix exporting of attachments in vB 4 if they are stored in database
authorTim Düsterhus <timwolla@bastelstu.be>
Sun, 8 Dec 2013 19:33:24 +0000 (20:33 +0100)
committerTim Düsterhus <timwolla@bastelstu.be>
Sun, 8 Dec 2013 19:34:29 +0000 (20:34 +0100)
files/lib/system/exporter/VB3or4xExporter.class.php

index 949d4b47bceb9a6b7468ac2654f2b1480bbb38a2..d54ae0b5591d215bead7c3a04299eb738c1fe532 100644 (file)
@@ -917,14 +917,18 @@ class VB3or4xExporter extends AbstractExporter {
         */
        public function exportPostAttachments($offset, $limit) {
                try {
-                       $sql = "SELECT          *, contentid AS postid
-                               FROM            ".$this->databasePrefix."attachment
-                               WHERE           contenttypeid = (SELECT contenttypeid FROM ".$this->databasePrefix."contenttype WHERE class = 'Post')
-                               ORDER BY        attachmentid ASC";
+                       // vb 4
+                       $sql = "SELECT          attachment.*, attachment.contentid AS postid, filedata.filedata
+                               FROM            ".$this->databasePrefix."attachment attachment
+                               LEFT JOIN       ".$this->databasePrefix."filedata filedata
+                               ON              attachment.filedataid = filedata.filedataid
+                               WHERE           attachment.contenttypeid = (SELECT contenttypeid FROM ".$this->databasePrefix."contenttype contenttype WHERE contenttype.class = 'Post')
+                               ORDER BY        attachment.attachmentid ASC";
                        $statement = $this->database->prepareStatement($sql, $limit, $offset);
                        $statement->execute();
                }
                catch (DatabaseException $e) {
+                       // vb 3
                        $sql = "SELECT          *
                                FROM            ".$this->databasePrefix."attachment
                                ORDER BY        attachmentid ASC";