Skip to:
Content

bbPress.org

Opened 13 years ago

Closed 13 years ago

#2155 closed defect (bug) (fixed)

Fix Current URL in bbp_redirect_to_field()

Reported by: alex-ye's profile alex-ye Owned by:
Milestone: 2.3 Priority: normal
Severity: normal Version: 2.2.3
Component: Tools - Code Improvements Keywords: has-patch needs-testing dev-feedback
Cc: alexvornoffice@…, nashwan.doaqan@…

Description

Hi Guys , I just found this small bug in bbPress ...

bbp_redirect_to_field() Function doesn't work when the WordPress in sub-folder , because of using WordPress home_url() function , bbp_redirect_to_field() can't guess the correct current URL ...

Example :
if current URL is "http://localhost/wp/page" the bbp_redirect_to_field() redirect you to "http://localhost/wp/wp/page" .

Tested On :
WordPess 3.5
bbPress 2.2.3
PHP 5.4.3

Attachments (3)

template-tags.patch (487 bytes) - added by alex-ye 13 years ago.
template-tags.php.patch (946 bytes) - added by alex-ye 13 years ago.
template-tags-3.php.patch (1.2 KB) - added by alex-ye 13 years ago.

Download all attachments as: .zip

Change History (19)

#1 @johnjamesjacoby
13 years ago

  • Milestone changed from Awaiting Review to 2.3

#2 follow-up: @alexvorn2
13 years ago

  • Component changed from General to Code Improvement
  • Keywords needs-patch added; has-patch removed
  • Version changed from trunk to 2.2.3

related #1835,

this patch is not good, because it breaks another fix...
https://bbpress.trac.wordpress.org/attachment/ticket/1835/1835.diff

Last edited 13 years ago by alexvorn2 (previous) (diff)

#3 @alexvorn2
13 years ago

  • Cc alexvornoffice@… added

#4 in reply to: ↑ 2 @alex-ye
13 years ago

  • Keywords has-patch added; needs-patch removed

Replying to alexvorn2:

this patch is not good, because it breaks another fix...
https://bbpress.trac.wordpress.org/attachment/ticket/1835/1835.diff

I have added a patch file that uses wp_get_referer() function :)

#5 @alexvorn2
13 years ago

  • Keywords needs-testing added

#6 follow-up: @alexvorn2
13 years ago

why not use home_url function?

#7 in reply to: ↑ 6 @alex-ye
13 years ago

Replying to alexvorn2:

why not use home_url function?

I describe the problem above , as you see home_url() function returns a the website home link like localhost/bbp , and REQUEST_URL return the URI which was given in order to access this page like /bbp/post-title/

So passing REQUEST_URL to home_url() return wrong URL localhost/bbp/bbp/post-title/

#8 follow-up: @alexvorn2
13 years ago

what about site_url() function? can you test if it works well here?

#9 @alexvorn2
13 years ago

  • Keywords reporter-feedback added

#10 in reply to: ↑ 8 @alex-ye
13 years ago

  • Keywords reporter-feedback removed

Replying to alexvorn2:

what about site_url() function? can you test if it works well here?

Remember that site_url() can return the same as home_url() in most cases :)

see :

http://codex.wordpress.org/Function_Reference/site_url

http://codex.wordpress.org/Function_Reference/home_url

Last edited 13 years ago by alex-ye (previous) (diff)

#11 follow-up: @alexvorn2
13 years ago

yeap, but it should work I think...

anyway, there must be a function, not a

$_SERVER['HTTP_HOST']

variable

#12 @alexvorn2
13 years ago

  • Keywords dev-feedback added

#13 in reply to: ↑ 11 @alex-ye
13 years ago

Replying to alexvorn2:

yeap, but it should work I think...

anyway, there must be a function, not a

$_SERVER['HTTP_HOST']

variable

there are no must :) , The code I write above is from the WordPress core and bbPress core too , and it writed in many plugins and themes :)

Why are you feel bad of using HTTP_HOST ?!

#14 @alex-ye
13 years ago

  • Cc nashwan.doaqan@… added

#15 @apet083
13 years ago

Hi everyone, I thought I would update you on my experience with this problem. I have spent MONTHS finding a reason and a fix for why my bbPress forum would redirect users to random places when replying to a post. I noticed the URL was being rewritten wrongly - see http://bbpress.org/forums/topic/forum-reply-redirect-url-rewrite-issue/#post-125384

Anyway, I implemented the patch that @alex-ye added and my replies were redirected correctly! Am very relieved and thankful :)
My WordPress was setup on Windows 7/IIS 7.5/PHP 5.3/MySQL 5.1 with the latest version of WordPress and bbPress.

#16 @johnjamesjacoby
13 years ago

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

(In [4700]) Update bbp_redirect_to_field() to not use home_url(), and instead use super globals. Props alex-ye. Fixes #2155.

Note: See TracTickets for help on using tickets.