Skip to:
Content

BuddyPress.org

Ticket #4415: 4415.patch

File 4415.patch, 2.3 KB (added by boonebgorges, 12 years ago)
  • bp-core/bp-core-catchuri.php

    diff --git bp-core/bp-core-catchuri.php bp-core/bp-core-catchuri.php
    index 28388bb..a8aa964 100644
    function _bp_maybe_remove_redirect_canonical() { 
    681681add_action( 'bp_init', '_bp_maybe_remove_redirect_canonical' );
    682682
    683683/**
     684 * Rehook maybe_redirect_404() to run later than the default
     685 *
     686 * WordPress's maybe_redirect_404() allows admins on a multisite installation
     687 * to define 'NOBLOGREDIRECT', a URL to which 404 requests will be redirected.
     688 * maybe_redirect_404() is hooked to template_redirect at priority 10, which
     689 * creates a race condition with bp_template_redirect(), our piggyback hook.
     690 * Due to a legacy bug in BuddyPress, internal BP content (such as members and
     691 * groups) is marked 404 in $wp_query until bp_core_load_template(), when BP
     692 * manually overrides the automatic 404. However, the race condition with
     693 * maybe_redirect_404() means that this manual un-404-ing doesn't happen in
     694 * time, with the results that maybe_redirect_404() thinks that the page is
     695 * a legitimate 404, and redirects incorrectly to NOBLOGREDIRECT.
     696 *
     697 * By switching maybe_redirect_404() to catch at a higher priority, we avoid
     698 * the race condition. If bp_core_load_template() runs, it dies before reaching
     699 * maybe_redirect_404(). If bp_core_load_template() does not run, it means that
     700 * the 404 is legitimate, and maybe_redirect_404() can proceed as expected.
     701 *
     702 * This function will be removed in a later version of BuddyPress. Plugins
     703 * (and plugin authors!) should ignore it.
     704 *
     705 * @since 1.6.1
     706 *
     707 * @link http://buddypress.trac.wordpress.org/ticket/4329
     708 * @link http://buddypress.trac.wordpress.org/ticket/4415
     709 */
     710function _bp_rehook_maybe_redirect_404() {
     711        if ( defined( 'NOBLOGREDIRECT' ) ) {
     712                remove_action( 'template_redirect', 'maybe_redirect_404' );
     713                add_action( 'template_redirect', 'maybe_redirect_404', 100 );
     714        }
     715}
     716add_action( 'template_redirect', '_bp_rehook_maybe_redirect_404', 1 );
     717
     718/**
    684719 * Remove WordPress's rel=canonical HTML tag if we are trying to load BuddyPress
    685720 * specific content.
    686721 *
    function _bp_maybe_remove_rel_canonical() { 
    696731        }
    697732}
    698733add_action( 'wp_head', '_bp_maybe_remove_rel_canonical', 8 );
    699 ?>
    700  No newline at end of file
     734?>