WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 5 months ago

#35880 new enhancement

Refactor date handling in wp_insert_post()

Reported by: redsweater Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch
Focuses: Cc:
PR Number:

Description

I started refactoring this code while researching #35874, because I thought the unpredictable logic in this function might have contributed to the problems described there. Although that turned out not to be the case, I think the refactoring I've done is still valuable. Effectively I've aimed to clarify the code by leaning heavily on standardizing the validation of submitted dates into the $post_date variable, and then converting that back to a GMT based $post_date_gmt only when all other shared validation is completed.

In my opinion this makes the code easier to read and maintain, but as this doesn't specifically address any known bug, I will appreciate it if it doesn't seem worth integrating.

Attachments (1)

refactor-insert-post-date-handling.patch (3.2 KB) - added by redsweater 4 years ago.
Refactor wp_insert_post()'s handling of dates to be more readable and maintainable

Download all attachments as: .zip

Change History (4)

@redsweater
4 years ago

Refactor wp_insert_post()'s handling of dates to be more readable and maintainable

#1 @redsweater
4 years ago

  • Keywords has-patch added

#2 @chriscct7
4 years ago

  • Version trunk deleted

#3 @ocean90
3 years ago

  • Component changed from General to Posts, Post Types
Note: See TracTickets for help on using tickets.