Our filter for displaying pages by month started returning a "The day is invalid" error today, 1 February. Because the month filter is really for content published between first and last day of month, if you filter for content in month with last date greater than 28th (ie any month except the current month, February) the error is displayed.
Confirmed on a plain D7 site with latest versions of Views, Date API and Date Views modules
Steps to reproduce:
- create new Drupal 7 site
- enable Views, Date API and Date Views modules
- create new View, type 'node'
- add page to view
- set path
- set row style to 'node'
- add 'Date (none)' filter
- select 'Node: post date' … update
- operator "is between"
- "Expose"
- "Update and override"
- Save the view
- go to the view
- from date: Jan 1 2011
- to date: Jan 31 2011
- Apply
I've tested this in both alpha1 and alpha2.
As we're currently using alpha1 I narrowed it down to:
./date_api.module:597: $errors['day'] = t('The day is invalid.');
It would appear that in the methods arrayErrors() & forceValid() it is testing whether '31' is a valid day, but it is testing it against $now, which is February, so it fails.
Thanks,
Tim
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | date-fix-arrayErrors-1047412-6.patch | 973 bytes | das-peter |
Comments
Comment #1
lomo commentedWe are seeing this issue, too. I was just going to report the same thing.
I think this is actually a "critical" issue since a lot of dates are now being rejected as invalid; dates which are actually perfectly valid input. Should be a fairly simple fix, though...
Comment #2
enikola commentedsub
Comment #3
mattcoady commentedI also got this as well. Sub. Today's date worked.
Comment #4
unknown interloper commentedI have the same issue.
April 29 and April 30 generate "The day is invalid" error.
I use Drupal in French, I don't know if it is related...
I changed the date format and also the date field type and these actions didn't help.
Any idea?
Comment #5
adaddinsaneAt the risk of being unoriginal "me too". This is a serious problem. I need to create a list of UK bank holidays, one of which is the last Monday of August = 29th. Ooops not allowed.
Comment #6
das-peter commentedJust came also across this - attached patch hopefully fixes this.
If there are usable values to work with they are used instead "now".
Comment #7
adaddinsaneWorks for me - thanks.
Comment #8
timhomewood commentedThe patch works, thanks das-peter.
Comment #9
jon betts commented#6 patch works for me too, thanks! Oct 29-31 didn't work for me.
Comment #10
georgedamonkey commentedI can not only confirm the patch fixes this issue... But, it also fixes this one: http://drupal.org/node/1049976
Outstanding work, my friend!
Comment #11
wiizzard commented#6 patch works for me too.
Comment #12
liberatrPatch works for me too.
Comment #13
czigor commented#6 works for me too.
Comment #14
enikola commentedIssue is present also in alpha2. Can somebody please confirm patch is working against alpha2.
Comment #15
enikola commentedComment #16
georgedamonkey commentedI have alpha 2, and the patch worked perfectly.
Comment #17
jcarlson34 commentedWorks like a charm. Many thanks!
Looks like enough people reviewed this, lets get it into the next build. Marking RBTC
Comment #18
mukesh.agarwal17 commentedWorked like a charm.. Thanks!
Comment #19
arlinsandbulte commentedMarked #1057116: Validation error "The day is invalid" even when it is not as a duplicate of this issue, which has code that is nearly identical to the patch in #6.
The only difference is this the use of !empty vs array_key_exists:
#6:
$default_month = !empty($arr['month']) ? $arr['month'] : $now->format('n');
$default_year = !empty($arr['year']) ? $arr['year'] : $now->format('Y');
#1057116: Validation error "The day is invalid" even when it is not:
$default_month = array_key_exists('month', $arr) ? $arr['month'] : $now->format('n');
$default_year = array_key_exists('year', $arr) ? $arr['year'] : $now->format('Y');
So, which method is best to use here?
Comment #20
das-peter commentedHmm, good question.
Since
array_key_existsalso returns true if there's an empty value like NULL or 0 I think we should use!empty- because dealing with dates 0 isn't a valid value (or am I missing a case?).Thus with
!emptywe have at least a chance that the right thing is done even if there's a empty value ;)Comment #21
arlinsandbulte commentedOK, sounds reasonable.
Committed #6: http://drupal.org/cvs?commit=498328
Comment #22
s_oneill commentedSomeone like me, who ain't no drupal wizard needs to be told, where to apply this patch ... it ain't root folder!
Comment #23
tim.plunketts_oneill, try it from within the date_api folder. Or just grab the latest dev copy, its included
Comment #24
Renegadez commentedTim is there a proper way to update to the new dev version like do I need to disable the module and uninstall it and then copy the new dev up to the server and reenable?? will doing this break an exisint dates? sorry still very new but do not want to break anything Thanks for the help Renz
Comment #25
tim.plunkettrenegadez, you can skip the uninstalling part. Just disable, remove the module folder, copy the new one up, re-enable, run update.php, and clear the caches.
Comment #26
Renegadez commentedTim Thank you very much!
Ok the new dev version expcet somehow my second calendar using its own content type cannot make display posts made it to it. The dates are created they just dont show up on the calendar Ideleted the view and made a fresh one from scratch used all the setting from the working except substituted the content type for puc_cal instead or priv_cal i am ar a total loss why one could displayed correctly but the other cannot they both worked before except for the post on the 30th weird Thanks Renz