commit fix for importers when source DB != target DB
authorgarvinhicking <garvinhicking>
Sat, 15 Oct 2005 16:02:02 +0000 (16:02 +0000)
committergarvinhicking <garvinhicking>
Sat, 15 Oct 2005 16:02:02 +0000 (16:02 +0000)
docs/NEWS
include/admin/import.inc.php
include/admin/importers/b2evolution.inc.php
include/admin/importers/sunlog.inc.php
include/admin/importers/textpattern.inc.php

index cadfb2bf076bfdd6de8079e9d774d23a27808e2d..c39f2e346cf8f361aa6d8c96b43a93e3775d8aa8 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -1,5 +1,10 @@
 # $Id$
 
+Version 0.9-beta3 ()
+------------------------------------------------------------------------
+    * Fix problem with b2evo importer when db was not in the same db
+      as serendipity. Thanks to Judebert from the forums! (garvinhicking)
+
 Version 0.9-beta2 ()
 ------------------------------------------------------------------------
 
index 1d4935acdcc1be84e85ce4f2410eba4d1ec705f7..a6a9661848be7cdae9fba6ef3fe201d77b9665c8 100644 (file)
@@ -104,7 +104,7 @@ class Serendipity_Import {
 
         mysql_select_db($this->data['name']);
         $return = &mysql_query($query, $db);
-        print_r($return);
+        // print_r($return);
         mysql_select_db($serendipity['dbName']);
         return $return;
     }
index 24edaa1d53872ff425f9eb5e9cafefaaed21c8c9..26a8fb3c263c2d468236371597c9848d5fcb264a 100644 (file)
@@ -126,7 +126,7 @@ class Serendipity_Import_b2evolution extends Serendipity_Import {
         }
 
         /* Categories */
-        if (!$this->importCategories(null)) {
+        if (!$this->importCategories(null, 0, $b2db)) {
             return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($b2db));
         }
         serendipity_rebuildCategoryTree();
@@ -258,7 +258,7 @@ class Serendipity_Import_b2evolution extends Serendipity_Import {
         return true;
     }
 
-    function importCategories($parentid = 0, $new_parentid = 0) {
+    function importCategories($parentid = 0, $new_parentid = 0, $b2db) {
         if (is_null($parentid)) {
             $where = 'WHERE ISNULL(cat_parent_ID)';
         } else {
@@ -266,7 +266,7 @@ class Serendipity_Import_b2evolution extends Serendipity_Import {
         }
 
         $res = $this->nativeQuery("SELECT * FROM evo_categories
-                                     " . $where);
+                                     " . $where, $b2db);
         if (!$res) {
             echo mysql_error();
             return false;
@@ -284,7 +284,7 @@ class Serendipity_Import_b2evolution extends Serendipity_Import {
             serendipity_db_insert('category', $this->strtrRecursive($cat));
             $row['categoryid']  = serendipity_db_insert_id('category', 'categoryid');
             $this->categories[] = $row;
-            $this->importCategories($row['cat_ID'], $row['categoryid']);
+            $this->importCategories($row['cat_ID'], $row['categoryid'], $b2db);
         }
 
         return true;
index 4e5649ead915c8e2ba7bd24ea7588f999125ab03..e21fd485484dc266901e073ea56071f525f39246 100644 (file)
@@ -126,7 +126,7 @@ class Serendipity_Import_sunlog extends Serendipity_Import {
         }
 
         /* Categories */
-        if (!$this->importCategories(null)) {
+        if (!$this->importCategories(null, 0, $sunlogdb)) {
             return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($sunlogdb));
         }
         serendipity_rebuildCategoryTree();
@@ -241,11 +241,11 @@ class Serendipity_Import_sunlog extends Serendipity_Import {
         return true;
     }
 
-    function importCategories($parentid = 0, $new_parentid = 0) {
+    function importCategories($parentid = 0, $new_parentid = 0, $sunlogdb) {
         $where = "WHERE parent = '" . mysql_escape_string($parentid) . "'";
 
         $res = $this->nativeQuery("SELECT * FROM {$this->data['prefix']}categories
-                                     " . $where);
+                                     " . $where, $sunlogdb);
         if (!$res) {
             echo mysql_error();
             return false;
@@ -263,7 +263,7 @@ class Serendipity_Import_sunlog extends Serendipity_Import {
             serendipity_db_insert('category', $this->strtrRecursive($cat));
             $row['categoryid']  = serendipity_db_insert_id('category', 'categoryid');
             $this->categories[] = $row;
-            $this->importCategories($row['id'], $row['categoryid']);
+            $this->importCategories($row['id'], $row['categoryid'], $sunlogdb);
         }
 
         return true;
index 5d0b8140f9a29e1fbfbf6ae3e22c4d05f9f4e21f..7b6898b1b6aab3a53de7d2070d9bace216a7f8e0 100644 (file)
@@ -131,7 +131,7 @@ class Serendipity_Import_textpattern extends Serendipity_Import {
         }
 
         /* Categories */
-        if (!$this->importCategories('root')) {
+        if (!$this->importCategories('root', 0, $txpdb)) {
             return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysql_error($txpdb));
         }
         serendipity_rebuildCategoryTree();
@@ -218,9 +218,9 @@ class Serendipity_Import_textpattern extends Serendipity_Import {
         return true;
     }
 
-    function importCategories($parentname = 'root', $parentid = 0) {
+    function importCategories($parentname = 'root', $parentid = 0, $txpdb) {
         $res = $this->nativeQuery("SELECT * FROM {$this->data['prefix']}txp_category
-                                     WHERE parent = '" . mysql_escape_string($parentname) . "' AND type = 'article'");
+                                     WHERE parent = '" . mysql_escape_string($parentname) . "' AND type = 'article'", $txpdb);
         if (!$res) {
             echo mysql_error();
             return false;
@@ -238,7 +238,7 @@ class Serendipity_Import_textpattern extends Serendipity_Import {
             serendipity_db_insert('category', $this->strtrRecursive($cat));
             $row['categoryid']  = serendipity_db_insert_id('category', 'categoryid');
             $this->categories[] = $row;
-            $this->importCategories($row['name'], $row['categoryid']);
+            $this->importCategories($row['name'], $row['categoryid'], $txpdb);
         }
 
         return true;