Test the existence of the blog (vB 3/4)
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 11 Dec 2020 10:52:33 +0000 (11:52 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 11 Dec 2020 10:52:59 +0000 (11:52 +0100)
Fixes #51

files/lib/system/exporter/VB3or4xExporter.class.php

index 2798892379eeacce91bc5f83c58ba45be7449eaa..c9268b910b482d48761fc9cf255f334e82db3f0d 100644 (file)
@@ -292,9 +292,23 @@ class VB3or4xExporter extends AbstractExporter {
                
                // blog
                if (in_array('com.woltlab.blog.entry', $this->selectedData)) {
-                       $queue[] = 'com.woltlab.blog.entry';
-                       if (in_array('com.woltlab.blog.entry.attachment', $this->selectedData)) $queue[] = 'com.woltlab.blog.entry.attachment';
-                       if (in_array('com.woltlab.blog.entry.comment', $this->selectedData)) $queue[] = 'com.woltlab.blog.entry.comment';
+                       try {
+                               // Check whether the blog appears to be available.
+                               $sql = "SELECT  COUNT(*)
+                                       FROM    ".$this->databasePrefix."blog";
+                               $statement = $this->database->prepareStatement($sql);
+                               $statement->execute();
+                               $dummy = $statement->fetchSingleColumn();
+                               
+                               // If we reach this place then the above query succeeded, thus
+                               // the blog appears to be available and we add it to the queue.
+                               $queue[] = 'com.woltlab.blog.entry';
+                               if (in_array('com.woltlab.blog.entry.attachment', $this->selectedData)) $queue[] = 'com.woltlab.blog.entry.attachment';
+                               if (in_array('com.woltlab.blog.entry.comment', $this->selectedData)) $queue[] = 'com.woltlab.blog.entry.comment';
+                       }
+                       catch (DatabaseException $e) {
+                               // The blog does not appear to be available.
+                       }
                }
                
                return $queue;