WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 8 months ago

#24672 closed defect (bug) (maybelater)

Remove final from WP_Post class

Reported by: carlalexander Owned by:
Milestone: 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 (10)

#1 @toscho
3 years ago

  • Cc info@… added

#2 @johnbillion
3 years ago

  • Cc johnbillion added

#3 follow-up: @nacin
3 years 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.)

#4 @nacin
3 years ago

  • Version changed from trunk to 3.5

#5 @carlalexander
3 years 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.

#6 @nacin
2 years ago

  • Component changed from General to Post Types

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


2 years ago

#9 in reply to: ↑ 3 @SergeyBiryukov
8 months ago

Replying to nacin:

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.

Related: #32619

#10 @nacin
8 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed

We will certainly not forget to do this when the time comes. Closing.

Note: See TracTickets for help on using tickets.