Fix empty custom page urls when importing a new language
authorMarcel Werk <burntime@woltlab.com>
Wed, 22 May 2024 15:58:49 +0000 (17:58 +0200)
committerMarcel Werk <burntime@woltlab.com>
Wed, 22 May 2024 15:58:49 +0000 (17:58 +0200)
wcfsetup/install/files/lib/data/language/LanguageEditor.class.php

index b58a1df575d6458e352e7a9278a97465c7e90f06..e1480431c48217801c90f315560ae2e638d4cb4e 100644 (file)
@@ -562,10 +562,13 @@ class LanguageEditor extends DatabaseObjectEditor implements IEditableCachedObje
                 $pageIDs[$row['identifier']] = $row['pageID'];
             }
 
-            $sql = "INSERT IGNORE INTO  wcf" . WCF_N . "_page_content
-                                        (pageID, languageID)
-                    VALUES              (?, ?)";
-            $createLanguageVersionStatement = WCF::getDB()->prepareStatement($sql);
+            $sql = "INSERT IGNORE INTO  wcf1_page_content
+                                        (pageID, languageID, title, content, metaDescription, customURL, hasEmbeddedObjects)
+                    SELECT              pageID, ?, title, content, metaDescription, CASE WHEN customURL <> '' THEN CONCAT(customURL, '_', ?) ELSE '' END, hasEmbeddedObjects
+                    FROM                wcf1_page_content
+                    WHERE               pageID = ?
+                                    AND languageID = ?";
+            $createLanguageVersionStatement = WCF::getDB()->prepare($sql);
             $sql = "UPDATE  wcf" . WCF_N . "_page_content
                     SET     title = ?
                     WHERE   pageID = ?
@@ -582,7 +585,12 @@ class LanguageEditor extends DatabaseObjectEditor implements IEditableCachedObje
                     continue; // unknown page
                 }
 
-                $createLanguageVersionStatement->execute([$pageIDs[$identifier], $this->languageID]);
+                $createLanguageVersionStatement->execute([
+                    $this->languageID,
+                    $this->languageID,
+                    $pageIDs[$identifier],
+                    LanguageFactory::getInstance()->getDefaultLanguageID(),
+                ]);
                 if (isset($pageContent['title'])) {
                     $updateTitleStatement->execute([$pageContent['title'], $pageIDs[$identifier], $this->languageID]);
                 }