diff --git a/include/admin/import.inc.php b/include/admin/import.inc.php
index 17bd3cbc..f0b4333a 100644
--- a/include/admin/import.inc.php
+++ b/include/admin/import.inc.php
@@ -167,8 +167,31 @@ class Serendipity_Import {
global $serendipity;
mysql_select_db($this->data['name'], $db);
+ $dbn = false;
+
+ $target = $this->data['charset'];
+
+ switch($target) {
+ case 'native':
+ $dbn = SQL_CHARSET;
+ break;
+
+ case 'ISO-8859-1':
+ $dbn = 'latin1';
+ break;
+
+ case 'UTF-8':
+ $dbn = 'utf8';
+ break;
+ }
+
+ if ($dbn && $serendipity['dbNames']) {
+ mysql_query("SET NAMES " . $dbn, $db);
+ }
+
$return = &mysql_query($query, $db);
- mysql_select_db($serendipity['dbName'], $serendipity['dbConn']); $return = &mysql_query($query, $db);
+ mysql_select_db($serendipity['dbName'], $serendipity['dbConn']);
+ serendipity_db_reconnect();
return $return;
}
}
diff --git a/include/admin/importers/wordpress.inc.php b/include/admin/importers/wordpress.inc.php
index b9ba7187..3c0cba5c 100644
--- a/include/admin/importers/wordpress.inc.php
+++ b/include/admin/importers/wordpress.inc.php
@@ -214,7 +214,7 @@ class Serendipity_Import_WordPress extends Serendipity_Import {
ON taxonomy.term_id = terms.term_id
WHERE taxonomy.taxonomy = 'category'
- ORDER BY taxonomy.parent, taxonomy.term_taxonomy", $wpdb);
+ ORDER BY taxonomy.parent, taxonomy.term_taxonomy_id", $wpdb);
if (!$res && !$no_cat) {
$no_cat = mysql_error($wpdb);
} elseif ($res) {
@@ -332,8 +332,9 @@ class Serendipity_Import_WordPress extends Serendipity_Import {
rel.term_taxonomy_id AS category_id
FROM {$this->data['prefix']}term_relationships AS rel;", $wpdb);
if (!$res && !$no_entrycat) {
- printf(COULDNT_SELECT_ENTRY_INFO, mysql_error($wpdb));
+ $no_entrycat = mysql_error($wpdb);
} elseif ($res) {
+ $no_entrycat = false;
if ($debug) echo "Importing category associations (WP 2.3 style)...
\n";
while ($a = mysql_fetch_assoc($res)) {
$data = array('entryid' => $assoc['entries'][$a['post_id']],
@@ -344,7 +345,7 @@ class Serendipity_Import_WordPress extends Serendipity_Import {
}
if ($no_entrycat) {
- printf(COULDNT_SELECT_ENTRY_INFO, mysql_error($wpdb));
+ printf(COULDNT_SELECT_ENTRY_INFO, $no_entrycat);
}
/* Comments */
@@ -366,11 +367,10 @@ class Serendipity_Import_WordPress extends Serendipity_Import {
'subscribed'=> 'false',
'body' => $a['comment_content'],
'type' => 'NORMAL');
-
serendipity_db_insert('comments', $this->strtrRecursive($comment));
if ($comment['status'] == 'approved') {
$cid = serendipity_db_insert_id('comments', 'id');
- serendipity_approveComment($cid, $comment['entry_id'], true);
+ serendipity_approveComment($cid, $assoc['entries'][$a['comment_post_ID']], true);
}
}
if ($debug) echo "Imported comments.
\n";