Skip to:
Content

BuddyPress.org

Changeset 8616


Ignore:
Timestamp:
07/15/2014 09:59:17 PM (5 years ago)
Author:
johnjamesjacoby
Message:

In messages_format_notifications(), check that thread ID exists before attempting to link to it. Fixes debug notices and incorrect links when a message thread is deleted before notifications are marked as read.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/bp-messages-notifications.php

    r8568 r8616  
    129129
    130130        if ( (int) $total_items > 1 ) {
    131             $text   = sprintf( __('You have %d new messages', 'buddypress' ), (int) $total_items );
     131            $text   = sprintf( __( 'You have %d new messages', 'buddypress' ), (int) $total_items );
    132132            $filter = 'bp_messages_multiple_new_message_notification';
    133133        } else {
     
    135135            $message   = new BP_Messages_Message( $item_id );
    136136            $thread_id = $message->thread_id;
    137 
    138             $link = bp_get_message_thread_view_link( $thread_id );
     137            $link      = ( ! empty( $thread_id ) )
     138                ? bp_get_message_thread_view_link( $thread_id )
     139                : false;
    139140
    140141            if ( ! empty( $secondary_item_id ) ) {
     
    148149
    149150    if ( 'string' === $format ) {
    150         $return = apply_filters( $filter, '<a href="' . esc_url( $link ) . '" title="' . esc_attr( $title ) . '">' . esc_html( $text ) . '</a>', (int) $total_items, $text, $link, $item_id, $secondary_item_id );
     151        if ( ! empty( $link ) ) {
     152            $retval = '<a href="' . esc_url( $link ) . '" title="' . esc_attr( $title ) . '">' . esc_html( $text ) . '</a>';
     153        } else {
     154            $retval = esc_html( $text );
     155        }
     156        $return = apply_filters( $filter, $retval, (int) $total_items, $text, $link, $item_id, $secondary_item_id );
    151157    } else {
    152158        $return = apply_filters( $filter, array(
Note: See TracChangeset for help on using the changeset viewer.