When submitting a comment (as the administrator in my test case), I get an error saying "You have to specify a valid date."

My initial strategy of waiting for a fix to show up in CVS hasn't worked so far, so I created this patch. However on the walk to the internet, I had some second thoughts about this patch.

This patch at least allows me to create comments, but I have the feeling it makes the check on the next line useless.

Comments

Wesley Tanaka’s picture

Status: Active » Needs review
StatusFileSize
new932 bytes

This patch is probably more likely to fix the problem without causing problems with editing the date later on. But it's difficult for me to test it here.

Wesley Tanaka’s picture

Title: You have to specify a valid date. » When trying to create a comment: You have to specify a valid date.
Wesley Tanaka’s picture

I've smoke tested http://drupal.org/files/issues/you-have-to-specify-a-valid-date_0.patch by:

1. posting a comment as the administrator
2. editing that comment and changing the date
3. re-editing the comment and trying to change the date to "abcdefg" (which failed properly)

Wesley Tanaka’s picture

Title: When trying to create a comment: You have to specify a valid date. » creating a comment, editing a comment, or anything that validates a comment fails. ("You have to specify a valid date")

Revising the title. In most issue tracking processes, this would be considered a "blocker."

Wesley Tanaka’s picture

Revising the title. In most issue tracking processes, this would be considered a "blocker."

Wesley Tanaka’s picture

Status: Needs review » Reviewed & tested by the community

plagiarizing from Cvbge:

Let's set this to RTBC and see what happens ;)

Cvbge’s picture

I think I can't reproduce this...

Wesley Tanaka’s picture

That's strange, since by inspection, if the validate function gets called, that form error will get set 100% of the time.

Wesley Tanaka’s picture

In any case, the steps I used to reproduce the problem:

1. log in as the superuser
2. navigate to an existing forum topic
3. use the comment form that's displayed on the same page to write a comment
4. hit submit

The comment fails with the error "You have to specify a valid date"

chx’s picture

Looks good to me but I have not run the code as i am on PHP4.

dries’s picture

Isn't if (strtotime($date) <= 0) better? It is what we use elsewhere:

$ grep -r -A 1 "strtotime returns" *
modules/aggregator.module:    $timestamp = strtotime($date); // As of PHP 5.1.0, strtotime returns FALSE on failure instead of -1.
modules/aggregator.module-    if ($timestamp <= 0) {
--
modules/node.module:    // Validate the "authored on" field. As of PHP 5.1.O, strtotime returns FALSE instead of -1 upon failure.
modules/node.module-    if (strtotime($node->date) <= 0) {
morbus iff’s picture

This bug also causes *comment creation*, be it anony or admin, to fail. Will test the patch shortly in PHP 5.

morbus iff’s picture

Patch works for me on PHP 5.0.3.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed a modified version of this patch. Thanks guys.

Anonymous’s picture

Status: Fixed » Closed (fixed)