From 704a20f58b828bbbcfb66236e60cbe0abd49b52a Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 20 Dec 2010 13:39:07 -0500 Subject: [PATCH] some corrections for double-posting of bookmarks --- plugins/Bookmark/deliciousbackupimporter.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/Bookmark/deliciousbackupimporter.php b/plugins/Bookmark/deliciousbackupimporter.php index af34f6066b..b9dc7d8879 100644 --- a/plugins/Bookmark/deliciousbackupimporter.php +++ b/plugins/Bookmark/deliciousbackupimporter.php @@ -16,8 +16,6 @@ class DeliciousBackupImporter $children = $dl->childNodes; - common_debug("
child nodes is " . $children->length); - $dt = null; for ($i = 0; $i < $children->length; $i++) { @@ -40,6 +38,7 @@ class DeliciousBackupImporter $dd = $child; $saved = $this->importBookmark($user, $dt, $dd); $dt = null; + $dd = null; case 'p': common_log(LOG_INFO, 'Skipping the

in the

.'); break; @@ -48,18 +47,25 @@ class DeliciousBackupImporter } } catch (Exception $e) { common_log(LOG_ERR, $e->getMessage()); + $dt = $dd = null; } } } function importBookmark($user, $dt, $dd = null) { - common_debug("DT child nodes length = " . $dt->childNodes->length); + // We have to go squirrelling around in the child nodes + // on the off chance that we've received another
+ // as a child. for ($i = 0; $i < $dt->childNodes->length; $i++) { $child = $dt->childNodes->item($i); if ($child->nodeType == XML_ELEMENT_NODE) { - common_debug('DT has an element child with tag name '. $child->tagName); + if ($child->tagName == 'dt' && !is_null($dd)) { + $this->importBookmark($user, $dt); + $this->importBookmark($user, $child, $dd); + return; + } } } @@ -83,7 +89,7 @@ class DeliciousBackupImporter $description = null; } - $title = $a->getAttribute('title'); + $title = $a->nodeValue; $url = $a->getAttribute('href'); $tags = $a->getAttribute('tags'); $addDate = $a->getAttribute('add_date'); -- 2.39.5