$additionalData['languageCode'] = $row['languageCode'];
}
if ($sourceVersion52 && $destVersion52 && $row['coverPhotoID']) {
- $directory = \substr($row["fileHash"], 0, 2);
- $additionalData['coverPhoto'] = "{$blogFilePath}images/coverPhotos/{$directory}/{$row["coverPhotoID"]}-{$row["fileHash"]}.{$row["fileExtension"]}";
+ $additionalData['coverPhoto'] = $this->getCoverPhotoPath($blogFilePath, $row);
}
ImportHandler::getInstance()
'2.1.0 Alpha 1',
'>='
);
+ $sourceVersion52 = \version_compare(
+ $this->getPackageVersion('com.woltlab.blog'),
+ '5.2.0 Alpha 1',
+ '>='
+ );
+ $destVersion52 = \version_compare(
+ BLOGCore::getInstance()->getPackage()->packageVersion,
+ '5.2.0 Alpha 1',
+ '>='
+ );
+
+ $sql = "SELECT packageDir
+ FROM wcf" . $this->dbNo . "_package
+ WHERE package = ?";
+ $statement = $this->database->prepareStatement($sql, 1);
+ $statement->execute(['com.woltlab.blog']);
+ $packageDir = $statement->fetchColumn();
+ $blogFilePath = FileUtil::getRealPath($this->fileSystemPath . '/' . $packageDir);
// get entry ids
$entryIDs = [];
$conditionBuilder = new PreparedStatementConditionBuilder();
$conditionBuilder->add('entry.entryID IN (?)', [$entryIDs]);
- $sql = "SELECT entry.*, language.languageCode
+ if ($sourceVersion52 && $destVersion52) {
+ $sql = "SELECT entry.*, language.languageCode, coverPhoto.fileExtension, coverPhoto.fileHash
+ FROM blog" . $this->dbNo . "_entry entry
+ LEFT JOIN wcf" . $this->dbNo . "_language language
+ ON language.languageID = entry.languageID
+ LEFT JOIN blog" . $this->dbNo . "_cover_photo coverPhoto
+ ON entry.coverPhotoID = entry.coverPhotoID
+ " . $conditionBuilder;
+ } else {
+ $sql = "SELECT entry.*, language.languageCode
FROM blog" . $this->dbNo . "_entry entry
LEFT JOIN wcf" . $this->dbNo . "_language language
ON language.languageID = entry.languageID
" . $conditionBuilder;
+ }
$statement = $this->database->prepareStatement($sql);
$statement->execute($conditionBuilder->getParameters());
while ($row = $statement->fetchArray()) {
if (isset($categories[$row['entryID']])) {
$additionalData['categories'] = $categories[$row['entryID']];
}
+ if ($sourceVersion52 && $destVersion52 && $row['coverPhotoID']) {
+ $additionalData['coverPhoto'] = $this->getCoverPhotoPath($blogFilePath, $row);
+ }
$data = [
'userID' => $row['userID'],
}
}
+ private function getCoverPhotoPath(string $blogFilePath, array $row): string
+ {
+ $coverPhotoID = $row["coverPhotoID"];
+ $fileHash = $row["fileHash"];
+ $fileExtension = $row["fileExtension"];
+ $directory = \substr($fileHash, 0, 2);
+
+ return "{$blogFilePath}images/coverPhotos/$directory/$coverPhotoID-$fileHash.$fileExtension";
+ }
+
/**
* Counts blog attachments.
*/