On my PostgreSQL installation, the upcoming events block is always empty. It appears in the existing 1.15 version of event_database.pgsql.inc that the function event_get_events_upcoming() needs amendment, and I propose the following fix:

Change at line 121:

  $query = "SELECT n.nid, n.title, n.type, n.status, n.changed, e.event_start, e.event_end, e.timezone, e.has_time, e.has_end_date, extract('day' from event_start - '%s')*24 + cast(substring(cast(event_start - '%s' as varchar) from ' (..):') as integer) || substring(cast(event_start - '%s' as varchar) from ' ..(:..:..)') as time_left, 0 AS days_left FROM {node} n INNER JOIN {event} e ON n.nid = e.nid WHERE n.status = 1 AND (((e.event_start <> e.event_end) AND ('%s' >= e.event_start AND '%s' < e.event_end)) OR ((e.event_start = e.event_end) AND ('%s' <= e.event_start + '%d seconds')) OR e.event_start >= '%s') AND n.type IN ($placeholders) ORDER BY event_start";
  return db_query_range(db_rewrite_sql($query, 'n', 'nid', array_merge(array('event' => TRUE, 'event_get_events' => TRUE, 'event_get_events_upcoming' => TRUE, 'event_types' => $types), $rewrite_parameter)), array_merge(array($time, $time, $time, $time, $time, $time, $time, $time, (60 * 60 * 2), $time), $types), 0, $limit);

to:

  $query = "SELECT n.nid, n.title, n.type, n.status, n.changed, e.event_start, e.event_end, e.timezone, e.has_time, e.has_end_date, CAST(((CAST(EXTRACT (EPOCH FROM event_start - '%s') AS INTEGER) % (24*60*60)) * INTERVAL '1 sec') AS VARCHAR) AS time_left, CAST(EXTRACT (EPOCH FROM event_start - '%s') AS INTEGER) / (24*60*60) AS days_left FROM {node} n INNER JOIN {event} e ON n.nid = e.nid WHERE n.status = 1 AND (((e.event_start <> e.event_end) AND ('%s' >= e.event_start AND '%s' < e.event_end)) OR ((e.event_start = e.event_end) AND ('%s' <= e.event_start + '%d seconds')) OR e.event_start >= '%s') AND n.type IN ($placeholders) ORDER BY event_start";
  $query_full = db_rewrite_sql($query, 'n', 'nid', array_merge(array('event' => TRUE, 'event_get_events' => TRUE, 'event_get_events_upcoming' => TRUE, 'event_types' => $types), $rewrite_parameter));
  return db_query_range($query_full, array_merge(array($time, $time, $time, $time, $time, (60 * 60 * 2), $time), $types), 0, $limit);
CommentFileSizeAuthor
#5 event_pgsql.patch2.29 KBdeece

Comments

Liberation’s picture

For completeness, it's worth noting that the above solution displays the remaining period to the event correctly only where the user timezone and the event timezone have currently equal UTC/DST offsets. Although this will often be the case, in general it won't for a global user and event mix.

Unfortunately a full fix for this would require considerably more substantial modification to the Event module codebase, including the two MySQL source files. One approach would be to use UTC date/times as follows:

  1. In _event_block_upcoming(), invoke a (new) function _event_user_time_utc() instead of _event_user_time()
  2. In event_get_events_upcoming():
    1. Add an INNER JOIN {event_timezone} z ON e.timezone = z.timezone
    2. Change the e.event_start occurrences to e.event_start - (CASE e.start_in_dst WHEN 1 THEN z.offset_dst ELSE z.offset)

Alternatively, it might be simpler to just return the join results and do the calculations programmatically rather than in the SQL.

Not ideal, I guess, but this is quite a tricky area.

killes@www.drop.org’s picture

Status: Active » Postponed (maintainer needs more info)

Please make a proper patch.

jaime_pomales’s picture

What happened to this particular issue?

Event blocks are still broken for all versions of PostgreSQL. Sounds like you have a proposed solution. Why not finish it up and submit a patch? Do you have anything partially complete? Care to post it and let someone else work on it?

Liberation’s picture

Regrettably I've had to abandon PostgreSQL due to problems like this in numerous modules.

deece’s picture

StatusFileSize
new2.29 KB

Just got bitten by this bug. Here is the above fix as a patch against event-6.x-2.x-dev.tar.gz released on 2009-Aug-29.

Cheers

japerry’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Event for Drupal 8 is unrelated to older versions. If an issue similar to this one exists, please open a new issue with the 8.x branch.