Răsfoiți Sursa

Fixing WP import

svalavuo 4 zile în urmă
părinte
comite
1d92c5a041
2 a modificat fișierele cu 7 adăugiri și 10 ștergeri
  1. 4 9
      includes/wordpress_import.php
  2. 3 1
      setup.sql

+ 4 - 9
includes/wordpress_import.php

@@ -477,8 +477,8 @@ class WordPressImport {
                     
                     // Insert comment
                     $this->targetDb->query(
-                        "INSERT INTO comments (publication_id, parent_id, name, email, content, status, created_at, admin_reply) 
-                         VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
+                        "INSERT INTO comments (publication_id, parent_id, name, email, content, status, created_at, admin_reply, wp_comment_id) 
+                         VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
                         [
                             $publicationId,
                             $parentId,
@@ -487,18 +487,13 @@ class WordPressImport {
                             $wpComment['comment_content'],
                             $status,
                             $wpComment['comment_date'],
-                            false
+                            false,
+                            $wpComment['comment_ID']
                         ]
                     );
                     
                     $commentId = $this->targetDb->getConnection()->lastInsertId();
                     
-                    // Store WordPress comment ID for parent mapping
-                    $this->targetDb->query(
-                        "UPDATE comments SET wp_comment_id = ? WHERE id = ?",
-                        [$wpComment['comment_ID'], $commentId]
-                    );
-                    
                     $imported++;
                     $this->log("Successfully imported comment: '{$wpComment['comment_content']}' (ID: {$wpComment['comment_ID']})");
                     

+ 3 - 1
setup.sql

@@ -15,7 +15,9 @@ CREATE TABLE publications (
     created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
     updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
     published_at TIMESTAMP NULL DEFAULT NULL,
-    INDEX idx_publications_slug (slug)
+    wp_post_id INT NULL DEFAULT NULL,
+    INDEX idx_publications_slug (slug),
+    INDEX idx_publications_wp_post_id (wp_post_id)
 );
 
 -- Users table for admin authentication with LDAP support