Skip to:
Content

BuddyPress.org

Opened 6 months ago

Closed 5 months ago

#9192 closed defect (bug) (fixed)

Subpages of the Members directory

Reported by: dontdream's profile dontdream Owned by: imath's profile imath
Milestone: 14.0.0 Priority: normal
Severity: normal Version: 12.0.0
Component: Route Parser Keywords: has-patch
Cc:

Description

Hello team,

Recently a user reported a problem with subpages of the Members directory, see:

https://wordpress.org/support/topic/only-works-if-the-form-page-is-at-root-level/

To reproduce, use a fresh WordPress installation, with only BuddyPress and BP Classic.

Make sure the rewrite rules are flushed and create a subpage of the Members directory.

If you try to view that page, you are redirected to your home page.

I think this happens because the new BP 12 rewrite rules are added even when BP Classic is activated. Then any subpage of the Members directory matches one of the new rules, thus causing the problem.

Attachments (2)

class-bp-component.php.patch (521 bytes) - added by dontdream 6 months ago.
don't add the new rewrite rules when BP Classic is active
class-bp-component.php.patch2 (580 bytes) - added by dontdream 5 months ago.
restore add_rewrite_rules() to its pre-version 12 state when BP Classic is active

Download all attachments as: .zip

Change History (14)

#1 @imath
6 months ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Up Next

Hi @dontdream

Thanks a lot for your feedback, I look at it during 15.0.0 development cycle. There’s another ticket about being able to use sub pages without BP Classic so I’ll work on both. I’m very open to review patches or PR to have it fixed faster. Don’t hesitate to contribute or invite others to do so 😰

#2 @dontdream
6 months ago

  • Keywords has-patch added; needs-patch removed

Hi imath,

I think we can avoid adding the new rewrite rules if BP Classic is active. The attached patch works for me, although it's probably not the best solution.

After applying this patch, I have to manually flush the rules, whereas during a standard BuddyPress update the rules will likely be flushed automatically.

@dontdream
6 months ago

don't add the new rewrite rules when BP Classic is active

#3 @AdventureRidingNZ
5 months ago

@imath What is the timeline of the 15.0.0 development cycle?

#4 @imath
5 months ago

Hi @AdventureRidingNZ

We haven’t set it yet, but I’d really like it to be released before the end of the year.

#5 @imath
5 months ago

Hi @dontdream Thanks a lot for your patch 😍

You're right: I believe it's a bit more complex as other plugins can use the BP Component to generate their rewrites rules even when BP Classic being active. This method is there since 1.9.0 😬.

#6 @AdventureRidingNZ
5 months ago

Oh wow, I guess I better install the patch then otherwise lots of features will be broken until then.

#7 @AdventureRidingNZ
5 months ago

So I downloaded the Zip file, uploaded it to /buddypress/bp-core/classes/
then renamed my original file as class-bp-component.php.original and renamed the .patch file as class-bp-component.php and I got the below error message.

Index: class-bp-component.php =================================================================== --- class-bp-component.php (revision 13931) +++ class-bp-component.php (working copy) @@ -1119,6 +1119,11 @@ * } */ public function add_rewrite_rules( $rewrite_rules = array() ) { + + if ( 'rewrites' !== bp_core_get_query_parser() ) { + return; + } + if ( array_filter( $this->rewrite_ids ) ) { $priority = 'top'; $chunks = array_merge( bp_rewrites_get_default_url_chunks(), $rewrite_rules );
There has been a critical error on this website.

I'm running Wordpress 6.5.5, Buddypress 12.5.1, BP Classic 1.4.0, all the latest versions.
An example page where I am having the issue, this should show my sites privacy policy:
https://www.adventureridingnz.co.nz/members/advrnz-privacy-policy/

Last edited 5 months ago by AdventureRidingNZ (previous) (diff)

#8 @dontdream
5 months ago

Hello @AdventureRidingNZ,

I've added a reply to your original forum topic:

https://wordpress.org/support/topic/only-works-if-the-form-page-is-at-root-level/

#9 @dontdream
5 months ago

This second patch fully restores add_rewrite_rules() in BP_Component to its pre-version 12 state (only when BP Classic is active).

@dontdream
5 months ago

restore add_rewrite_rules() to its pre-version 12 state when BP Classic is active

#10 @imath
5 months ago

  • Milestone changed from Up Next to 14.0.0

Hi @dontdream,

Thanks for contributing again and insisting on the subject. We'll have it fixed for 14.0.0. I made some tests, will add a PR to this tickets soon, & it it's fine with our PHP Unit tests, I'll commit the fix.

This ticket was mentioned in PR #325 on buddypress/buddypress by imath.


5 months ago
#11

Make sure the BP Query Parser in use is 'rewrites' before generating BP Rewrite rules

Trac ticket: https://buddypress.trac.wordpress.org/ticket/9192

#12 @imath
5 months ago

  • Owner set to imath
  • Resolution set to fixed
  • Status changed from new to closed

In 13943:

Only generate rewrite rules when the BP Query Parser is 'rewrites'

Props dontdream

Fixes #9192
Closes https://github.com/buddypress/buddypress/pull/325

Note: See TracTickets for help on using tickets.