Opened 9 years ago
Closed 9 years ago
#37607 closed defect (bug) (fixed)
get_site() does not return the current site when multisite is in a switched state
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.6 | Priority: | normal |
| Severity: | normal | Version: | 4.6 |
| Component: | Networks and Sites | Keywords: | has-patch has-unit-tests commit dev-reviewed |
| Focuses: | multisite | Cc: |
Description
get_site() uses the global $current_blog as a fallback if a site ID is not passed. When in a switched state via switch_to_blog(), this global continues to contain the original site information. If get_site() is called, then the originally loaded site will be returned, not that of the switched site.
$blog_id should be used instead as it is modified during switch_to_blog() and restore_current_blog().
Attachments (2)
Change History (11)
#3
@
9 years ago
- Keywords has-unit-tests added; needs-unit-tests removed
37607.2.diff adds a test showing the issue. This fails pre-patch.
#6
@
9 years ago
- Keywords dev-feedback added
Keeping this open for review before merging [38217] to the 4.6 branch.
#7
@
9 years ago
- Keywords commit dev-reviewed added; dev-feedback removed
[38217] looks good for the 4.6 branch.
This ticket was mentioned in Slack in #core-multisite by jeremyfelt. View the logs.
9 years ago
Note: See
TracTickets for help on using
tickets.
37607.diff makes the change from
global $current_blogtoget_current_blog_id().