]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
script to fix unfiled bugs (for bug #3386178)
authorChristian Weiske <cweiske@cweiske.de>
Fri, 5 Aug 2011 17:48:46 +0000 (19:48 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Fri, 5 Aug 2011 17:48:46 +0000 (19:48 +0200)
doc/ChangeLog
doc/UPGRADE.txt
scripts/fix-unfiled-tags.php [new file with mode: 0644]

index d71a3d05de68cc719077d9b9f78d41c89090213f..860a213d29aeb78d023789aa188efbf779ed7a02 100644 (file)
@@ -8,6 +8,9 @@ ChangeLog for SemantiScuttle
 - Fix bug #3385724: Rename tag ends with XML Parsing Error
 - Fix bug #3386178: "system:unfiled" secret tag does not work
 
+Run ``scripts/fix-unfiled-tags.php`` to fix old bookmarks that miss the
+``system:unfiled`` tags.
+
 
 0.98.1 - 2011-08-01
 -------------------
index b144af202061e7425b2c9027b460ee22d6351aff..e4054315edfa399628b19c3ac2ca37f026d38c27 100644 (file)
@@ -4,6 +4,12 @@ Upgrading SemanticScuttle from a previous version
 
 .. contents::
 
+From version 0.94-0.98.1 to 0.98.2
+==================================
+Run ``scripts/fix-unfiled-tags.php`` to fix old bookmarks that miss the
+``system:unfiled`` tags.
+
+
 From version 0.97 to 0.98
 =========================
 Database updates
diff --git a/scripts/fix-unfiled-tags.php b/scripts/fix-unfiled-tags.php
new file mode 100644 (file)
index 0000000..8a5238e
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+/**
+ * SemanticScuttle from approximately 0.94 up to 0.98.2, system:unfiled
+ * tags were not created when adding new bookmarks with the web interface.
+ *
+ * This script adds system:unfiled tags for all bookmarks that have no
+ * tags.
+ */
+require_once dirname(__FILE__) . '/../src/SemanticScuttle/header-standalone.php';
+
+//needed to load the database object 
+$bt = SemanticScuttle_Service_Factory::get('Bookmark2Tag');
+$db = SemanticScuttle_Service_Factory::getDb();
+
+$query = <<<SQL
+SELECT b.bId
+FROM sc_bookmarks AS b
+ LEFT JOIN sc_bookmarks2tags AS bt ON b.bId = bt.bId
+WHERE bt.bId IS NULL
+SQL;
+
+if (!($dbresult = $db->sql_query($query))) {
+    die('Strange SQL error');
+}
+while ($row = $db->sql_fetchrow($dbresult)) {
+    $db->sql_query(
+        'INSERT INTO ' . $bt->getTableName() . ' '
+        . $db->sql_build_array(
+            'INSERT',
+            array('bId' => $row['bId'], 'tag' => 'system:unfiled')
+        )
+    );
+}
+$db->sql_freeresult($dbresult);
+?>
\ No newline at end of file