From c27d6ee56828dc7c3c1c2bd8c5601faddd3639b3 Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Sat, 15 Oct 2005 16:02:02 +0000 Subject: [PATCH] commit fix for importers when source DB != target DB --- docs/NEWS | 5 +++++ include/admin/import.inc.php | 2 +- include/admin/importers/b2evolution.inc.php | 8 ++++---- include/admin/importers/sunlog.inc.php | 8 ++++---- include/admin/importers/textpattern.inc.php | 8 ++++---- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/docs/NEWS b/docs/NEWS index cadfb2b..c39f2e3 100644 --- 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 () ------------------------------------------------------------------------ diff --git a/include/admin/import.inc.php b/include/admin/import.inc.php index 1d4935a..a6a9661 100644 --- a/include/admin/import.inc.php +++ b/include/admin/import.inc.php @@ -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; } diff --git a/include/admin/importers/b2evolution.inc.php b/include/admin/importers/b2evolution.inc.php index 24edaa1..26a8fb3 100644 --- a/include/admin/importers/b2evolution.inc.php +++ b/include/admin/importers/b2evolution.inc.php @@ -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; diff --git a/include/admin/importers/sunlog.inc.php b/include/admin/importers/sunlog.inc.php index 4e5649e..e21fd48 100644 --- a/include/admin/importers/sunlog.inc.php +++ b/include/admin/importers/sunlog.inc.php @@ -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; diff --git a/include/admin/importers/textpattern.inc.php b/include/admin/importers/textpattern.inc.php index 5d0b814..7b6898b 100644 --- a/include/admin/importers/textpattern.inc.php +++ b/include/admin/importers/textpattern.inc.php @@ -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; -- 2.39.5