Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#24636 closed defect (bug) (wontfix)

WP_User has no method to access WP_User->data

Reported by: dd32's profile 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 11 years ago.

Download all attachments as: .zip

Change History (6)

#1 @scribu
11 years ago

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

#2 @nacin
11 years ago

  • Version changed from trunk to 3.5

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

@barrykooij
11 years ago

#3 @barrykooij
11 years 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 11 years ago by barrykooij (previous) (diff)

#4 @barrykooij
11 years 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?

#5 @dd32
11 years ago

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