Skip to:
Content

BuddyPress.org

Opened 7 years ago

Closed 5 weeks ago

#4154 closed defect (bug) (fixed)

BuddyPress not allow use search like domain.com/search/my+search+text

Reported by: Ivinco Owned by: imath
Milestone: 5.0.0 Priority: normal
Severity: major Version: 1.5.5
Component: Route Parser Keywords: has-patch
Cc: darrenmeehan

Description (last modified by imath)

Default wordpress Installation allows to search via url like domain.com/search/my+search+text
BuddyPress don't allow these searches.

I fixed this bug, but maybe is not the best way.

[ 15:11:12 ] :> diff -u bp-core-catchuri-org.php bp-core-catchuri.php 
--- bp-core-catchuri-org.php    2012-04-19 15:10:37.000000000 +0300
+++ bp-core-catchuri.php    2012-04-19 15:10:49.000000000 +0300
@@ -375,6 +375,9 @@
 function bp_core_catch_no_access() {
    global $bp, $bp_no_status_set, $wp_query;
 
+        if ($bp->current_component == 'search') {
+            return true;
+        }
    // If bp_core_redirect() and $bp_no_status_set is true,
    // we are redirecting to an accessible page, so skip this check.
    if ( $bp_no_status_set )


[15:13:56 ] :> diff -u bp-core-functions-org.php bp-core-functions.php 
--- bp-core-functions-org.php   2012-04-19 14:55:11.000000000 +0300
+++ bp-core-functions.php   2012-04-19 14:55:57.000000000 +0300
@@ -825,6 +825,10 @@
  */
 function bp_core_action_search_site( $slug = '' ) {
    global $bp;
+        
+        if ($bp->current_component == 'search') {
+            return;
+        }
 
    if ( !bp_is_current_component( bp_get_search_slug() ) )
        return;

Attachments (2)

4154.diff (1.7 KB) - added by ericlewis 7 years ago.
Cleaned up Invinco's implementation a bit; added respect for custom title in bp_modify_page_title
4154.2.patch (588 bytes) - added by imath 8 weeks ago.

Download all attachments as: .zip

Change History (13)

#1 @DJPaul
7 years ago

  • Milestone changed from Awaiting Review to 1.6

@ericlewis
7 years ago

Cleaned up Invinco's implementation a bit; added respect for custom title in bp_modify_page_title

#2 @DJPaul
7 years ago

  • Keywords reporter-feedback added

I think it's really bad that we're using /search/ as a search handler, and that it's stomping all over WordPress query var of the same name. How about we get rid of it.

#3 @boonebgorges
7 years ago

DJPaul - What kind of backward compatibility problems will this introduce?

#4 @DJPaul
7 years ago

Lots? The search box in BP-Default's header (all the way back to 1.2) sends a POST to /search/, which we then redirect to the component's index page, with the query passed. bp_core_action_search_site()

#5 @boonebgorges
7 years ago

I'm less concerned with what we do in BuddyPress (since we can easily rewrite our own search boxes to go to ?s= or whatever) than with what will happen with third party plugins and themes. Is there a way that we can do away with the 'search' hijacking without also breaking old implementations? Here's one idea: Instead of grabbing all requests to '/search/', only grab those that have $_POST data, throw a deprecated notice, and redirect to whatever our replacement solution is. (That won't make example.com/search/foo work, but did it ever?)

#6 @DJPaul
7 years ago

  • Keywords needs-patch added; has-patch reporter-feedback removed

I think checking POST is a good idea; if we set any BP-specific keys, we can check for those specifically. I'm pretty sure BuddyPress Default Theme has always used POST for that form submission, rather than GET. It might help us get rid of the BP_SEARCH_SLUG fake Url

#7 @DJPaul
7 years ago

I'm thinking removing our fake search URL could cause problems with other BP plugins that have copied our implementation detail. It's better to do that at the start of 1.7 so there is enough time to test it properly.

#8 @boonebgorges
7 years ago

  • Milestone changed from 1.6 to Future Release

Sold.

#9 @darrenmeehan
7 years ago

  • Cc darrenmeehan added
  • Keywords needs-refresh added

Is this something that should be discussed now? I need to look more into what this will involve, but if I feel my skills are up to this, I'd like to help.

#10 @imath
8 weeks ago

  • Component changed from Core to Route Parser
  • Description modified (diff)
  • Keywords has-patch added; needs-patch needs-refresh removed
  • Milestone changed from Awaiting Contributions to 5.0.0

Hi!

I think the least we need to do is to stop preventing WordPress to use site.url/search/hello pretty urls. It's not good. I think checking if $_POST['search-terms'] is set won't break plugins as anyway bp_core_action_search_site() is redirecting to home if it's empty.

@imath
8 weeks ago

#11 @imath
5 weeks ago

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

In 12404:

Do not interfere with WordPress "pretty URL" search slug

Props Ivinco, ericlewis

Fixes #4154

Note: See TracTickets for help on using tickets.