WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 3 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)

comment:1 @toscho2 years ago

  • Cc info@… added

comment:2 @johnbillion2 years ago

  • Cc johnbillion added

comment:3 follow-up: @nacin2 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.)

comment:4 @nacin2 years ago

  • Version changed from trunk to 3.5

comment:5 @carlalexander2 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.

comment:6 @nacin20 months ago

  • Component changed from General to Post Types

comment:8 @ircbot18 months ago

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

comment:9 in reply to: ↑ 3 @SergeyBiryukov3 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

comment:10 @nacin3 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.