Opened 10 years ago
Closed 10 years ago
#37050 closed defect (bug) (fixed)
Make the `WP_Network` `id` property an int
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.6 | Priority: | normal |
| Severity: | normal | Version: | 4.4 |
| Component: | Networks and Sites | Keywords: | has-patch has-unit-tests |
| Focuses: | multisite | Cc: |
Description
#36717 introduced magic methods for WP_Network and we now have a mechanism for forcing the id property of WP_Network to int rather than string.
When WP_Network was introduced in [34097], the id property was incorrectly marked as int, which @jdgrimes highlighted in #35404. We adjusted this back to string for 4.5 to match the returned value.
For general developer sanity, it would be nice to cast id to an int and change the documentation. This would however break backwards compatibility for anyone doing strict comparisons with a string.
If determined to be worth it, I'd like to get it in soon so that we give things a chance to break.
Attachments (3)
Change History (8)
This ticket was mentioned in Slack in #core-multisite by jeremyfelt. View the logs.
10 years ago
#3
@
10 years ago
- Keywords has-patch has-unit-tests added; dev-feedback 2nd-opinion removed
37050.3.diff is a combination of both previous patches. It changes the property itself to be an integer, while it also makes it private to be able to use magic methods to ensure the type.
The patch also adds a unit test for it.
After discussion at WCEU contributor day, this change is good to go in although being backwards-incompatible. The network class is not widely used and strict comparisons shouldn't be used with something as unclear as an ID field where it's unknown whether it's string or int. The change doesn't need an extra dev-note, but should be mentioned in the global multisite changes note.
37050.2.diff makes a few adjustments:
$blog_idfrom integer to string so that it matches the described type@jeremyfelt I think this method is more in line with the changes from #36717 and we keep the internals the same types like before. Let's discuss which route we wanna go. One issue with your patch was that
$idwas still a public property, so the magic get method that would ensure it returned an integer was never triggered.