Skip to:
Content

Opened 4 years ago

Closed 4 years ago

#5736 closed enhancement (fixed)

messages_format_notifications(): variables not in scope

Reported by: wpdennis Owned by: boonebgorges
Milestone: 2.1 Priority: normal
Severity: normal Version:
Component: Messages Keywords: needs-patch good-first-bug
Cc:

Description

If messages_format_notifications() is used with any other action than "new_message", the variables $link, $filter and $text aren't declared before usage:


if ( 'string' === $format ) {
    $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 );
} else {
    $return = apply_filters( $filter, array(
        'text' => $text,
        'link' => $link
    ), $link, (int) $total_items, $text, $link, $item_id, $secondary_item_id );
}

Attachments (1)

5736.01.patch (881 bytes) - added by wolfhoundjesse 4 years ago.
Declarations moved to top of function.

Download all attachments as: .zip

Change History (7)

#1 @DJPaul
4 years ago

  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to 2.1
  • Type changed from defect (bug) to enhancement

#2 @DJPaul
4 years ago

Should be an easy fix for someone looking to contribute a patch: just need to make sure these variables are declared sensibly at the top of the file.

#3 @DJPaul
4 years ago

  • Milestone changed from 2.1 to 2.2

#4 @wolfhoundjesse
4 years ago

This comment replaces the comment I wrote before I remembered that there is a place to enter a patch description. That is all.

Last edited 4 years ago by wolfhoundjesse (previous) (diff)

@wolfhoundjesse
4 years ago

Declarations moved to top of function.

#5 @boonebgorges
4 years ago

  • Milestone changed from 2.2 to 2.1

#6 @boonebgorges
4 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 8947:

In messages_format_notifications(), declare variables early, to avoid PHP notices.

Fixes #5736

Props wolfhoundjesse

Note: See TracTickets for help on using tickets.