Index: feedapi.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/feedapi/feedapi.module,v
retrieving revision 1.23.2.119.2.57
diff -u -p -r1.23.2.119.2.57 feedapi.module
--- feedapi.module	5 Jun 2009 13:32:47 -0000	1.23.2.119.2.57
+++ feedapi.module	16 Jun 2009 14:42:38 -0000
@@ -669,6 +669,12 @@ function feedapi_feedapi_settings_form($
  * Implementation of hook_cron().
  */
 function feedapi_cron() {
+  global $user;
+  
+  // Saves the currently logged in user and start safe impersonating
+  $original_user = $user;
+  session_save_session(FALSE);
+  
   db_query('DELETE FROM {feedapi_stat} WHERE timestamp < %d', variable_get('cron_semaphore', FALSE) - FEEDAPI_CRON_STAT_LIFETIME);
   
   // Initialize counters
@@ -686,9 +692,10 @@ function feedapi_cron() {
   // The counter process will be > 0 if we've selected less feeds
   while (!$process && feedapi_cron_time()) {
     $process = FEEDAPI_CRON_FEEDS;
-    $result = db_query_range("SELECT f.nid FROM {feedapi} f JOIN {node} n ON n.vid = f.vid WHERE next_refresh_time < %d AND next_refresh_time <> %d ORDER BY next_refresh_time ASC", $now, FEEDAPI_CRON_NEVER_REFRESH, 0, FEEDAPI_CRON_FEEDS);
+    $result = db_query_range("SELECT f.nid, n.uid FROM {feedapi} f JOIN {node} n ON n.vid = f.vid WHERE next_refresh_time < %d AND next_refresh_time <> %d ORDER BY next_refresh_time ASC", $now, FEEDAPI_CRON_NEVER_REFRESH, 0, FEEDAPI_CRON_FEEDS);
 
     while (feedapi_cron_time() && $feed = db_fetch_object($result)) {
+      $user = user_load(array('uid' => $feed->uid));
       // Call the refresh process for each feed and store counters
       $counter = feedapi_invoke('refresh', $feed, TRUE);
       if ($counter) {
@@ -700,6 +707,10 @@ function feedapi_cron() {
       $process--;
     }
   }
+  
+  // Loads back the logged in user
+  $user = $original_user;
+  session_save_session(TRUE);
 }
 
 /**
