[bbDev] [1526] trunk: copy tags to taxonomy
Sam Bauers
sam at automattic.com
Wed May 14 15:52:34 GMT 2008
Do you think it will be possible to share taxonomy tables with
WordPress?
I can see many advantages for plugin developers wanting to leverage
bbPress data in WordPress. But I'm not completely sure it's a good idea.
Sam
On 14/05/2008, at 6:23 AM, m at wordpress.org wrote:
> Revision1526AuthormdawaffeDate2008-05-13 20:23:39 +0000 (Tue, 13 May
> 2008)Log Message
> copy tags to taxonomy
> Modified Paths
> • trunk/bb-admin/upgrade-functions.php
> • trunk/bb-includes/functions.php
> • trunk/bb-settings.php
> Diff
> Modified: trunk/bb-admin/upgrade-functions.php (1525 => 1526)
> --- trunk/bb-admin/upgrade-functions.php 2008-05-13 19:55:46 UTC
> (rev 1525)
> +++ trunk/bb-admin/upgrade-functions.php 2008-05-13 20:23:39 UTC
> (rev 1526)
> @@ -10,7 +10,10 @@
> function bb_upgrade_all() {
> if ( !ini_get('safe_mode') )
> set_time_limit(600);
> +
> $bb_upgrade = array();
> +
> + // Pre DB Delta
> $bb_upgrade[] = bb_upgrade_160(); // Break blocked users
> $bb_upgrade[] = bb_upgrade_170(); // Escaping in usermeta
> $bb_upgrade[] = bb_upgrade_180(); // Delete users for real
> @@ -18,8 +21,11 @@
> $bb_upgrade[] = bb_upgrade_200(); // Indices
> $bb_upgrade[] = bb_upgrade_210(); // Convert text slugs to varchar
> slugs
> $bb_upgrade[] = bb_upgrade_220(); // remove bb_tagged primary key,
> add new column and primary key
> +
> require_once( BB_PATH . 'bb-admin/upgrade-schema.php');
> $bb_upgrade = array_merge($bb_upgrade, bb_dbDelta($bb_queries));
> +
> + // Post DB Delta
> $bb_upgrade[] = bb_upgrade_1000(); // Make forum and topic slugs
> $bb_upgrade[] = bb_upgrade_1010(); // Make sure all forums have a
> valid parent
> $bb_upgrade[] = bb_upgrade_1020(); // Add a user_nicename to
> existing users
> @@ -28,7 +34,10 @@
> $bb_upgrade[] = bb_upgrade_1050(); // Update active theme if present
> $bb_upgrade[] = bb_upgrade_1060(); // throttle_time option
> $bb_upgrade[] = bb_upgrade_1070(); // trim whitespace from raw_tag
> + $bb_upgrade[] = bb_upgrade_1080(); // Convert tags to taxonomy
> +
> bb_update_db_version();
> +
> return $bb_upgrade;
> }
>
> @@ -604,6 +613,45 @@
> return 'Whitespace trimmed from raw_tag: ' . __FUNCTION__;
> }
>
> +function bb_upgrade_1080() {
> + global $bbdb, $wp_taxonomy_object;
> + if ( ( $dbv = bb_get_option_from_db( 'bb_db_version' ) ) && $dbv
> >= 1526 )
> + return;
> +
> + $offset = 0;
> + while ( $tags = (array) $bbdb->get_results( "SELECT * FROM $bbdb-
> >tags LIMIT $offset, 100" ) ) {
> + if ( !ini_get('safe_mode') ) set_time_limit(600);
> + $wp_taxonomy_object->defer_term_counting(true);
> + for ( $i = 0; isset($tags[$i]); $i++ ) {
> + $bbdb->insert( $bbdb->terms, array(
> + 'name' => $tags[$i]->raw_tag,
> + 'slug' => $tags[$i]->tag
> + ) );
> + $term_id = $bbdb->insert_id;
> + $bbdb->insert( $bbdb->term_taxonomy, array(
> + 'term_id' => $term_id,
> + 'taxonomy' => 'bb_topic_tag'
> + ) );
> + $term_taxonomy_id = $bbdb->insert_id;
> + $topics = (array) $bbdb->get_results( $bbdb->prepare( "SELECT
> user_id, topic_id FROM $bbdb->tagged WHERE tag_id = %d", $tags[$i]-
> >tag_id ) );
> + for ( $j = 0; isset($topics[$j]); $j++ ) {
> + $bbdb->insert( $bbdb->term_relationships, array(
> + 'object_id' => $topics[$j]->topic_id,
> + 'term_taxonomy_id' => $term_taxonomy_id,
> + 'user_id' => $topics[$j]->user_id
> + ) );
> + }
> + $wp_taxonomy_object-
> >update_term_count( array( $term_taxonomy_id ), 'bb_topic_tag' );
> + }
> + $wp_taxonomy_object->defer_term_counting(false);
> + $offset += 100;
> + }
> +
> + bb_update_option( 'bb_db_version', 1467 );
> +
> + return 'Tags copied to taxonomy tables: ' . __FUNCTION__;
> +}
> +
> function bb_deslash($content) {
> // Note: \\\ inside a regex denotes a single backslash.
>
> Modified: trunk/bb-includes/functions.php (1525 => 1526)
> --- trunk/bb-includes/functions.php 2008-05-13 19:55:46 UTC (rev 1525)
> +++ trunk/bb-includes/functions.php 2008-05-13 20:23:39 UTC (rev 1526)
> @@ -1557,7 +1557,7 @@
> return '1.0-dev'; // Don't filter
> break;
> case 'bb_db_version' :
> - return '1523'; // Don't filter
> + return '1526'; // Don't filter
> break;
> case 'html_type' :
> $r = 'text/html';
> Modified: trunk/bb-settings.php (1525 => 1526)
> --- trunk/bb-settings.php 2008-05-13 19:55:46 UTC (rev 1525)
> +++ trunk/bb-settings.php 2008-05-13 20:23:39 UTC (rev 1526)
> @@ -386,7 +386,7 @@
> $wp_taxonomy_object->taxonomies =& $tax;
> unset($tax);
> }
> -$wp_taxonomy_object->register_taxonomy( 'bb_topic_tag', 'bb_topic',
> array( 'hierarchical' => false ) );
> +$wp_taxonomy_object->register_taxonomy( 'bb_topic_tag', 'bb_topic' );
>
> // Set the path to the tag pages
> if ( !isset( $bb->tagpath ) )
> _______________________________________________
> bbDev mailing list
> bbDev at lists.bbpress.org
> http://lists.bbpress.org/mailman/listinfo/bbdev
---------------------
Sam Bauers
Automattic, Inc.
sam at automattic.com
http://automattic.com
http://wordpress.com
http://wordpress.org
http://bbpress.org
http://unlettered.org
---------------------
More information about the bbDev
mailing list