[buddypress-trac] [BuddyPress Trac] #7394: BP_Activity_Activity::__construct() sets id even if not valid

buddypress-trac noreply at wordpress.org
Fri Dec 16 13:57:46 UTC 2016


#7394: BP_Activity_Activity::__construct() sets id even if not valid
--------------------------+-----------------------------
 Reporter:  jdgrimes      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Activity      |    Version:
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 In many of BuddyPress's objects that are constructed with an ID, the `id`
 attribute is only set to a non-zero value if the passed ID actually
 belongs to an existing record in the database. However, in
 `BP_Activity_Activity::__construct()`, the `id` is set, and in
 `populate()` it is ''not'' set to `0` if the ID is invalid. In other
 objects, `populate()` will set the ID to `0` if it can't find the record
 in the database.

 So for most objects, you can check if an item exists with a certain ID
 like this:

 {{{#!php
 <?php
 $object = new BP_Groups_Group( $id );

 if ( ! $object->id ) {
     // doesn't exist.
 }
 }}}


 However, for `BP_Activity_Activity`, this doesn't work, and there is
 apparently no other method available specifically for checking if an
 activity item with a given ID actually exists.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7394>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list