Opened 10 years ago
Closed 10 years ago
#37607 closed defect (bug) (fixed)
get_site() does not return the current site when multisite is in a switched state
| Reported by: | jeremyfelt | Owned by: | jeremyfelt |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.6 |
| Component: | Networks and Sites | Version: | 4.6 |
| Severity: | normal | Keywords: | has-patch has-unit-tests commit dev-reviewed |
| Cc: | Focuses: | multisite |
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
@
10 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
@
10 years ago
- Keywords dev-feedback added
Keeping this open for review before merging [38217] to the 4.6 branch.
#7
@
10 years ago
- Keywords commit dev-reviewed added; dev-feedback removed
[38217] looks good for the 4.6 branch.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
37607.diff makes the change from
global $current_blogtoget_current_blog_id().