Skip to:
Content

BuddyPress.org

Changeset 4124


Ignore:
Timestamp:
03/12/2011 12:32:15 AM (13 years ago)
Author:
djpaul
Message:

Correctly handle invalid forum permalinks. Also fixes a couple of PHP notices. Fixes #2349.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-forums/bp-forums-template.php

    r4088 r4124  
    899899    extract( $r, EXTR_SKIP );
    900900
    901     if ( empty( $topic_id ) && bp_is_current_component( 'groups') && bp_is_current_action( 'forum' ) && 'topic' == $bp->action_variables[0] )
     901    if ( empty( $topic_id ) && bp_is_current_component( 'groups') && bp_is_current_action( 'forum' ) && !empty( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] && !empty( $bp->action_variables[1] ) )
    902902        $topic_id = bp_forums_get_topic_id_from_slug( $bp->action_variables[1] );
    903903    elseif ( empty( $topic_id ) && bp_is_current_component( 'forums') && bp_is_current_action( 'topic' ) && !empty( $bp->action_variables[0] ) )
    904904        $topic_id = bp_forums_get_topic_id_from_slug( $bp->action_variables[0] );
    905905
    906     if ( is_numeric( $topic_id ) ) {
    907         $topic_template = new BP_Forums_Template_Topic( $topic_id, $per_page, $max, $order );
     906    if ( empty( $topic_id ) ) {
     907        return false;
     908
     909    } else {
     910        $topic_template = new BP_Forums_Template_Topic( (int) $topic_id, $per_page, $max, $order );
    908911
    909912        // Current topic forum_id needs to match current_group forum_id
    910913        if ( bp_is_current_component( 'groups' ) && $topic_template->forum_id != groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ) )
    911914            return false;
    912 
    913     } else {
    914         return false;
    915915    }
    916916
  • trunk/bp-groups/bp-groups-screens.php

    r4088 r4124  
    104104
    105105function groups_screen_group_forum() {
    106     global $bp;
     106    global $bp, $wp_query;
    107107
    108108    if ( bp_is_single_item() && $bp->groups->current_group->user_has_access ) {
    109109
    110110        // Fetch the details we need
    111         $topic_slug     = isset( $bp->action_variables[1] ) ? $bp->action_variables[1] : false;
     111        $topic_slug     = !empty( $bp->action_variables[1] ) ? $bp->action_variables[1] : false;
    112112        $topic_id       = bp_forums_get_topic_id_from_slug( $topic_slug );
    113113        $forum_id       = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' );
     
    302302                bp_core_load_template( apply_filters( 'groups_template_group_forum_topic', 'groups/single/home' ) );
    303303            }
     304
     305        // Forum topic does not exist
     306        } elseif ( !empty( $topic_slug ) && empty( $topic_id ) ) {
     307            $wp_query->set_404();
     308            status_header( 404 );
     309            nocache_headers();
     310            return;
    304311
    305312        } else {
Note: See TracChangeset for help on using the changeset viewer.