Making WordPress.org


Ignore:
Timestamp:
07/19/2019 03:51:20 AM (7 years ago)
Author:
dd32
Message:

Support Forums: /topic/0/ isn't a valid url - It seems that bbPress isn't catching that this is a topic request and doesn't properly handle the request.

This change forces canonical to kick in instead, as the empty QVs are no longer set.

Fixes #4547.

File:
1 edited

Legend:

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

    r8695 r9066  
    100100                // Deindex Support Forum Feeds. bbPress hooks in way earlier than most Core feed functions..
    101101                add_filter( 'request', array( $this, 'deindex_forum_feeds' ), 5 );
     102
     103                add_filter( 'request', array( $this, 'ignore_empty_query_vars' ) );
     104
    102105        }
    103106
     
    971974                return $query_vars;
    972975        }
     976
     977        /**
     978         * Ignore certain empty set query vars.
     979         *
     980         * TODO: This is probably a bbPress bug in that it doesn't handle "empty" QVs well.
     981         */
     982        function ignore_empty_query_vars( $query_vars ) {
     983                // bbPress query vars that sometimes have weird urls as a result.
     984                $ignore_emptyish_values = [ 'topic', 'reply', 'forum', 'topic-tag', 'bbp_view' ];
     985
     986                foreach ( $ignore_emptyish_values as $q ) {
     987                        if ( isset( $query_vars[ $q ] ) && empty( $query_vars[ $q ] ) ) {
     988                                // It's set, but empty so not a useful QV?
     989                                unset( $query_vars[ $q ] );
     990                        }
     991                }
     992
     993                return $query_vars;
     994        }
     995
    973996}
Note: See TracChangeset for help on using the changeset viewer.