Make WordPress Core

Opened 6 years ago

Closed 6 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 6 years ago.
Updated wp-admin/includes/post.php with an updated checker
ticket-10309.patch (3.1 KB) - added by camper2020 6 years ago.
#10309.diff (99.5 KB) - added by arena 6 years ago.
A completely different approach, handles leap years
10309_latest.patch (99.5 KB) - added by arena 6 years ago.
latest patch with leap years

Download all attachments as: .zip

Change History (19)

comment:1 @Denis-de-Bernardy6 years ago

  • Milestone changed from Unassigned to 2.8.2

comment:2 @hakre6 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.

@camper20206 years ago

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

comment:3 @camper20206 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

comment:4 @camper20206 years ago

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

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

comment:6 @camper20206 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

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,

@camper20206 years ago

comment:8 @camper20206 years ago

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

comment:9 @hakre6 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?

comment:10 @arena6 years ago

Hi all,

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

@arena6 years ago

A completely different approach, handles leap years

comment:11 @arena6 years ago

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

comment:12 @arena6 years ago

  • Keywords tested added; needs-testing removed

comment:13 @arena6 years ago

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

@arena6 years ago

latest patch with leap years

comment:14 @arena6 years ago

  • Keywords tested added; needs-testing removed

10309_latest.patch tested.

comment:15 @azaozz6 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.