WordPress.org

Make WordPress Core

Opened 10 months ago

Last modified 7 weeks ago

#24672 new defect (bug)

Remove final from WP_Post class

Reported by: carlalexander Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.5
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description

After discussing it with stephdau and reading through #21309, I think a discussion should be had on the validity of using the final keyword on the class.

While I agree that a decorator pattern is probably best for building the class, there is still no reason for the keyword to be used. If someone wants to extend the class then they should be allowed to do so.

Change History (8)

comment:1 toscho10 months ago

  • Cc info@… added

comment:2 johnbillion10 months ago

  • Cc johnbillion added

comment:3 nacin9 months ago

I think we are waiting for WP_Post to be joined by a WP_Comment and WP_Term, and then for all four classes (along with WP_User) to actually be decorated with methods. Removing that final makes it a free-for-all that will make it painful if not nearly impossible to make changes that don't break plugins. Very simply, final is the only thing that lets us turn this into a real API while not worrying about back compat. (This class was originally just for caching and sanitization sanity, not API.)

comment:4 nacin9 months ago

  • Version changed from trunk to 3.5

comment:5 carlalexander9 months ago

What version are those classes planned for? Extending this class is a pretty advanced use case for a plugin developer. They should be able to handle the back compat issues when the pattern gets implemented.

That said. If it's planned for 3.7, then that's not a big deal, but if it's a very long term plan. I'd take it off and amend the class doc to make note of the fact that this is not the final implementation of the class.

comment:6 nacin3 months ago

  • Component changed from General to Post Types

comment:8 ircbot7 weeks ago

This ticket was mentioned in IRC in #wordpress-dev by danielbachhuber. View the logs.

Note: See TracTickets for help on using tickets.