WordPress.org

Make WordPress Core

Opened 11 years ago

Closed 7 years ago

#14279 closed defect (bug) (fixed)

wp_new_comment ignores comment_date_gmt and comment_date

Reported by: johneckman Owned by: boonebgorges
Milestone: 4.2 Priority: normal
Severity: normal Version: 3.0
Component: Comments Keywords: has-patch commit
Focuses: Cc:

Description

wp_new_comment takes in a $comment array, but then ignores the comment_date and comment_date_gmt passed into it, instead replacing them with the current time.

It should only set them if the data passed in is empty or not a date/time.

Attachments (2)

14279.diff (896 bytes) - added by solarissmoke 11 years ago.
14279.2.diff (2.7 KB) - added by oso96_2000 8 years ago.
Refreshed patch with unit test

Download all attachments as: .zip

Change History (10)

#1 @dd32
11 years ago

  • Keywords needs-patch easy added
  • Milestone changed from Awaiting Review to Future Release

@solarissmoke
11 years ago

#2 @solarissmoke
11 years ago

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

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


8 years ago

@oso96_2000
8 years ago

Refreshed patch with unit test

#4 @oso96_2000
8 years ago

  • Keywords dev-feedback added; has-patch removed

Hey, sorry for taking too long to resolve this. Thanks for the patch @solarissmoke, I just refreshed it and added some unit tests.

#5 @oso96_2000
8 years ago

  • Keywords has-patch added

#6 @DrewAPicture
7 years ago

  • Keywords commit added; dev-feedback removed
  • Milestone changed from Future Release to 4.2

14279.2.diff still applies and unit tests pass.

#7 @boonebgorges
7 years ago

This looks pretty good, but I'm going to make a few changes to clean it up:

  • Unit tests can be simplified. Modding the environment during setUp() and tearDown() is likely to have unforeseen effects on other tests in the class.
  • I'm going to remove the ! strtotime() checks. I know that this is meant as a sort of validation. But (a) as validation it's imperfect, as it'll fail for the UNIX epoch, and (b) we don't do this kind of validation on dates elsewhere. If someone enters an invalid date, MySQL will convert it to 0000-00-00 00:00:00, which IMO is better behavior than silently swapping out the intended date for the current date.

#8 @boonebgorges
7 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 31615:

Respect comment_date and comment_date_gmt params in wp_new_comment().

Props solarissmoke, oso96_2000.
Fixes #14279.

Note: See TracTickets for help on using tickets.