Making WordPress.org

Changeset 15121


Ignore:
Timestamp:
09/01/2026 07:01:20 PM (2 months ago)
Author:
obenland
Message:

Support Forums: use the topic ID passed to user_can_resolve()

Closes ​https://github.com/WordPress/wordpress.org/pull/856.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins
Files:
3 edited

Legend:

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

    r15072 r15121  
    463463                        return $retval;
    464464                }
     465
     466                // The compat object is loaded from the request, not from $topic_id.
     467                $terms = get_the_terms( $topic_id, $this->taxonomy() );
     468                if ( empty( $terms ) || is_wp_error( $terms ) || ! in_array( (string) $this->slug(), wp_list_pluck( $terms, 'slug' ), true ) ) {
     469                        return $retval;
     470                }
     471
    465472                if (
    466473                        ( ! empty( $this->authors ) && in_array( $user->user_nicename, $this->authors, true ) )
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-support-compat.php

    r14963 r15121  
    329329         */
    330330        public function is_enabled_on_forum( $retval, $forum_id = 0 ) {
    331                 // Check the passed forum id.
     331                // An explicit forum id wins over whatever the request happens to be rendering.
    332332                if ( ! empty( $forum_id ) ) {
    333                         $retval = ( $forum_id != Plugin::REVIEWS_FORUM_ID );
     333                        return ( Plugin::REVIEWS_FORUM_ID !== (int) $forum_id );
    334334                }
    335335
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-topic-resolution/inc/class-plugin.php

    r12459 r15121  
    265265         */
    266266        public function topic_resolution_handler( $action = '' ) {
    267                 if ( ! $this->is_enabled_on_forum() ) {
    268                         return false;
    269                 }
    270 
    271267                // Bail if the action isn't meant for this function.
    272268                if ( $action != 'wporg_bbp_topic_resolution' ) {
    … …  
    284280                $user_id    = get_current_user_id();
    285281                $resolution = $_POST[ self::META_KEY ];
     282
     283                // Resolution must be enabled on the topic's forum, not on the one being viewed.
     284                if ( $topic && ! $this->is_enabled_on_forum( bbp_get_topic_forum_id( $topic->ID ) ) ) {
     285                        return false;
     286                }
    286287
    287288                // Check for empty topic id.
    … …  
    510511         */
    511512        public function user_can_resolve( $user_id, $topic_id ) {
    512                 $post     = false;
    513                 $topic_id = bbp_get_topic_id();
    514                 if ( $topic_id ) {
    515                         $post = get_post( $topic_id );
    516                 }
     513                // Authorize against the requested topic, only falling back to the displayed one.
     514                $topic_id = bbp_get_topic_id( $topic_id );
     515                $post     = $topic_id ? bbp_get_topic( $topic_id ) : false;
    517516
    518517                if ( $user_id && $post && ( user_can( $user_id, 'moderate', $topic_id ) || $user_id == $post->post_author ) ) {
Note: See TracChangeset for help on using the changeset viewer.