Skip to:
Content

BuddyPress.org

Ticket #8505: 8505-review.patch

File 8505-review.patch, 1.6 KB (added by imath, 5 years ago)
  • src/bp-messages/bp-messages-functions.php

    diff --git src/bp-messages/bp-messages-functions.php src/bp-messages/bp-messages-functions.php
    index 07b45fb3b..56a1b2193 100644
    function bp_messages_dismiss_sitewide_notice( $user_id = 0, $notice_id = 0 ) { 
    757757        if ( ! $user_id ) {
    758758                $user_id = bp_loggedin_user_id();
    759759        }
     760
    760761        // Bail if no user is set.
    761762        if ( ! $user_id ) {
    762763                return $retval;
    function bp_messages_dismiss_sitewide_notice( $user_id = 0, $notice_id = 0 ) { 
    767768        } else {
    768769                $notice = BP_Messages_Notice::get_active();
    769770        }
     771
    770772        // Bail if no notice is set.
    771773        if ( empty( $notice->id ) ) {
    772774                return $retval;
    773775        }
    774776
    775777        // Fetch the user's closed notices and add the new item.
    776         $closed_notices = bp_get_user_meta( $user_id, 'closed_notices', true );
    777         if ( empty( $closed_notices ) || ! is_array( $closed_notices ) ) {
    778                 $closed_notices = array();
    779         }
     778        $closed_notices = (array) bp_get_user_meta( $user_id, 'closed_notices', true );
    780779
    781780        if ( in_array( (int) $notice->id, $closed_notices, true ) ) {
    782781                // The notice has already been dismissed, so there's nothing to do.
    function bp_messages_dismiss_sitewide_notice( $user_id = 0, $notice_id = 0 ) { 
    786785                $closed_notices[] = (int) $notice->id;
    787786                $closed_notices   = array_map( 'absint', array_unique( $closed_notices ) );
    788787                $success          = bp_update_user_meta( $user_id, 'closed_notices', $closed_notices );
     788
    789789                // The return value from update_user_meta() could be an integer or a boolean.
    790790                $retval = (bool) $success;
    791791        }