Download & Extend

Date browser and Calendar works but show errors

Project:Calendar
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Hi, I've been trying to fix my issue for some time now, and I get to the conclusion that I'm facing a bug in the module, hoping that I'm wrong.

Before I start, I updated to dev and followed all the steps for date and calendar. That fixed all my issues exept one :

- I created a content type with a date field
- Cloned a date browser view, that I turned into a calendar view (exactly like the video on drupaltherapy.com).
- Changed the field to the date field, no content is displayed in the calendar
- Added a sort criteria to be the same date field, ascending
- The content is displayed correctly, on the right dates, but I get these errors, each time per node displayed in the calendar :

    * warning: date_timezone_set() expects parameter 1 to be DateTime, null given in /home/couzinhu/public_html/vivo/sites/all/modules/contrib/calendar/includes/calendar.inc on line 414.
    * warning: date_format() expects parameter 1 to be DateTime, null given in /home/couzinhu/public_html/vivo/sites/all/modules/contrib/calendar/includes/calendar.inc on line 416.

The date field is pretty standard, nothing fancy, any idea ?

Comments

#1

I hope this helps getting this resolved. However i have exactly the same error in the 6.x.2.1 version.

#2

Same issue here:
Drupal 6.10
Date 6.x-2.1
Calendar 6.x-2.1
php 5.2.0-8

i only get the errors whe not logged in so maybe the defaukt timezone does not get set properly? Could it have to do with the site being multingual?

#3

Setting Time zone handling in the the date field's properties to 'Date's time zone' fixes this issue for me except when i select french as preferred language (as an anonymous user).

#4

I'm sorry I keep posting. Now everything is solved by setting the right permissions for this field (anonymous users could not view the date field). If topicstarter could confirm this works for him/her too, this can be marked as closed.

#5

Not fixed for me yet - Setting the field with no time zone conversion only removes the first error, but the second is still here, and I'd prefer using a time zone conversion.

#6

Same problem here.

Drupal 6.10
Date 6.x-2.1-dev
Calendar 6.x-2.1-dev

Duplicated the calendar view.
Modified the filter to only show my event content type.
Modified the Argument to use my event 'From date' instead of the published date.
Modified sort criteria to use the same 'From date'.

Looked at my calendar view, and got all these warnings.

My solution: added my Event content type 'From date' field to the Fields list and removed the default 'published date.

This solved it for me, not to say it isn't still a problem.

#7

Version:6.x-2.x-dev» 6.x-2.1
Assigned to:Anonymous» follettoinventore

I fixed this error removig "To date" from CCK field, I setting "display never" the form to date in the setting of cck.

#8

I found the warnings went away if I unpublished all events that had passed.

No warnings showing as of now.

Only change I made.

Regards,

didymo

#9

Version:6.x-2.1» 6.x-2.x-dev
Assigned to:follettoinventore» Anonymous

@follettoinventore -> you're not maintainer of the module, and your fix is not valid as some will need the 'to date' or having to display it.
Also, this concern the latest version of the module, so back to DEV.

#10

Fixed when adding the date field in the fields list of the view, even works when set to 'exclude from display'.

#11

#10 worked perfectly for me, thank you.

#12

I just installed 6.x-2.1 , used the wizard to create a calander
and am seeing the above problem after adding a date.

Could someond kindly post the exact steps to fix this?
Being a relative newbie to Drupal I'm still fumbling around.

Thanks

#13

Nevermind, I found it.

In my case it was the 'view field_date' permissions. All three fields
were not checked. What threw me was that everything
was fine for the admin user despite the site admin field not being
checked.

#14

Setting 'view field_date' seems to do the trick! Thanks for the solution!

Aniruddha

#15

#13 worked for me too -- enabling Content Permissions for date fields listed in a View to any Role that can access that View.

Thanks ipb!

Disabling the Content Permissions module also fixed the symptom of this issue.

#16

Solution #10 did the trick for me, if you don't want to display the date in the view simply add field Content: from date but mark the "Exclude from display" tick, it will erase the errors but will mantain your view as you want it.

#17

Solution #10 worked for me as well.

#18

Update: Solution #10 worked for me, but when I use an anauthenticated user error comes back

#19

Very interesting... #10 does seem to work, although I don't quite see why yet :) Subscribe.

#20

Project:Date» Calendar
Version:6.x-2.x-dev» 6.x-2.x-dev

#18> Set the same access right for the "anonymous user" role and it should not display these errors anymore.

I don't see how this is related to "Date" project, since it is obviously an issue with the verification of the CCK field access permission which should be done in Calendar. The Date project does what it is supposed to do, not return anything because the access rights are not sufficient, so I updated the issue accordingly.
Before trying to use the Date field, Caldendar should verify if access to it is granted, or the event should not be displayed in the calendar. Of course this should be documented, because as we can see many users forget to set those permissions on the CCK fields.

