0
votes

For more than a week I've been struggling with trying to create custom Elysia cron jobs for different feeds defined in Feed Import module.

I want to import data from feed AAA daily and data from feed BBB once a week. So two (or more if needed) separate tasks, that need be executed on different schedules. I have researched and combination of Elysia cron and Feed Import module seems to be the answer.

I have created two different feeds in Feed Import module. When I execute them manually from Feed Import everything works fine. When I run feed_import_base_cron task from Cron, it also works, but executes both feeds at the same time.

Problem starts when I want to define specific execution times for each feed. I have found a suggestion here: https://drupal.stackexchange.com/questions/30819/give-an-individual-cron-task-for-each-feeds-import But can't make it work and don't know what I'm doing wrong, as php and drupal module development are not my strengths.

I have included code from above url in Feed Import module (feed_import_base.module). I'm not 100% sure if that's the correct place, but it kinda seems to work, as the feeds I define in code, appear in Cron tasks in administrative UI. But when I try to execute them, it results with an error, which can be seen in recent log messages:

    Exception: exception 'Exception' with message 'Download of failed with code -1002.' in

    pathToMySite../drupal/sites/all/modules/feeds/plugins/FeedsHTTPFetcher.inc:33 Stack trace: #0     
    pathToMySite../drupal/sites/all/modules/feeds/plugins/FeedsSyndicationParser.inc(20): FeedsHTTPFetcherResult->getRaw() #1 
    pathToMySite../drupal/sites/all/modules/feeds/includes/FeedsSource.inc(354): FeedsSyndicationParser->parse(Object(FeedsSource), Object(FeedsHTTPFetcherResult)) #2
    pathToMySite../drupal/sites/all/modules/feed_import/feed_import_base/feed_import_base.module(622): FeedsSource->import() #3
    [internal function]: feed_import_base_fetch_test_api_feed_raw_cron(Array) #4 
    pathToMySite../drupal/sites/all/modules/elysia_cron/elysia_cron.module(1090): call_user_func_array('feed_import_bas...', Array) #5
    pathToMySite../drupal/sites/all/modules/elysia_cron/elysia_cron.admin.inc(730): elysia_cron_execute('fetch_test_api_...') #6
    [internal function]: elysia_cron_execute_page('fetch_test_api_...') #7
    pathToMySite../drupal/includes/menu.inc(519): call_user_func_array('elysia_cron_exe...', Array) #8
    pathToMySite../drupal/index.php(21): menu_execute_active_handler() #9 {main}

The actual code I use is:

function feed_import_base_cronapi($op, $job = NULL) {
  $items['fetch_test_api_feed_raw_cron'] = array(
    'description' => 'Fetch test API feed RAW',
    'rule' => '*/10 * * * *', // Every 10 minutes
    'callback' => 'feed_import_base_fetch_test_api_feed_raw_cron' ,
    'arguments' => array(array('test_api_feed_raw'))
  );
  return $items;
}

function feed_import_base_fetch_test_api_feed_raw_cron($feednames){
  if (function_exists('feeds_source')){
    foreach($feednames as $feedname){
      $source = feeds_source($feedname);
      $source->import();
    }
  }
}

I really don't know what I'm missing or doing wrong and starting to run out of options what to look for.

2

2 Answers

0
votes

I suggest, you should start debugging from the report status page. So first navigate to '/admin/reports/status' page to check if cron runs and time of cron run. Then you should check in Drupal watchdog logs for any error during cron run related to feed. Hope this will help you to debug your issue.

0
votes

Found a solution with a help from a colleague. Will post it here if someone would have need for it some day.

I'm missing a callback function here that triggers the actual feed import. I think the above mentioned function was developed for Feeds module not Feed Import. And thus also was not working here..

the actual function that triggers feed import is from feed_import_base.module

_feed_import_base_process_feed($feed);