[3831] trunk/htdocs/system/classes/installhandler.php: Upgrade to using terms without destroying the tag2post table tag ids.

0 views
Skip to first unread message

svn-N...@habariproject.org

unread,
Nov 25, 2009, 3:11:52 AM11/25/09
to habar...@googlegroups.com
Revision
3831
Author
rickc
Date
2009-11-25 08:11:52 +0000 (Wed, 25 Nov 2009)

Log Message

Upgrade to using terms without destroying the tag2post table tag ids.

Modified Paths

Diff

Modified: trunk/htdocs/system/classes/installhandler.php (3830 => 3831)


--- trunk/htdocs/system/classes/installhandler.php	2009-11-25 05:07:47 UTC (rev 3830)
+++ trunk/htdocs/system/classes/installhandler.php	2009-11-25 08:11:52 UTC (rev 3831)
@@ -1482,15 +1482,18 @@
 		$vocabulary->insert();
 		
 		$new_tag = NULL;
+		$post_ids = array();
 		$prefix = Config::get( 'db_connection' )->prefix;
 
-		$results = DB::get_results( "SELECT ID, tag_text, tag_slug from {$prefix}tags" );
+		$results = DB::get_results( "SELECT id, tag_text, tag_slug from {$prefix}tags" );
 
 		foreach( $results as $tag ) {
 			$new_tag = $vocabulary->add_term( $tag->tag_text );
-			DB::query( "UPDATE {$prefix}tag2post SET tag_id = ? WHERE tag_id = ?", array( $new_tag->id, $tag->id ) );
+			$post_ids = DB::get_column( "SELECT post_id FROM {$prefix}tag2post WHERE tag_id = ?", array( $tag->id ) );
+			foreach( $post_ids as $id ) {
+				DB::insert( "{object_terms}", array( 'term_id' => $new_tag->id, 'object_id' => $id, 'object_type_id' => $type_id ) );
+			}
 		}
-		DB::exec( "INSERT INTO {object_terms} (term_id, object_id, object_type_id) SELECT tag_id, post_id, {$type_id} AS type_id FROM {$prefix}tag2post" );
 	}
 
 	/**
Reply all
Reply to author
Forward
0 new messages