Anyways, these errors should not be raised like that, they should be handled because it is common to forget to set those rights and it could also be done on purpose (maybe the event's date should not be disclosed to every users and this could be achieved like this, through access rights).

***EDIT***
After a bit more investigation, when the "view" access right of the CCK Date field is not granted, the "From" date is returned but not the "To" date.. I do not get why... maybe another issue in Date API or even in CCK itself, but in any case, if both dates weren't returned, as it should be (when access rights are not sufficient), there would be 4 errors, not two.. and thus Calendar should really check if those dates are all here before trying to convert the timezones or even before trying to add them in the calendar !

When sufficient right, in $items you find :

[calendar_fields] => stdClass Object
                      (
                        [node_data_field_event_field_event_value] => 2009-04-16 15:00:00
                        [node_data_field_event_field_event_value2] => 2009-04-16 15:00:00
                      )

When access is not granted :
[calendar_fields] => stdClass Object
                     (
                        [node_data_field_event_field_event_value] => 2009-04-16 15:00:00
                     )

#21

Status:active» needs review

I've come up with this pretty simple patch. Comments in the code explain how I decided to handle it.
For the ones who are wondering, even if the "To" date is not set when the form is filled by the user, it is set in the database (to the same date as the "From" date).

AttachmentSize
calendar-417626.patch 943 bytes

#22

Tried the patch above..the errors indeed go away...so does all the data. With patch applied nothing I post to the calendar shows up on the calendar! Suggestions?

#23

Providing you have content_permissions module enabled, did you set the good access rights for the field (admin/user/permissions, under the "content_permissions module", view <yourfield name>) ? Because my patch does not make this optional, it just doesn't raise an error in Calendar (as it used to) when you did not specify the access rights to your CCK field.

#24

it is set.. next steps?

#25

Not really sure... I do have a pending issue with disappearing nodes in certain circumstances (#436636: Year view makes all Date nodes disappear from the Calendar), but it does happen even without this patch, so I don't think we should look this way. Maybe this is related to this issue : #389294: Time Slot Calendar does not work ?

#26

#10 worked for me, thanks.

using:
Drupal 6.10
Calendar 6.x-2.1
Views 6.x-2.5
Date 6.x-2.1
CCK 6.x-2.2

#27

#13 solution worked for me. [Thanks ipb!] Permissions for 'view field_date' needed to be enabled for anonymous and authenticated users.
#10 solution made no difference for me (perhaps because I already had From date included as a field).

Using:
Drupal 6.10

CCK 6.x-2.2 (with content permissions enabled)
Calendar 6.x-2.1
Date 6.x-2.1
Views 6.x-2.5

MySQL 5.0.45
PHP 4.2.4

#28

I guess the productive approach would be to test the patch I made in #21 and tell us if it works (doesn't mean you don't have to set permissions... but at least with this patch it shouldn't raise an error when permission is not set).

#29

#10 fixed this issue for me. Thank you very much!

#30

Tried #10 and #13 -
Permissions are set so that any user can view field_date but when I try to create an Event (the name of my content type that has field_date as a field) in any role other than User 1, I get a bunch of warnings like this:

warning: date_format() expects parameter 1 to be DateTime, null given in /home1/oregonfb/public_html/sites/all/modules/date/date/date.module on line 351.
warning: date_timezone_set() expects parameter 1 to be DateTime, null given in /home1/oregonfb/public_html/sites/all/modules/date/date/date.module on line 353.
warning: date_format() expects parameter 1 to be DateTime, null given in /home1/oregonfb/public_html/sites/all/modules/date/date/date.module on line 355.
warning: date_offset_get() expects parameter 1 to be DateTime, null given in /home1/oregonfb/public_html/sites/all/modules/date/date/date.module on line 357.

Is anyone else experiencing this?

#31

I fixed this by checking every single box on the Permissions page for my admin account (not User 1). One by one I unchecked the permissions I didn't necessarily want, saved permissions, and then tried to post again using the admin account.

It worked great until I unchecked the box "post with no checking" under the Mollom Module. Then I got all the same warnings.

I don't know why this works but I'm now enabling that permission for any Role that needs to create an Event.

#32

#31 worked for me. I checked the Mollom "post with no checking" and now don't see the errors. So then I set Mollom to not test events and unchecked the "post with no checking" permission for everyone and now no errors. I'll just keep an eye on events as they come in and let Mollom check everything else.

Looks like a problem with date.module and Mollom though.

#33

Just solved this issue on my site.

Under my content type's datetime field configuration, I chose the "Never" option under Global Settings/To Date, & then choosing "No time zone conversion" under Time Zone Handling.

I'd prefer to use the site's time zone, but I'm fine with it as long as these error messages stay gone.

#34

Status:needs review» active

I'm looking for patches that are ready to apply and there is no patch here, so re-classifying. I will try to come back later and review, but I can't do it yet.

#35

KarenS: What about #21 ?

#36

Status:active» needs work

Ah, I missed the patch, but there are comments after that that say it doesn't work, so they need to be sorted out to see what, if any, changes are needed.

#37

Well, it seems that anyways, for me at least, this error does not happen now, even without my previous patch (with latest versions oh the concerned modules from CVS). And maybe it was related to #452690: date_timezone_set() expects parameter 1 to be DateTime, null given which was about the same errors and got fixed with this commit.
I think this issue should be maked as fixed then.

#38

Status:needs work» fixed

No activity for a while... according to #37, seems fixed.

#39

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.