Error importing iCal

lonebrave - May 11, 2007 - 21:09
Project:Calendar
Version:5.x-1.5
Component:User interface
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

I'm trying to import my Google Calendar via their iCal link.

I've installed the Calendar module (5.x-1.4) and have created a block and page view. From the page view, clicking on the iCal tab brings me the options for importing the iCal feeds. I've given it a name (Google Calendar) and provided the URL (http://www.google.com/calendar/ical/my_email_here/public/basic.ics). The Calendar is marked as public in Google, so that shouldn't be a problem.

When clicking "Submit", however, Drupal reports "Invalid input file". That is the only content of the page...not even the admin interface, just that text.

There is probably something very simple I'm missing, but still being new to Drupal, I haven't been able to figure out what it is.

I can provide the actual link to the Google Calendar if needed.

Nick

#1

alaken - June 5, 2007 - 07:01

I'm also getting this error. I had 5.x-1.4 installed, and upgraded to HEAD just now, but there's the same issue, blank page with "Invalid input file." I'm using an exact clone of the default calendar view - no extra fields.

PHP log dumped this:

[05-Jun-2007 02:55:06] PHP Notice:  unserialize() [<a href='function.unserialize'>function.unserialize</a>]: Error at offset 310 of 3167 bytes in /Applications/MAMP/htdocs/ck/includes/bootstrap.inc on line 347
[05-Jun-2007 02:58:35] PHP Notice:  unserialize() [<a href='function.unserialize'>function.unserialize</a>]: Error at offset 2 of 55 bytes in /Applications/MAMP/htdocs/ck/includes/bootstrap.inc on line 347
[05-Jun-2007 02:58:35] PHP Notice:  unserialize() [<a href='function.unserialize'>function.unserialize</a>]: Error at offset 2 of 54 bytes in /Applications/MAMP/htdocs/ck/includes/bootstrap.inc on line 347
[05-Jun-2007 02:58:35] PHP Notice:  unserialize() [<a href='function.unserialize'>function.unserialize</a>]: Error at offset 2 of 60 bytes in /Applications/MAMP/htdocs/ck/includes/bootstrap.inc on line 347
[05-Jun-2007 02:58:35] PHP Notice:  unserialize() [<a href='function.unserialize'>function.unserialize</a>]: Error at offset 76 of 1125 bytes in /Applications/MAMP/htdocs/ck/includes/bootstrap.inc on line 347
[05-Jun-2007 02:58:35] PHP Notice:  unserialize() [<a href='function.unserialize'>function.unserialize</a>]: Error at offset 310 of 3167 bytes in /Applications/MAMP/htdocs/ck/includes/bootstrap.inc on line 347

#2

slb534 - June 8, 2007 - 15:25

I am also getting the same error. I noticed that the error goes away if I download the .ics file and then put it into my drupal folder. Then, instead of typing in a full URL in the "Source file:" box, I just type in the file name by itself and press Submit. Next, it takes me to a different screen, where I'm stuck, but at least it's a little further! :-)

#3

torelad - June 14, 2007 - 09:06

The source of the error is the exit statement on line 108 of date_ical.inc:

<?php

