Skip to:
Content

Ticket #7523: 7523.deleted.patch

File 7523.deleted.patch, 2.4 KB (added by r-a-y, 12 months ago)
  • src/bp-members/bp-members-functions.php

     
    206206 *
    207207 * @since 1.2.0
    208208 *
    209  * @param int $user_id The ID of the user.
    210  * @return array
     209 * @param  int $user_id The ID of the user.
     210 * @return array|bool Array of data on success, boolean false on failure.
    211211 */
    212212function bp_core_get_core_userdata( $user_id = 0 ) {
    213213        if ( empty( $user_id ) ) {
    214214                return false;
    215215        }
    216216
    217         if ( !$userdata = wp_cache_get( 'bp_core_userdata_' . $user_id, 'bp' ) ) {
     217        $userdata = wp_cache_get( 'bp_core_userdata_' . $user_id, 'bp' );
     218
     219        // No cache.
     220        if ( false === $userdata ) {
    218221                $userdata = BP_Core_User::get_core_userdata( $user_id );
    219                 wp_cache_set( 'bp_core_userdata_' . $user_id, $userdata, 'bp' );
     222
     223                // Cache data; no-result is cached as integer 0.
     224                wp_cache_set( 'bp_core_userdata_' . $user_id, false === $userdata ? 0 : $userdata, 'bp' );
     225
     226        // Cached no-result, so set return value as false as expected.
     227        } elseif ( 0 === $userdata ) {
     228                $userdata = false;
    220229        }
    221230
    222231        /**
     
    224233         *
    225234         * @since 1.2.0
    226235         *
    227          * @param array $userdata Array of user data for a passed user.
     236         * @param array|bool $userdata Array of user data for a passed user on success, boolean false on failure.
    228237         */
    229238        return apply_filters( 'bp_core_get_core_userdata', $userdata );
    230239}
  • src/bp-messages/bp-messages-template.php

     
    19961996        function bp_get_the_thread_message_content() {
    19971997                global $thread_template;
    19981998
     1999                $content = $thread_template->message->message;
     2000
     2001                // If user was deleted, mark content as deleted.
     2002                if ( false === bp_core_get_core_userdata( bp_get_the_thread_message_sender_id() ) ) {
     2003                        $content = esc_html__( '[deleted]', 'buddypress' );
     2004                }
     2005
    19992006                /**
    20002007                 * Filters the content of the current message in the loop.
    20012008                 *
     
    20032010                 *
    20042011                 * @param string $message The content of the current message in the loop.
    20052012                 */
    2006                 return apply_filters( 'bp_get_the_thread_message_content', $thread_template->message->message );
     2013                return apply_filters( 'bp_get_the_thread_message_content', $content );
    20072014        }
    20082015
    20092016/** Embeds *******************************************************************/