Make WordPress Core

Opened 17 months ago

Closed 7 weeks ago

#44825 closed defect (bug) (invalid)

get_rest_url does not respect query args added to get_home_url

Reported by: distinct Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: REST API Keywords: reporter-feedback close
Focuses: Cc:
PR Number:



This line appends the rest $path to the result of get_home_url, which can be modified by any plugin to have query arguments.

An easy way to fix it is to just append the $path to the parameter to get_home_url itself

//line 315 and further
if ( $wp_rewrite->using_index_permalinks() ) {
  $url = get_home_url( $blog_id, $wp_rewrite->index . '/' . rest_get_url_prefix() . $path, $scheme );
} else {
  $url = get_home_url( $blog_id, rest_get_url_prefix() . $path, $scheme );

Hope this helps.

Change History (6)

#1 @SergeyBiryukov
17 months ago

  • Component changed from General to REST API

#2 @pento
12 months ago

  • Version trunk deleted

This ticket was mentioned in Slack in #core-restapi by timothybjacobs. View the logs.

7 months ago

#4 @TimothyBlynJacobs
7 months ago

  • Keywords reporter-feedback added

@distinct could you expand a bit more on your use case? Does your home URL always have query parameters in order for your website to load at all?

My initial thoughts are that particular query params on the home URL shouldn't be added to the REST API as well. There is also a high chance of conflicting with the various REST API collection params.

#5 @TimothyBlynJacobs
2 months ago

  • Keywords close added

#6 @TimothyBlynJacobs
7 weeks ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Closing based on my earlier comment. @distinct please feel free to comment with your use case even if the ticket is closed and we can reevaluate.

Note: See TracTickets for help on using tickets.