Problem with the whole-calendar iCal feed?

  • Problem
  • Updated 3 years ago
  • Acknowledged
I tried to subscribe to the whole Boston Music Intelligencer calendar in Outlook, using the link webcal://classical-scene.com/?feed=gigpress-ical, and it didn’t work. The message was:

“Cannot verify or add the calendar to Outlook. Make sure the following link is a valid calendar link: webcal://classical-scene.com/?feed=gigpress-ical”

I looked under the covers and found that the server is reporting this error:

HTTP/1.1 500 Internal Server Error

Looking further I think I see the problem here:

function gigpress_ical() {

global $wpdb, $gpo;
$further_where = '';
if(isset($_GET['show_id'])) {
$further_where .= $wpdb->prepare(' AND s.show_id = %d', $_GET['show_id']);
}
if(isset($_GET['artist'])) {
$further_where .= $wpdb->prepare(' AND s.show_artist_id = %d', $_GET['artist']);
}
if(isset($_GET['tour'])) {
$further_where .= $wpdb->prepare(' AND s.show_tour_id = %d', $_GET['tour']);
}
if(isset($_GET['venue'])) {
$further_where .= $wpdb->prepare(' AND s.show_venue_id = %d', $_GET['venue']);
}

$shows = $wpdb->get_results(
$wpdb->prepare("SELECT * FROM " . GIGPRESS_ARTISTS . " AS a, " . GIGPRESS_VENUES . " as v, " . GIGPRESS_SHOWS ." AS s LEFT JOIN " . GIGPRESS_TOURS . " AS t ON s.show_tour_id = t.tour_id WHERE show_status != 'deleted' AND s.show_artist_id = a.artist_id AND s.show_venue_id = v.venue_id" . $further_where, $_GET['show_id'])
);

It looks like this will bomb if show_id, the 2nd argument to wpdb->prepare, isn't set. (And in fact, it looks like wpdb->prepare isn't even using that 2nd argument.)
Photo of Jon Udell

Jon Udell

  • 5 Posts
  • 0 Reply Likes

Posted 3 years ago

  • 1
Photo of Derek

Derek, Developer

  • 2045 Posts
  • 105 Reply Likes
That does look odd indeed, not sure how that's gone unnoticed for so long ... but I don't think that's the source of your error, as iCal feeds have been working fine for most folks. On most setups the empty $_GET call will just evaluate to false and prepare() will just pass the query right through.

I'm guessing you have a large number of shows in the database ... try adding a "LIMIT 10" on that query and see what happens?
Photo of Jon Udell

Jon Udell

  • 5 Posts
  • 0 Reply Likes
Hi Derek,

So I'm not the operator of the site, just a user. I've notified them and pointed them here, so your proposed fix is something their web developer may want to try.

From my perspective, though, it looks like there's not currently a way for a user of the feed to impose a limit? For my purposes, scope=upcoming would be what I'd want, i.e.:

webcal://classical-scene.com/?feed=gigpress-ical&scope=upcoming
Photo of Derek

Derek, Developer

  • 2045 Posts
  • 105 Reply Likes
Yup, that extra bit of code in the query was wholly unnecessary on my part (a leftover of some previous approaches to that query), and it will be removed in an update, but I'm just saying that this is not the issue we're encountering here. This issue has to due with (I suspect) the server's memory limit being hit when processing the query result.
Photo of Jon Udell

Jon Udell

  • 5 Posts
  • 0 Reply Likes
OK.

In this example there seem to be somewhere between 5200 and 5300 shows:

http://classical-scene.com/?feed=gigp...
http://classical-scene.com/?feed=gigp...

Dunno if that's a huge load for that server but maybe so.

I notice that the events seem to go back to 2008:

http://classical-scene.com/?feed=gigp...

I wonder if it would make sense to add this (from gigpress_export) to gigpress-ical as a default:

$further_where = " AND show_expire >= '" . GIGPRESS_NOW . "'";

Because almost nobody cares about past events, but everybody cares about upcoming events.
Photo of Derek

Derek, Developer

  • 2045 Posts
  • 105 Reply Likes
Yup, limiting the feed to upcoming is a good idea ... originally I figured people might like having the historical record there (and some may well), and I never really anticipated someone having thousands of shows in GigPress to be honest. 5000+ shows in one go will most definitely max PHP memory on almost any server.
Photo of Jon Udell

Jon Udell

  • 5 Posts
  • 0 Reply Likes
"I never really anticipated someone having thousands of shows in GigPress to be honest."

That's a good problem to have!

Well maybe the web person for the Boston Musical Intelligencer can add that as a patch for now.

Thanks Derek, both for creating the plugin in the first place and for your helpful responsiveness here.
Photo of Derek

Derek, Developer

  • 2045 Posts
  • 105 Reply Likes
Thanks for finding the issue!
Photo of Derek

Derek, Developer

  • 2045 Posts
  • 105 Reply Likes
For the record: the iCal feed can timeout due to PHP memory limits if you have thousands of shows. This will be addressed by limited the iCal feed to upcoming shows only in an update.