WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 2 years ago

#38597 reviewing enhancement

Discourage usage of legacy properties in WP_Network

Reported by: johnjamesjacoby Owned by: jeremyfelt
Milestone: Future Release Priority: normal
Severity: normal Version: 4.6
Component: General Keywords: has-patch early
Focuses: multisite Cc:

Description

@property's is for magic properties: https://phpdoc.org/docs/latest/references/phpdoc/tags/property.html

Since $id isn't magic, let's remove the @property documentation.

See: #37050

Attachments (2)

38597.patch (314 bytes) - added by johnjamesjacoby 3 years ago.
38597.2.patch (2.7 KB) - added by johnjamesjacoby 3 years ago.
Deprecate $blog_id, remove magic @property variables, and call __set() in __constructor() so data is cast correctly

Download all attachments as: .zip

Change History (14)

#1 @jeremyfelt
3 years ago

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

Indeed. It's "magic" in that string is forced to int, but not magic in that the property isn't already defined with a docblock. :+1:

#2 follow-ups: @jeremyfelt
3 years ago

Hmm. On second thought. Does the @property tag help in this case because the property itself is private and access is magic?

#3 in reply to: ↑ 2 ; follow-up: @flixos90
3 years ago

  • Keywords close added

@jeremyfelt Yes, that's probably the reason we put it there. The @property needs to remain there so that IDEs etc recognize this property as public.

#4 in reply to: ↑ 3 @johnjamesjacoby
3 years ago

Replying to flixos90:

@jeremyfelt Yes, that's probably the reason we put it there. The @property needs to remain there so that IDEs etc recognize this property as public.

If the concern is IDEs and documentation coverage, the current approach isn't quite right either. Now it's declared in two places: the class itself, and the docblock, and they are in conflict with each other (and my IDE complains about the overlap.)

@property is also reserved for invisible magic variables, not known ones (in this case, defined in the class object.)

Having it wrong is worse than not having it at all. I'd still vote ro remove it until we decide what is most accurate.

Last edited 3 years ago by johnjamesjacoby (previous) (diff)

#5 in reply to: ↑ 2 ; follow-up: @johnjamesjacoby
3 years ago

Replying to jeremyfelt:

Hmm. On second thought. Does the @property tag help in this case because the property itself is private and access is magic?

It really shouldn't be both privately defined & publicly magic. Either we shouldn't privately define it, or we should publicly define it as what the magic method will always return.

#6 in reply to: ↑ 5 @flixos90
3 years ago

  • Keywords close removed

Replying to johnjamesjacoby:

It really shouldn't be both privately defined & publicly magic. Either we shouldn't privately define it, or we should publicly define it as what the magic method will always return.

Well if PHP was type-safe... I'm not sure which solution to go for here. I tend to leave it publicly magic and change the internals. So I assume that would mean we'd need to store it in another way than the $id property?

@johnjamesjacoby
3 years ago

Deprecate $blog_id, remove magic @property variables, and call __set() in __constructor() so data is cast correctly

#7 @flixos90
3 years ago

  • Summary changed from WP_Network::id is not a magic property to Discourage usage of legacy properties in WP_Network
  • Type changed from defect (bug) to enhancement

It's partly still a bug, but I think enhancement is a better fit now - which is a good thing. :)

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


3 years ago

#9 @flixos90
3 years ago

  • Keywords early added
  • Milestone changed from 4.7 to Future Release

Since it's an enhancement, let's get back to it early in 4.8.

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


2 years ago

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


2 years ago

Note: See TracTickets for help on using tickets.