Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#32277 closed defect (bug) (duplicate)

get_comment_reply_link() uses $_SERVER['REQUEST_URI'] for post link, not the actual post's link.

Reported by: shelob9's profile Shelob9 Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.7
Component: Comments Keywords: has-patch needs-unit-tests
Focuses: template Cc:


When get_comment_reply_link() is used to get the reply link, not the login link, the post is generated from the use on ~L1416 of add_query_arg() without specifying a URL, so the value of $_SERVER['REQUEST_URI'] is used.

This works perfectly fine when the function is called during a request for a single post, but what if it is not? Then you end up with a link that makes very little sense.

2 scenarios to consider:
1) You call this function during an AJAX request. You end up with the AJAX API's URL as the base of the reply link URL. This is the actual scenario that led me to report/ patch this. The link is still valid, but it looks funny.
2) You want to output a reply link to post when not on a single post view. I don't know what happens then, but I could have a lot of fun with the ability to do so.

Attachments (1)

32277.diff (5.3 KB) - added by Shelob9 9 years ago.
use get_permalink() for post link

Download all attachments as: .zip

Change History (3)

9 years ago

use get_permalink() for post link

#1 @Shelob9
9 years ago

  • Keywords has-patch needs-unit-tests added

#2 @SergeyBiryukov
9 years ago

  • Component changed from General to Comments
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #31333.

Note: See TracTickets for help on using tickets.