Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#37615 closed defect (bug) (fixed)

Do not pass `$site` and `$network` by reference in `get_*()` functions

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

Description

In get_site(), the $site parameter is passed by reference, which doesn't make a lot of sense. Same for the $network parameter in get_network(). Objects are passed by reference anyway, but passing for example the ID by reference could possibly lead to unexpected results.

Attachments (2)

37615.diff (1.3 KB) - added by flixos90 8 years ago.
37615.2.diff (1.3 KB) - added by jeremyfelt 8 years ago.

Download all attachments as: .zip

Change History (7)

@flixos90
8 years ago

@jeremyfelt
8 years ago

#1 @flixos90
8 years ago

  • Keywords has-patch added; needs-patch removed

37615.diff adjust that. The patch also adjust a similar issue in update_site_cache(), and fixes the docs for the $network parameter of get_network() (previously didn't mention the default value).

#2 @jeremyfelt
8 years ago

  • Owner set to jeremyfelt
  • Status changed from new to accepted

Looks good. I don't think there's a reason for us to pass by reference here. I'm going to hold off on committing to trunk until we're good for 4.6 as well. Pinging @ocean90 for review. :)

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


8 years ago

#4 @jeremyfelt
8 years ago

In 38232:

Multisite: Remove unnecessary reference parameters.

There is no advantage to passing parameters by reference to get_site(), get_network(), and update_site_cache().

Props flixos90, ocean90 for review.
See #37615.

#5 @jeremyfelt
8 years ago

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

In 38233:

Multisite: Remove unnecessary reference parameters.

There is no advantage to passing parameters by reference to get_site(), get_network(), and update_site_cache().

Merge of [38232] to the 4.6 branch.

Props flixos90, ocean90 for review.
Fixes #37615.

Note: See TracTickets for help on using tickets.