Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#10309 closed defect (bug) (fixed)

Publish Date (Schedule) does not handle inputs properly.

Reported by: hakre Owned by: camper2020
Milestone: 2.9 Priority: normal
Severity: normal Version: 2.9
Component: Date/Time Keywords: has-patch tested
Focuses: Cc:


Entering an invalid day does not show any error and deletes the whole datetime value after save. Clientside javascript does his own limbo.

Create a Post on 2009-06-30 and then schedule it by changing the day 30 to day 31. Then save the post.


  • Prevent the reset to unixtime of 0.
  • Display an error message Clientside if a value is wrong

Attachments (4)

post.php (113.0 KB) - added by camper2020 9 years ago.
Updated wp-admin/includes/post.php with an updated checker
ticket-10309.patch (3.1 KB) - added by camper2020 9 years ago.
#10309.diff (99.5 KB) - added by arena 9 years ago.
A completely different approach, handles leap years
10309_latest.patch (99.5 KB) - added by arena 9 years ago.
latest patch with leap years

Download all attachments as: .zip

Change History (19)

#1 @Denis-de-Bernardy
9 years ago

  • Milestone changed from Unassigned to 2.8.2

#2 @hakre
9 years ago

  • Severity changed from normal to major

This should be taken care of. It is really harsh to delete a users input completely only because he made a mistake.

9 years ago

Updated wp-admin/includes/post.php with an updated checker

#3 @camper2020
9 years ago

  • Owner set to camper2020
  • Status changed from new to accepted

Hi all, I am a third year student at the University of Pretoria in South Africa.

We were given a task of finding a well known open source architecture and atte,pting to write a patch for it. I chose wordpress and this partucular ticket.

I believe I have managed to fix this error, not in the javascript but in the "post.php" file. I have uploaded the new file. <Seen Above>

List of changes:

  • Date no longer resets to Jan 1 1970.
  • If an invalid date is entered, month and year are still accepted, and day resets to current day of month on user's local machine. (Not as much overhead to edit from there)
  • Patch tests per month, i.e. Jan can have 31 days, April only 30 etc.
  • Patch takes leap years into account and so for February, 28 days are the max allowed unless the given year corresponds to a leap year test, if so, February can accept 29 days.
  • This patch is obviously only for Gregorian calendars :-)

I hope that this is satisfactory and that my code meets the standards of your great program. I have written two new methods: 'checkDates()' and 'checkDays()'.

The page still seems to load rather efficiently.

Any further queries: email me on johnston.jasond@…

Kind Regards

#4 @camper2020
9 years ago

  • Keywords Has Patch / Needs Testing added; needs-patch removed

#5 @mrmist
9 years ago

  • Keywords needs-patch added; Has Patch / Needs Testing removed
  • Severity changed from major to normal

What version was that page created from? It doesn't look like current trunk or 2.8..

Maybe it would be best to re-attached it as an actual patch file?

At least for me, I can't test it as is as I don't know where it fits as a valid file.

#6 @camper2020
9 years ago

Hi There

Sorry as its my first patch wasn't quite sure how to upload as a "proper" patch file, still not quite sure. Version wise, it is the latest version on Wordpress, 2.8.3. What I did was, I went into the actual PHP files of the Wordpress install directory, and modified the file.

The file location, if you did want to test it, would be "installdir/wp-admin/includes/post.php"

Obviously back up the original file before overwriting it with mine, also, if you could guide, how would I go about submitting this patch along the correct channels?

(oh and don't be scared that its my first patch ;-))

Thanks and regards, Jasond

#8 @camper2020
9 years ago

I assume this is a better file to attach here :-)

#9 @hakre
9 years ago

hi camper,

thanks for the patch. please consider to not that much duplicate code (for example, multiple of the cases in the switch statement containt the same code, you can write those below each other) and the the coding guidelines (I normally do write the brackets like you do, but in this project there is some other guideline):


Then I do not understand why you remove the 'trash' code in your patch. maybe this is by error?

#10 @arena
9 years ago

Hi all,

A completely different approach using select for touch_time function, Handles leap years.

9 years ago

A completely different approach, handles leap years

#11 @arena
9 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

#12 @arena
9 years ago

  • Keywords tested added; needs-testing removed

#13 @arena
9 years ago

  • Keywords needs-testing added; tested removed
  • Version changed from 2.8 to 2.9

9 years ago

latest patch with leap years

#14 @arena
9 years ago

  • Keywords tested added; needs-testing removed

10309_latest.patch tested.

#15 @azaozz
9 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [12318]) Validate date/time fields for posts and comments, fixes #10309

Note: See TracTickets for help on using tickets.