<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][12729] trunk: BP Types: merge BP Types saved in DB with the ones registered by code</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/12729">12729</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/12729","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>imath</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2020-09-21 01:21:21 +0000 (Mon, 21 Sep 2020)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>BP Types: merge BP Types saved in DB with the ones registered by code

- Introduces the `bp_get_taxonomy_types()` to merge types saved into the database with the types registered by code. It's now possible to edit all properties of the registered by code types except for the type's slug which needs to be unique.
- Caches these merged types.
- Introduces the `bp_get_member_types_registered_by_code()` to only get member types registered by code.
- Updates the `test_bp_get_member_type_should_not_return_unregistered_types()` unit test to `test_bp_get_registered_by_code_member_type_should_not_return_unregistered_types()` to check the previous point new function.
- Introduces the `bp_update_type_metadata()` function to update a type's metadata.

Props mercime, DJPaul, dcavins, boonebgorges, tw2113, sbrajesh

See <a href="http://buddypress.trac.wordpress.org/ticket/7179">#7179</a>
See <a href="http://buddypress.trac.wordpress.org/ticket/7181">#7181</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpcorebpcorecachephp">trunk/src/bp-core/bp-core-cache.php</a></li>
<li><a href="#trunksrcbpcorebpcorefunctionsphp">trunk/src/bp-core/bp-core-functions.php</a></li>
<li><a href="#trunksrcbpmembersbpmembersfunctionsphp">trunk/src/bp-members/bp-members-functions.php</a></li>
<li><a href="#trunktestsphpunittestcasesmemberstypesphp">trunk/tests/phpunit/testcases/members/types.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpcorebpcorecachephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-core/bp-core-cache.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/bp-core-cache.php       2020-09-21 01:09:16 UTC (rev 12728)
+++ trunk/src/bp-core/bp-core-cache.php 2020-09-21 01:21:21 UTC (rev 12729)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -390,3 +390,28 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'bp_invitation_after_save', 'bp_invitations_reset_cache_incrementor' );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'bp_invitation_after_delete', 'bp_invitations_reset_cache_incrementor' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * Add a cache group for Database object types.
+ *
+ * @since 7.0.0
+ */
+function bp_set_object_type_terms_cache_group() {
+       wp_cache_add_global_groups( 'bp_object_terms' );
+}
+add_action( 'bp_setup_cache_groups', 'bp_set_object_type_terms_cache_group' );
+
+/**
+ * Clear the Database object types cache.
+ *
+ * @since 7.0.0
+ *
+ * @param int $type_id The Type's term ID.
+ * @param string $taxonomy The Type's taxonomy name.
+ */
+function bp_clear_object_type_terms_cache( $type_id = 0, $taxonomy = '' ) {
+       wp_cache_delete( $taxonomy, 'bp_object_terms' );
+}
+add_action( 'bp_type_inserted', 'bp_clear_object_type_terms_cache' );
+add_action( 'bp_type_updated', 'bp_clear_object_type_terms_cache' );
+add_action( 'bp_type_deleted', 'bp_clear_object_type_terms_cache' );
</ins></span></pre></div>
<a id="trunksrcbpcorebpcorefunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-core/bp-core-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/bp-core-functions.php   2020-09-21 01:09:16 UTC (rev 12728)
+++ trunk/src/bp-core/bp-core-functions.php     2020-09-21 01:21:21 UTC (rev 12729)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3143,6 +3143,120 @@
</span><span class="cx" style="display: block; padding: 0 10px">        return register_term_meta( $type_tax, $meta_key, $args );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Update a list of metadata for a given type ID and a given taxonomy.
+ *
+ * @since 7.0.0
+ *
+ * @param  integer $type_id    The database ID of the BP Type.
+ * @param  string  $taxonomy   The BP Type taxonomy.
+ * @param  array   $type_metas An associative array (meta_key=>meta_value).
+ * @return boolean             False on failure. True otherwise.
+ */
+function bp_update_type_metadata( $type_id = 0, $taxonomy = '', $type_metas = array() ) {
+       if ( ! $type_id || ! $taxonomy || ! is_array( $type_metas ) ) {
+               return false;
+       }
+
+       foreach ( $type_metas as $meta_key => $meta_value ) {
+               if ( ! registered_meta_key_exists( 'term', $meta_key, $taxonomy ) ) {
+                       continue;
+               }
+
+               update_term_meta( $type_id, $meta_key, $meta_value );
+       }
+
+       return true;
+}
+
+/**
+ * Get types for a given BP Taxonomy.
+ *
+ * @since 7.0.0
+ *
+ * @param string $taxonomy The taxonomy to transform terms in types for.
+ * @param array  $types    Existing types to merge with the types found into the database.
+ *                         For instance this function is used internally to merge Group/Member
+ *                         types registered using code with the ones created by the administrator
+ *                         from the Group/Member types Administration screen. If not provided, only
+ *                         Types created by the administrator will be returned.
+ *                         Optional.
+ * @return array           The types of the given taxonomy.
+ */
+function bp_get_taxonomy_types( $taxonomy = '', $types = array() ) {
+       if ( ! $taxonomy ) {
+               return $types;
+       }
+
+       $db_types = wp_cache_get( $taxonomy, 'bp_object_terms' );
+
+       if ( ! $db_types ) {
+               $terms = bp_get_terms(
+                       array(
+                               'taxonomy' => $taxonomy,
+                       )
+               );
+
+               if ( ! is_array( $terms ) || ! $terms ) {
+                       return $types;
+               }
+
+               $type_metadata = array_keys( get_registered_meta_keys( 'term', $taxonomy ) );
+
+               foreach ( $terms as $term ) {
+                       $type_name                      = $term->name;
+                       $db_types[ $type_name ]         = new stdClass();
+                       $db_types[ $type_name ]->db_id  = $term->term_id;
+                       $db_types[ $type_name ]->labels = array();
+                       $db_types[ $type_name ]->name   = $type_name;
+
+                       if ( $type_metadata ) {
+                               foreach ( $type_metadata as $meta_key ) {
+                                       $type_key = str_replace( 'bp_type_', '', $meta_key );
+                                       if ( in_array( $type_key, array( 'name', 'singular_name' ), true ) ) {
+                                               $db_types[ $type_name ]->labels[ $type_key ] = get_term_meta( $term->term_id, $meta_key, true );
+                                       } else {
+                                               $db_types[ $type_name ]->{$type_key} = get_term_meta( $term->term_id, $meta_key, true );
+                                       }
+                               }
+                       }
+               }
+
+               wp_cache_set( $taxonomy, $db_types, 'bp_object_terms' );
+       }
+
+       if ( is_array( $db_types ) ) {
+               foreach ( $db_types as $db_type_name => $db_type ) {
+                       // Override props of registered by code types if customized by the admun user.
+                       if ( isset( $types[ $db_type_name ] ) && isset( $types[ $db_type_name ]->code ) && $types[ $db_type_name ]->code ) {
+                               // Merge Labels.
+                               if ( $db_type->labels ) {
+                                       foreach ( $db_type->labels as $key_label => $value_label ) {
+                                               if ( '' !== $value_label ) {
+                                                       $types[ $db_type_name ]->labels[ $key_label ] = $value_label;
+                                               }
+                                       }
+                               }
+
+                               // Merge other properties.
+                               foreach ( get_object_vars( $types[ $db_type_name ] ) as $key_prop => $value_prop ) {
+                                       if ( 'labels' === $key_prop || 'name' === $key_prop ) {
+                                               continue;
+                                       }
+
+                                       if ( isset( $db_type->{$key_prop} ) && '' !== $db_type->{$key_prop} ) {
+                                               $types[ $db_type_name  ]->{$key_prop} = $db_type->{$key_prop};
+                                       }
+                               }
+
+                               unset( $db_types[ $db_type_name ] );
+                       }
+               }
+       }
+
+       return array_merge( $types, (array) $db_types );
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /** Email *****************************************************************/
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcbpmembersbpmembersfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-members/bp-members-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-members/bp-members-functions.php     2020-09-21 01:09:16 UTC (rev 12728)
+++ trunk/src/bp-members/bp-members-functions.php       2020-09-21 01:21:21 UTC (rev 12729)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2763,6 +2763,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        $r = bp_parse_args( $args, array(
</span><span class="cx" style="display: block; padding: 0 10px">                'labels'        => array(),
</span><span class="cx" style="display: block; padding: 0 10px">                'has_directory' => true,
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                'code'          => true,
+               'db_id'         => 0,
</ins><span class="cx" style="display: block; padding: 0 10px">         ), 'register_member_type' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $member_type = sanitize_key( $member_type );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2862,6 +2864,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function bp_get_member_types( $args = array(), $output = 'names', $operator = 'and' ) {
</span><span class="cx" style="display: block; padding: 0 10px">        $types = buddypress()->members->types;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        // Merge with types available into the database.
+       if ( ! isset( $args['code'] ) || true !== $args['code'] ) {
+               $types = bp_get_taxonomy_types( bp_get_member_type_tax_name(), $types );
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         $types = wp_filter_object_list( $types, $args, $operator );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2886,6 +2893,78 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Only gets the member types registered by code.
+ *
+ * @since 7.0.0
+ *
+ * @return array The member types registered by code.
+ */
+function bp_get_member_types_registered_by_code() {
+       return bp_get_member_types(
+               array(
+                       'code' => true,
+               ),
+               'objects'
+       );
+}
+add_filter( bp_get_member_type_tax_name() . '_registered_by_code', 'bp_get_member_types_registered_by_code' );
+
+/**
+ * Generates missing metadata for a type registered by code.
+ *
+ * @since 7.0.0
+ *
+ * @return array The member type metadata.
+ */
+function bp_set_registered_by_code_member_type_metadata( $metadata = array(), $type = '' ) {
+       $member_type = bp_get_member_type_object( $type );
+
+       foreach ( get_object_vars( $member_type ) as $object_key => $object_value ) {
+               if ( 'labels' === $object_key ) {
+                       foreach ( $object_value as $label_key => $label_value ) {
+                               $metadata[ 'bp_type_' . $label_key ] = $label_value;
+                       }
+               } elseif ( ! in_array( $object_key, array( 'name', 'code', 'db_id' ), true ) ) {
+                       $metadata[ 'bp_type_' . $object_key ] = $object_value;
+               }
+       }
+
+       /**
+        * Save metadata into database to avoid generating metadata
+        * each time a type is listed into the Types Admin screen.
+        */
+       if ( isset( $member_type->db_id ) && $member_type->db_id ) {
+               bp_update_type_metadata( $member_type->db_id, bp_get_member_type_tax_name(), $metadata );
+       }
+
+       return $metadata;
+}
+add_filter( bp_get_member_type_tax_name() . '_set_registered_by_code_metada', 'bp_set_registered_by_code_member_type_metadata', 10, 2 );
+
+/**
+ * Insert member types registered by code not yet saved into the database as WP Terms.
+ *
+ * @since 7.0.0
+ */
+function bp_insert_member_types_registered_by_code() {
+       $all_types     = bp_get_member_types( array(), 'objects' );
+       $unsaved_types = wp_filter_object_list( $all_types, array( 'db_id' => 0 ), 'and', 'name' );
+
+       if ( $unsaved_types ) {
+               foreach ( $unsaved_types as $type_name ) {
+                       bp_insert_term(
+                               $type_name,
+                               bp_get_member_type_tax_name(),
+                               array(
+                                       'slug' => $type_name,
+                               )
+                       );
+               }
+       }
+}
+add_action( bp_get_member_type_tax_name() . '_add_form', 'bp_insert_member_types_registered_by_code', 1 );
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px">  * Set type for a member.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 2.2.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2968,14 +3047,17 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * Get type for a member.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 2.2.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 7.0.0 Adds the `$use_db` parameter.
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @param int  $user_id ID of the user.
</span><span class="cx" style="display: block; padding: 0 10px">  * @param bool $single  Optional. Whether to return a single type string. If multiple types are found
</span><span class="cx" style="display: block; padding: 0 10px">  *                      for the user, the oldest one will be returned. Default: true.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param bool $use_db  Optional. Whether to request all member types or only the ones registered by code.
+ *                      Default: true.
</ins><span class="cx" style="display: block; padding: 0 10px">  * @return string|array|bool On success, returns a single member type (if $single is true) or an array of member
</span><span class="cx" style="display: block; padding: 0 10px">  *                           types (if $single is false). Returns false on failure.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function bp_get_member_type( $user_id, $single = true ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function bp_get_member_type( $user_id, $single = true, $use_db = true ) {
</ins><span class="cx" style="display: block; padding: 0 10px">         $types = wp_cache_get( $user_id, 'bp_member_member_type' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        if ( false === $types ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2995,6 +3077,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        if ( false === $use_db && $types ) {
+               $registred_by_code = bp_get_member_types_registered_by_code();
+               $ctype_names       = wp_list_pluck( $registred_by_code, 'name' );
+               $types             = array_intersect( $types, $ctype_names );
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         $type = false;
</span><span class="cx" style="display: block; padding: 0 10px">        if ( ! empty( $types ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                if ( $single ) {
</span></span></pre></div>
<a id="trunktestsphpunittestcasesmemberstypesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/testcases/members/types.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/testcases/members/types.php   2020-09-21 01:09:16 UTC (rev 12728)
+++ trunk/tests/phpunit/testcases/members/types.php     2020-09-21 01:21:21 UTC (rev 12729)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -393,7 +393,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEqualSets( array( 'bar', 'foo' ), $types );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public function test_bp_get_member_type_should_not_return_unregistered_types() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_bp_get_registered_by_code_member_type_should_not_return_unregistered_types() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $u1 = self::factory()->user->create();
</span><span class="cx" style="display: block; padding: 0 10px">                bp_register_member_type( 'foo' );
</span><span class="cx" style="display: block; padding: 0 10px">                bp_set_member_type( $u1, 'foo' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -401,7 +401,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                // Directly set a type that hasn't been registered.
</span><span class="cx" style="display: block; padding: 0 10px">                bp_set_object_terms( $u1, 'ugh', bp_get_member_type_tax_name(), true );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $type = bp_get_member_type( $u1, false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $type = bp_get_member_type( $u1, false, false );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertEquals( array( 'foo' ), $type );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>

</body>
</html>