WordPress.org

Making WordPress.org

Changeset 10640


Ignore:
Timestamp:
02/03/2021 05:51:21 AM (3 months ago)
Author:
dd32
Message:

Support Forums: Treat the archived post status as a pending post status via bbp_is_topic_pending() to ensure that bbPress doesn't attempt to run user_trailingslashit() on a non-pretty url.

Fixes moderators hitting a 400/403 error page when performing actions on archived threads.
See https://wordpress.slack.com/archives/C02QB8GMM/p1612273746169300.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-moderators.php

    r10610 r10640  
    3333        add_filter( 'bbp_after_has_topics_parse_args',  array( $this, 'add_post_status_to_query' ) );
    3434        add_filter( 'bbp_after_has_replies_parse_args', array( $this, 'add_post_status_to_query' ) );
     35        add_filter( 'bbp_is_topic_pending',             array( $this, 'archived_is_pending_topic' ), 10, 2 );
    3536
    3637        // Adjust the list of admin links for topics and replies.
     
    10381039        update_post_meta( $post_id, self::MODERATOR_META, wp_get_current_user()->user_nicename );
    10391040    }
     1041
     1042    /**
     1043     * Treat the archived status as a pending status to ensure that bbp_get_reply_url() doesn't slash a non-pretty url.
     1044     *
     1045     * @param bool $topic_status Whether the topic is pending.
     1046     * @param int  $topic_id     The topic ID.
     1047     * @return bool
     1048     */
     1049    public function archived_is_pending_topic( $topic_status, $topic_id ) {
     1050        if (
     1051            ! $topic_status &&
     1052            ( bbp_get_topic_status( $topic_id ) === self::ARCHIVED )
     1053        ) {
     1054            $topic_status = true;
     1055        }
     1056
     1057        return $topic_status;
     1058    }
    10401059}
Note: See TracChangeset for help on using the changeset viewer.