Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/09/2016 08:32:09 PM (11 years ago)
Author:
djpaul
Message:

Emails: fix situations not being correctly assigned to email posts.

Previously, we were using wp_set_post_terms() to fetch the terms to assign to an email post. However, it turns that that function returns term taxonomy IDs, not term IDs. Generally, term_id and term_taxonomy_id will be the same for newly created terms like these, but not when the database still contains shared taxonomy terms.

Fixes #6936

Props chherbst, boonebgorges

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/admin/functions.php

    r9819 r10647  
    219219                $bp->admin->notices = $reset_admin_notices;
    220220        }
     221
     222        /**
     223         * @ticket BP6936
     224         */
     225        public function test_email_type_descriptions_should_match_when_split_terms_exist() {
     226                global $wpdb;
     227
     228                // Delete all existing email types and descriptions.
     229                $emails = get_posts( array(
     230                        'fields' => 'ids',
     231                        'post_type' => bp_get_email_post_type(),
     232                ) );
     233                foreach ( $emails as $email ) {
     234                        wp_delete_post( $email, true );
     235                }
     236
     237                $descriptions = get_terms( bp_get_email_tax_type(), array(
     238                        'fields' => 'ids',
     239                        'hide_empty' => false,
     240                ) );
     241                foreach ( $descriptions as $description ) {
     242                        wp_delete_term( (int) $description, bp_get_email_tax_type() );
     243                }
     244
     245                // Fake the existence of split terms by offsetting the term_taxonomy table.
     246                $wpdb->insert( $wpdb->term_taxonomy, array( 'term_id' => 9999, 'taxonomy' => 'post_tag', 'description' => 'foo description', 'parent' => 0, 'count' => 0 ) );
     247
     248                require_once( BP_PLUGIN_DIR . '/bp-core/admin/bp-core-admin-schema.php' );
     249                bp_core_install_emails();
     250
     251                $d_terms = get_terms( bp_get_email_tax_type(), array(
     252                        'hide_empty' => false,
     253                ) );
     254
     255                $correct_descriptions = bp_email_get_type_schema();
     256                foreach ( $d_terms as $d_term ) {
     257                        $correct_description = $correct_descriptions[ $d_term->slug ];
     258                        $this->assertSame( $correct_description, $d_term->description );
     259                }
     260        }
    221261}
Note: See TracChangeset for help on using the changeset viewer.