Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#37053 closed enhancement (fixed)

Ensure `get_site_by_path()` returns a `WP_Site`

Reported by: flixos90's profile flixos90 Owned by: jeremyfelt's profile jeremyfelt
Milestone: 4.7 Priority: normal
Severity: normal Version: 4.6
Component: Networks and Sites Keywords: has-patch has-unit-tests
Focuses: docs, multisite Cc:

Description

When using the filter pre_get_sites_by_path, the return value might possibly be a raw site object. Let's ensure it is turned into a WP_Site instance.

Attachments (2)

37053.diff (1.9 KB) - added by flixos90 8 years ago.
37053.2.diff (3.2 KB) - added by flixos90 8 years ago.

Download all attachments as: .zip

Change History (10)

@flixos90
8 years ago

#1 @flixos90
8 years ago

  • Keywords has-patch added; needs-patch removed

@flixos90
8 years ago

#2 follow-up: @flixos90
8 years ago

  • Focuses docs added
  • Keywords has-unit-tests added
  • Milestone changed from Awaiting Review to 4.7
  • Owner set to jeremyfelt
  • Status changed from new to reviewing
  • Type changed from defect (bug) to enhancement
  • Version changed from 3.9 to 4.6

37053.2.diff is an updated patch, including a unit test for when using the filter to short-circuit.

#3 @jorbin
8 years ago

@jeremyfelt what are you thoughts on this one?

This ticket was mentioned in Slack in #core by desrosj. View the logs.


8 years ago

#5 @desrosj
8 years ago

  • Keywords needs-testing added

This is most of the way there. Just needs some feedback if it will land in 4.7.

This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.


8 years ago

#7 in reply to: ↑ 2 @jeremyfelt
8 years ago

  • Keywords needs-testing removed

Replying to flixos90:

37053.2.diff is an updated patch, including a unit test for when using the filter to short-circuit.

This looks great, thanks @flixos90. I removed the removal of the todo doc. We should address that in another ticket with the docs in the paragraph just above as well. There are some things that are still relevant and some that aren't.

#8 @jeremyfelt
8 years ago

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

In 38681:

Multisite: Ensure a consistent WP_Site return from get_site_by_path().

It is possible to short circuit get_site_by_path() using the pre_get_site_by_path filter. When this happens and a standard site object is provided, we can make sure it is upgraded to a proper WP_Site object before passing it on.

Props flixos90.
Fixes #37053.

Note: See TracTickets for help on using tickets.