summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/SemanticScuttle/Service/Bookmark2Tag.php13
-rw-r--r--tests/Bookmark2TagTest.php15
2 files changed, 22 insertions, 6 deletions
diff --git a/src/SemanticScuttle/Service/Bookmark2Tag.php b/src/SemanticScuttle/Service/Bookmark2Tag.php
index 6e8e28c..ed5e328 100644
--- a/src/SemanticScuttle/Service/Bookmark2Tag.php
+++ b/src/SemanticScuttle/Service/Bookmark2Tag.php
@@ -97,12 +97,13 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
$tags_count = is_array($tags)?count($tags):0;
-
- foreach($tags as $i => $tag) {
- $tags[$i] = trim(utf8_strtolower($tags[$i]));
- if ($fromApi) {
- include_once 'SemanticScuttle/functions.php';
- $tags[$i] = convertTag($tags[$i], 'in');
+ if (is_array($tags)) {
+ foreach($tags as $i => $tag) {
+ $tags[$i] = trim(utf8_strtolower($tags[$i]));
+ if ($fromApi) {
+ include_once 'SemanticScuttle/functions.php';
+ $tags[$i] = convertTag($tags[$i], 'in');
+ }
}
}
diff --git a/tests/Bookmark2TagTest.php b/tests/Bookmark2TagTest.php
index b0eccd1..fdfc42e 100644
--- a/tests/Bookmark2TagTest.php
+++ b/tests/Bookmark2TagTest.php
@@ -88,6 +88,21 @@ class Bookmark2TagTest extends TestBase
$this->b2ts->getTagsForBookmark($bid, true)
);
}
+
+ public function testAttachTagsWithEmptyStringAddsSystemUnfiled()
+ {
+ $originalDisplayErros = ini_get('display_errors');
+ $originalErrorReporting = ini_get('error_reporting');
+ ini_set('display_errors', 1);
+ error_reporting(E_ALL);
+ $bid = $this->addBookmark(null, null, 0, '');
+ $this->assertEquals(
+ array('system:unfiled'),
+ $this->b2ts->getTagsForBookmark($bid, true)
+ );
+ ini_set('display_errors', $originalDisplayErros);
+ error_reporting($originalErrorReporting);
+ }
public function testAttachTagsWithSomeEmptyTags()
{