Opened 6 years ago
Closed 5 years ago
#45594 closed enhancement (fixed)
Action 'switch_blog' duplicated $new_blog param
Reported by: | ChriCo | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.3 | Priority: | normal |
Severity: | normal | Version: | 5.0 |
Component: | Networks and Sites | Keywords: | has-patch needs-testing |
Focuses: | multisite | Cc: |
Description
The action 'switch_blog' which can be found in wp-includes/ms-blogs.php L1660 has two times $new_blog
injected, while the Doc Block says:
<?php * @param int $new_blog New blog ID. * @param int $new_blog Blog ID.
This is maybe - in this context - correct, since in L1651 we're checking for if ( $new_blog == $blog_id )
before doing the action.
But regarding correctness, it should be $new_blog
and $prev_blog_id
(as declared after the if-statement) as param and in docBlocks (for generation of documentation).
My patch...
- renames
$blog_id
into$prev_blog_id
. - updates the docBlock for the action 'switch_blog'.
- update third param in 'switch_blog' to
$prev_blog_id
. - removes the not required
$prev_blog_id = $blog_id
.
Attachments (1)
Change History (9)
#2
follow-up:
↓ 3
@
6 years ago
- Focuses multisite added
- Milestone changed from Awaiting Review to Future Release
#3
in reply to:
↑ 2
@
6 years ago
Replying to jeremyfelt:
I think we can remove
$prev_blog_id
entirely and change both action calls todo_action( 'switch_blog', $new_blog, $blog_id );
Thanks for your feedback. My intention was to name it in way everyone can understand it and also in terms of automatic generation of documentation out of docblocks. The var name $blog_id
is not very exact here. Is it the current, new or previous one?
#4
@
6 years ago
Howdy,
any news here? The patch is working so far, so it needs only an "approved" or "not approved".
#5
@
5 years ago
@jeremyfelt any news here? This is already over a half year ago and just a small "fix" in terms of rename internal used variables and update of a DocBlock of the action switch_blog
. Any blocker here?
#6
@
5 years ago
- Milestone changed from Future Release to 5.3
- Owner set to SergeyBiryukov
- Status changed from new to reviewing
Thanks, @ChriCo, some consistency in docs and parameters makes sense here. I'm wondering if we can do this with a smaller change.
The
$prev_blog_id
parameter was populated with$GLOBALS['blog_id']
until [38457]. It now serves less of a purpose because there is no worry of the global being overwritten on the next line.I think we can remove
$prev_blog_id
entirely and change both action calls todo_action( 'switch_blog', $new_blog, $blog_id );