[buddypress-trac] [BuddyPress Trac] #7224: bp_groups_get_group_type() probably shouldn't return unregistered group types.

buddypress-trac noreply at wordpress.org
Fri Aug 19 15:39:09 UTC 2016


#7224: bp_groups_get_group_type() probably shouldn't return unregistered group
types.
-------------------------+--------------------
 Reporter:  dcavins      |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  2.7
Component:  Groups       |     Version:  2.6.0
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |
-------------------------+--------------------

Comment (by dcavins):

 Replying to [comment:1 boonebgorges]:
 > This looks good to me. One small thing: can you check the keys on the
 index after some items have been unset? I can't recall if it's numerically
 indexed; if so, running `unset( $array[1] )` on `[ 0 => 'foo', 1 => 'bar',
 2 => 'baz' ]` will leave you with an array with keys 0 and 2, and you
 should reset by passing through `array_values()`.

 Hi @boonebgorges -

 Thanks for your comment. Yes, the array keys are no longer compact after
 the unset, and adding `array_values()` as you suggest fixes that issue.

 I've read several things lately about avoiding direct modification of the
 active array in a `foreach` loop. Would it make more sense in a situation
 with small arrays like this to add the good terms to a validated array and
 pass that along, rather than removing bad terms from the array with an
 `unset()` which then should be followed up by an `array_values()`?

 Thanks!

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7224#comment:2>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list