WordPress.org

Make WordPress Core

Opened 10 months ago

Closed 5 months ago

#24636 closed defect (bug) (wontfix)

WP_User has no method to access WP_User->data

Reported by: dd32 Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5
Component: Users Keywords: has-patch
Focuses: Cc:

Description

While working on #24635 I noticed that the WP_User class doesn't have a method to access the data field, while it has magic getters and setters, plus a to_array() method.

It seems appropriate that we should have a getter for the entire data object to go along with them.

Attachments (1)

24636.patch (464 bytes) - added by barrykooij 6 months ago.

Download all attachments as: .zip

Change History (6)

comment:1 scribu9 months ago

You can already do $user->data, since it's not actually private.

comment:2 nacin9 months ago

  • Version changed from trunk to 3.5

Seems like $user->data is probably good for now.

barrykooij6 months ago

comment:3 barrykooij6 months ago

  • Keywords has-patch added; needs-patch removed

Added get_data method, in my opinion it's better to use getters/setters than public properties.

Last edited 6 months ago by barrykooij (previous) (diff)

comment:4 barrykooij6 months ago

Talked this over with Nacin and my patch can be ignored/removed.

Although the $data property isn't private, it's not supposed to be public either. The guideline Nacin uses at the moment is changing properties that should be public to public, while leaving those that should be private or protected at var. The $data property in this case should be private, so creating a getter for it would give people the idea that it should be used publicly.

I suggest closing the ticket, agree dd32?

comment:5 dd325 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.