WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 3 weeks ago

#24672 reopened enhancement

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 (15)

#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
3 years ago

  • Component changed from General to Post Types

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


3 years ago

#9 in reply to: ↑ 3 @SergeyBiryukov
18 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
18 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.

#11 @Gerkin
9 months ago

  • Type changed from defect (bug) to enhancement

Hi WordPress team,
I'd like to extend WP_Post in my plugins too. Why don't you plan to create a new class for the junction with WP_Term, WP_Comment, etc etc, and let us extend WP_Post with plugin-specific logic?

Thank you for your attention.

#12 @schrapel
7 weeks ago

@nacin this is no longer blocked, right?

#13 @schrapel
7 weeks ago

  • Resolution maybelater deleted
  • Status changed from closed to reopened

#14 @Jabawack
3 weeks ago

Any news about this ticket?

#15 @netweb
3 weeks ago

  • Milestone set to Awaiting Review

Moving reopened tickets without a milestone back to Awaiting Review for review

Note: See TracTickets for help on using tickets.