105
function date_ical_import($filename) {
106  $items = array();
107  $ifile = @fopen($filename, "r");
108  if ($ifile == FALSE) exit('Invalid input file');
109  $nextline = fgets($ifile, 1024);

?>

For my part, I've found that Dreamhost does not allow fopen to access external URLs.

The error handling is clearly not very Drupal-like and I suspect the author's intention wasn't to leave it as simple exit statements. Hopefully this bug report is enough to address it, but I can submit a feature request if required.

The Aggregator module uses drupal_http_request which uses the fsockopen function. This might be a better way of fetching the data.

#4

torelad - June 14, 2007 - 20:34

ical_import_errormsg1.patch for date_ical.inc.

Attached patch replaces the 2 instances of the PHP exit function with drupal_set_message.

It also adds an explicit test for allow_url_fopen and returns an error if allow_url_fopen == FALSE.

AttachmentSize
ical_import_errormsg1.patch1.44 KB

#5

torelad - June 15, 2007 - 07:07
Status:active» patch (code needs review)

Patch to date_ical.inc - date_ical_import function.

Forget that last patch. This patch checks the URL string passed to the date_ical_import function. If it starts with http it uses the drupal_http_request function to get the data. If it doesn't, it uses fopen via the PHP file function.

As with the last patch, it used drupal_set_message for error reporting.

Although the while loop was changed to a foreach loop, none of the ical parsing logic was changed.

I've tested on my WindowsXP workstation test environment and on a unix host (Dreamhost) with allow_url_fopen disabled and it passed.

AttachmentSize
ical_import1.patch2.56 KB

#6

KarenS - June 15, 2007 - 12:11

Yes, the error handling needed work, and I wasn't aware of hosts that don't allow fopen, so this appears to be a good fix and I'm inclined to commit it, but I'd appreciate feedback from others on whether it's working correctly. I'll test it myself if no one else does, but can't work on it for a couple days.

#7

uturn - June 27, 2007 - 01:38

I've applied torelad's patch to my installation on a Dreamhost account. I can confirm that it works with no ill effects (so far). Thanks! I was pulling my hair out with this.

#8

KarenS - July 7, 2007 - 16:50
Status:patch (code needs review)» fixed

Nice fix, thanks! Committed to both 5.x and 4.7.

#9

KarenS - July 7, 2007 - 16:52

Just in case anyone doesn't realize it, this is actually a fix in the Date API, which is where the ical handling lives, so the updated code is in the Date module.

#10

Anonymous - July 21, 2007 - 17:17
Status:fixed» closed

#11

areav - August 13, 2007 - 23:46
Status:closed» active

I am getting the "Invalid Input File" message with the updated version. I am using iCal from google. It worked for me the first time I did it, but It does not work anymore and I am using the same address and haven't changed anything.

and ideas?

also is there a way that it could update the calendar from the google feed on its own

#12

TallDavid - September 24, 2007 - 21:11
Version:5.x-1.4» 5.x-1.5

The white screen containing only "Invalid input file" also occurs with Calendar 5.x-1.5. Disabling iCal from the modules screen resolves the "Invalid input file" error.

If anyone knows of a production-worthy method of feeding CiviEvent (part of CiviCRM v1.8) events into Calendar, I'm all ears!

#13

g76 - September 27, 2007 - 15:35

I too am working on ical feeds from civievents. I am running Drupal 5.2/civicrm 1.8. I applied the patch above ( thank you!) and it has gotten rid of the blank screen and error, but upon entering in the ical feed url provided directly in civievents documentation, I get this error now: Invalid calendar file:http://www.mysite.com/civicrm/event/ical?reset=1&page=1.

I am at a loss here, any ideas?

#14

g76 - September 27, 2007 - 19:34

fixed my own problem(above). you have to give anonymous users permissions to register for events.

see http://forum.civicrm.org/index.php/topic,135.0.html

#15

MediaGuy4 - October 2, 2007 - 17:08

I'm confused, can someone explain exactly how to use the patch. Where do I install? Do I change the filename? Does it work?

Thanks!

#16

KarenS - October 6, 2007 - 11:05
Status:active» fixed

You don't need to do anything with the patch, it is already committed and included in the module.

Making Google calendar info usable is actually a somewhat confusing problem on the Google side. You can create a public event in your Google calendar but the ical feed still won't work unless you also make your calendar public. Don't ask me why, it's a Google question.

If the feed is not set up on Google's side to allow public access, there's no way to make it work here.

You can test your feed for yourself by pasting it directly into your browser. If you get an error message when you do that, it won't work in this Calendar either.

I need to create some documentation to explain this. Since this issue is pretty polluted at this point, I'll open another one.

#17

Anonymous - October 20, 2007 - 11:11
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.