Make WordPress Core

Opened 2 years ago

Last modified 15 months 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:


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 @toscho2 years ago

  • Cc info@… added

comment:2 @johnbillion2 years ago

  • Cc johnbillion added

comment:3 @nacin22 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 @nacin22 months ago

  • Version changed from trunk to 3.5

comment:5 @carlalexander22 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 @nacin16 months ago

  • Component changed from General to Post Types

comment:8 @ircbot15 months ago

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

Note: See TracTickets for help on using tickets.