#7394 closed defect (bug) (fixed)
BP_Activity_Activity::__construct() sets id even if not valid
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Activity | Keywords: | has-patch |
Cc: |
Description
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 $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.
Set
id
to0
inpopulate()
if row not found