It would be nice to choose how long it takes to clear the cache version of your feed items. Could be usefull for a feed that produces a lot of items. The 3600s which is the standard cache time is too long in that case. Not all the items in the feed would of been imported.
Here is how it could be implemented:
A simple line in parser simple pie module setting the cache time of the parser object.
/**
* Set SimplePie setting
* @param $url
* The feed's url
* @return
* SimplePie object
*/
function _parser_simplepie_get_parser($url, $enable_cache = TRUE) {
require_once(drupal_get_path('module', 'parser_simplepie') .'/simplepie.inc');
$parser = new SimplePie();
$parser->set_feed_url($url);
$parser->set_timeout(15);
$parser->set_stupidly_fast(TRUE);
$parser->encode_instead_of_strip(FALSE);
$cache_location = _parser_simplepie_sanitize_cache();
$parser->enable_cache($cache_location !== FALSE ? $enable_cache : FALSE);
//This sets the cache time
$parser->set_cache_duration(variable_get('feedapi_cache_time', '3600'));
$parser->set_cache_location($cache_location);
$parser->init();
return $parser;
}
And in the feedapi module we should add a form field.
return system_settings_form($form);
* Settings: allowed HTML tags, number of feeds refreshed in one round
*/
function feedapi_admin_settings() {
$form['feedapi_allowed_html_tags'] = array(
'#type' => 'textfield', '#title' => t('Allowed HTML tags'), '#size' => 80, '#maxlength' => 255,
'#default_value' => variable_get('feedapi_allowed_html_tags', '
'),
'#description' => t('The list of tags which are allowed in feeds, i.e., which will not be removed by Drupal.')
);
$form['feedapi_allow_html_all'] = array(
'#type' => 'checkbox', '#title' => t('Allow all HTML tags'),
'#default_value' => variable_get('feedapi_allow_html_all', FALSE),
'#description' => t('In this case the module does\'t filter any HTML elements from the incoming fields. This checkbox overrides the above list of allowed tags.')
);
if (variable_get('feedapi_allow_html_all', FALSE)) {
$form['feedapi_allowed_html_tags']['#disabled'] = TRUE;
}
// Drupal will try to overwrite this value at cron time
$max_exec = !ini_get('safe_mode') ? 240 : ini_get('max_execution_time');
$form['feedapi_cron_percentage'] = array(
'#type' => 'select',
'#title' => t('Cron time for FeedAPI [%]'),
'#options' => drupal_map_assoc(array(15, 25, 50, 75)),
'#default_value' => variable_get('feedapi_cron_percentage', 15),
'#description' => t('Percentage of maximal PHP execution time (currently !exec seconds). At current settings, the FeedAPI cron process can run for up to !now seconds.',
array("!exec" => $max_exec, "!now" => (variable_get('feedapi_cron_percentage', 15) / 100) * $max_exec)),
);
//to set the cache time
$form['feedapi_cache_time'] = array(
'#type' => 'textfield',
'#title' => t('Cache time in seconds'),
'#size' => 80,
'#maxlength' => 255,
'#default_value' => variable_get('feedapi_cache_time', '3600'),
'#description' => t('Time feedapi uses cached version when looking for new feeds to import')
);
}
Comments
Comment #1
aron novakThank you for the suggestion.
I implemented it a little bit differently, you can configure this setting under the content-type edit form.
Notice that feedapi has a hard-limit itself:
in feedapi.module
So you may want to alter this value as well.
The next daily build will contain the fix.
If you want to patch your old version:
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/feedapi/par...
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/feedapi/fee...