Drop unparseable serialized data in VB 3 / 4
authorTim Düsterhus <timwolla@googlemail.com>
Sun, 1 Dec 2013 19:21:04 +0000 (20:21 +0100)
committerTim Düsterhus <timwolla@googlemail.com>
Sun, 1 Dec 2013 19:21:04 +0000 (20:21 +0100)
files/lib/system/exporter/VB3or4xExporter.class.php

index b3e9b1d7d69451f24db2a9db733a10454185cf8f..08baf8d17bba4414c6d59bfb9c4b8086c6ca2a08 100644 (file)
@@ -555,7 +555,11 @@ class VB3or4xExporter extends AbstractExporter {
                $statement = $this->database->prepareStatement($sql, $limit, $offset);
                $statement->execute(array(''));
                while ($row = $statement->fetchArray()) {
-                       $pmfolders = unserialize($row['pmfolders']);
+                       // vBulletin relies on undefined behaviour by default, we cannot know in which
+                       // encoding the data was saved -> drop it
+                       $pmfolders = @unserialize($row['pmfolders']);
+                       if (!is_array($pmfolders)) continue;
+                       
                        foreach ($pmfolders as $key => $val) {
                                ImportHandler::getInstance()->getImporter('com.woltlab.wcf.conversation.label')->import($row['userid'].'-'.$key, array(
                                        'userID' => $row['userid'],
@@ -668,7 +672,11 @@ class VB3or4xExporter extends AbstractExporter {
                $statement = $this->database->prepareStatement($sql, $limit, $offset);
                $statement->execute();
                while ($row = $statement->fetchArray()) {
-                       $recipients = unserialize($row['touserarray']);
+                       // vBulletin relies on undefined behaviour by default, we cannot know in which
+                       // encoding the data was saved
+                       // this may cause some hidden participants to become visible
+                       $recipients = @unserialize($row['touserarray']);
+                       if (!is_array($recipients)) $recipients = array();
                        
                        ImportHandler::getInstance()->getImporter('com.woltlab.wcf.conversation.user')->import(0, array(
                                'conversationID' => ($row['parentpmid'] ?: $row['pmid']),