Skip to:
Content

BuddyPress.org

Ticket #6580: 6580.diff

File 6580.diff, 3.1 KB (added by jdgrimes, 9 years ago)

Always populate the fields

  • tests/phpunit/testcases/messages/class.bp-messages-thread.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    402402        public function test_is_valid_invalid_thread() {
    403403                $this->assertEquals( null, BP_Messages_Thread::is_valid( 999 ) );
    404404        }
     405
     406        /**
     407         * @group last_message
     408         */
     409        public function test_last_message_populated() {
     410                $u1 = $this->factory->user->create();
     411                $u2 = $this->factory->user->create();
     412
     413                $t1 = $this->factory->message->create( array(
     414                        'sender_id' => $u1,
     415                        'recipients' => array( $u2 ),
     416                        'subject' => 'Foo',
     417                ) );
     418
     419                $thread = new BP_Messages_Thread( $t1 );
     420
     421                $this->assertEquals( 'Foo', $thread->last_message_subject );
     422                $this->assertEquals( $u1, $thread->last_sender_id );
     423        }
    405424}
  • src/bp-messages/bp-messages-template.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    18461846        public function __construct( $thread_id = 0, $order = 'ASC', $args = array() ) {
    18471847                $this->thread        = new BP_Messages_Thread( $thread_id, $order, $args );
    18481848                $this->message_count = count( $this->thread->messages );
    1849 
    1850                 $last_message_index                 = $this->message_count - 1;
    1851                 $this->thread->last_message_id      = $this->thread->messages[ $last_message_index ]->id;
    1852                 $this->thread->last_message_date    = $this->thread->messages[ $last_message_index ]->date_sent;
    1853                 $this->thread->last_sender_id       = $this->thread->messages[ $last_message_index ]->sender_id;
    1854                 $this->thread->last_message_subject = $this->thread->messages[ $last_message_index ]->subject;
    1855                 $this->thread->last_message_content = $this->thread->messages[ $last_message_index ]->message;
    18561849        }
    18571850
    18581851        /**
  • src/bp-messages/classes/class-bp-messages-thread.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    164164                        $this->messages = array_reverse( $this->messages );
    165165                }
    166166
     167                $last_message_index         = count( $this->messages ) - 1;
     168                $this->last_message_id      = $this->messages[ $last_message_index ]->id;
     169                $this->last_message_date    = $this->messages[ $last_message_index ]->date_sent;
     170                $this->last_sender_id       = $this->messages[ $last_message_index ]->sender_id;
     171                $this->last_message_subject = $this->messages[ $last_message_index ]->subject;
     172                $this->last_message_content = $this->messages[ $last_message_index ]->message;
     173
    167174                foreach ( (array) $this->messages as $key => $message ) {
    168175                        $this->sender_ids[ $message->sender_id ] = $message->sender_id;
    169176                }