Skip to:
Content

BuddyPress.org

Changeset 11312


Ignore:
Timestamp:
12/20/2016 02:54:45 AM (8 years ago)
Author:
boonebgorges
Message:

Activity: After populate(), activity items with a bad ID should have id = 0.

Props jdgrimes.
Fixes #7394.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/classes/class-bp-activity-activity.php

    r11101 r11312  
    186186        }
    187187
    188         if ( ! empty( $row ) ) {
    189             $this->id                = (int) $row->id;
    190             $this->item_id           = (int) $row->item_id;
    191             $this->secondary_item_id = (int) $row->secondary_item_id;
    192             $this->user_id           = (int) $row->user_id;
    193             $this->primary_link      = $row->primary_link;
    194             $this->component         = $row->component;
    195             $this->type              = $row->type;
    196             $this->action            = $row->action;
    197             $this->content           = $row->content;
    198             $this->date_recorded     = $row->date_recorded;
    199             $this->hide_sitewide     = (int) $row->hide_sitewide;
    200             $this->mptt_left         = (int) $row->mptt_left;
    201             $this->mptt_right        = (int) $row->mptt_right;
    202             $this->is_spam           = (int) $row->is_spam;
    203         }
     188        if ( empty( $row ) ) {
     189            $this->id = 0;
     190            return;
     191        }
     192
     193        $this->id                = (int) $row->id;
     194        $this->item_id           = (int) $row->item_id;
     195        $this->secondary_item_id = (int) $row->secondary_item_id;
     196        $this->user_id           = (int) $row->user_id;
     197        $this->primary_link      = $row->primary_link;
     198        $this->component         = $row->component;
     199        $this->type              = $row->type;
     200        $this->action            = $row->action;
     201        $this->content           = $row->content;
     202        $this->date_recorded     = $row->date_recorded;
     203        $this->hide_sitewide     = (int) $row->hide_sitewide;
     204        $this->mptt_left         = (int) $row->mptt_left;
     205        $this->mptt_right        = (int) $row->mptt_right;
     206        $this->is_spam           = (int) $row->is_spam;
    204207
    205208        // Generate dynamic 'action' when possible.
  • trunk/tests/phpunit/testcases/activity/class.BP_Activity_Activity.php

    r10217 r11312  
    772772    }
    773773
     774    /**
     775     * @ticket BP7394
     776     */
     777    public function test_nonexistent_activity_should_have_id_0_after_population() {
     778        $a = $this->factory->activity->create();
     779        bp_activity_delete_by_activity_id( $a );
     780
     781        $a_obj = new BP_Activity_Activity( $a );
     782        $this->assertSame( 0, $a_obj->id );
     783    }
     784
    774785    public function action_cb( $activity ) {
    775786        return 'Woo Hoo!';
Note: See TracChangeset for help on using the changeset viewer.