@@ -2055,7 +2055,12 @@ public function countBlogs()
20552055 */
20562056 public function exportBlogs ($ offset , $ limit )
20572057 {
2058- $ sourceVersion52 = \version_compare (
2058+ $ sourceVersion62 = \version_compare (
2059+ $ this ->getPackageVersion ('com.woltlab.blog ' ),
2060+ '6.2.0 Alpha 1 ' ,
2061+ '>= '
2062+ );
2063+ $ sourceVersion52 = !$ sourceVersion62 && \version_compare (
20592064 $ this ->getPackageVersion ('com.woltlab.blog ' ),
20602065 '5.2.0 Alpha 1 ' ,
20612066 '>= '
@@ -2069,6 +2074,7 @@ public function exportBlogs($offset, $limit)
20692074 $ packageDir = $ statement ->fetchColumn ();
20702075 $ blogFilePath = FileUtil::getRealPath ($ this ->fileSystemPath . '/ ' . $ packageDir );
20712076
2077+ $ coverPhotoFiles = [];
20722078 if ($ sourceVersion52 ) {
20732079 $ sql = "SELECT blog.*, language.languageCode, coverPhoto.fileExtension, coverPhoto.fileHash
20742080 FROM blog " . $ this ->dbNo . "_blog blog
@@ -2079,13 +2085,24 @@ public function exportBlogs($offset, $limit)
20792085 WHERE blog.blogID BETWEEN ? AND ?
20802086 ORDER BY blog.blogID " ;
20812087 } else {
2088+ if ($ sourceVersion62 ) {
2089+ $ sql = "SELECT coverPhotoFileID
2090+ FROM blog " . $ this ->dbNo . "_blog
2091+ WHERE blogID BETWEEN ? AND ?
2092+ ORDER BY blogID " ;
2093+ $ statement = $ this ->database ->prepareUnmanaged ($ sql );
2094+ $ statement ->execute ([$ offset + 1 , $ offset + $ limit ]);
2095+ $ coverPhotoFiles = $ this ->getFileLocations ($ statement ->fetchAll (\PDO ::FETCH_COLUMN ));
2096+ }
2097+
20822098 $ sql = "SELECT blog.*, language.languageCode
20832099 FROM blog " . $ this ->dbNo . "_blog blog
20842100 LEFT JOIN wcf " . $ this ->dbNo . "_language language
20852101 ON language.languageID = blog.languageID
20862102 WHERE blog.blogID BETWEEN ? AND ?
20872103 ORDER BY blog.blogID " ;
20882104 }
2105+
20892106 $ statement = $ this ->database ->prepareUnmanaged ($ sql );
20902107 $ statement ->execute ([$ offset + 1 , $ offset + $ limit ]);
20912108 while ($ row = $ statement ->fetchArray ()) {
@@ -2102,7 +2119,14 @@ public function exportBlogs($offset, $limit)
21022119 if ($ row ['languageCode ' ]) {
21032120 $ additionalData ['languageCode ' ] = $ row ['languageCode ' ];
21042121 }
2105- if ($ sourceVersion52 && $ row ['coverPhotoID ' ]) {
2122+
2123+ if ($ sourceVersion62 ) {
2124+ if (!empty ($ row ['coverPhotoFileID ' ]) && isset ($ coverPhotoFiles [$ row ['coverPhotoFileID ' ]])) {
2125+ ['location ' => $ location , 'filename ' => $ filename ] = $ coverPhotoFiles [$ row ['coverPhotoFileID ' ]];
2126+ $ additionalData ['coverPhotoLocation ' ] = $ location ;
2127+ $ additionalData ['coverPhotoFilename ' ] = $ filename ;
2128+ }
2129+ } elseif ($ sourceVersion52 && $ row ['coverPhotoID ' ]) {
21062130 $ additionalData ['coverPhoto ' ] = $ this ->getCoverPhotoPath ($ blogFilePath , $ row );
21072131 }
21082132
@@ -2166,7 +2190,12 @@ public function exportBlogEntries($offset, $limit)
21662190 '2.1.0 Alpha 1 ' ,
21672191 '>= '
21682192 );
2169- $ sourceVersion52 = \version_compare (
2193+ $ sourceVersion62 = \version_compare (
2194+ $ this ->getPackageVersion ('com.woltlab.blog ' ),
2195+ '6.2.0 Alpha 1 ' ,
2196+ '>= '
2197+ );
2198+ $ sourceVersion52 = !$ sourceVersion62 && \version_compare (
21702199 $ this ->getPackageVersion ('com.woltlab.blog ' ),
21712200 '5.2.0 Alpha 1 ' ,
21722201 '>= '
@@ -2220,6 +2249,7 @@ public function exportBlogEntries($offset, $limit)
22202249 $ conditionBuilder = new PreparedStatementConditionBuilder ();
22212250 $ conditionBuilder ->add ('entry.entryID IN (?) ' , [$ entryIDs ]);
22222251
2252+ $ coverPhotoFiles = [];
22232253 if ($ sourceVersion52 ) {
22242254 $ sql = "SELECT entry.*, language.languageCode, coverPhoto.fileExtension, coverPhoto.fileHash
22252255 FROM blog " . $ this ->dbNo . "_entry entry
@@ -2229,6 +2259,15 @@ public function exportBlogEntries($offset, $limit)
22292259 ON entry.coverPhotoID = entry.coverPhotoID
22302260 " . $ conditionBuilder ;
22312261 } else {
2262+ if ($ sourceVersion62 ) {
2263+ $ sql = "SELECT entry.coverPhotoFileID
2264+ FROM blog " . $ this ->dbNo . "_entry entry
2265+ " . $ conditionBuilder ;
2266+ $ statement = $ this ->database ->prepareUnmanaged ($ sql );
2267+ $ statement ->execute ($ conditionBuilder ->getParameters ());
2268+ $ coverPhotoFiles = $ this ->getFileLocations ($ statement ->fetchAll (\PDO ::FETCH_COLUMN ));
2269+ }
2270+
22322271 $ sql = "SELECT entry.*, language.languageCode
22332272 FROM blog " . $ this ->dbNo . "_entry entry
22342273 LEFT JOIN wcf " . $ this ->dbNo . "_language language
@@ -2248,7 +2287,13 @@ public function exportBlogEntries($offset, $limit)
22482287 if (isset ($ categories [$ row ['entryID ' ]])) {
22492288 $ additionalData ['categories ' ] = $ categories [$ row ['entryID ' ]];
22502289 }
2251- if ($ sourceVersion52 && $ row ['coverPhotoID ' ]) {
2290+ if ($ sourceVersion62 ) {
2291+ if (!empty ($ row ['coverPhotoFileID ' ]) && isset ($ coverPhotoFiles [$ row ['coverPhotoFileID ' ]])) {
2292+ ['location ' => $ location , 'filename ' => $ filename ] = $ coverPhotoFiles [$ row ['coverPhotoFileID ' ]];
2293+ $ additionalData ['coverPhotoLocation ' ] = $ location ;
2294+ $ additionalData ['coverPhotoFilename ' ] = $ filename ;
2295+ }
2296+ } elseif ($ sourceVersion52 && $ row ['coverPhotoID ' ]) {
22522297 $ additionalData ['coverPhoto ' ] = $ this ->getCoverPhotoPath ($ blogFilePath , $ row );
22532298 }
22542299
@@ -4674,7 +4719,7 @@ private function getFilebaseDir()
46744719 *
46754720 * @param int[] $fileIDs
46764721 *
4677- * @return array{ int, array{location: string, filename: string}}
4722+ * @return array< int, array{location: string, filename: string}>
46784723 */
46794724 private function getFileLocations (array $ fileIDs ): array
46804725 {
0 commit comments