In order to stop 'slow loading feeds' causing performance problems
with standard moodle pages, i've set the timeout for simplepie quite
low. When cron runs i've set this timeout high and cache duration low.
The intention is that cron does all the hard work of connecting to remote
sites and users get this fast fast fast from cache.
However, in the case of adding a feed its probably better to try and get the
feed more agressively..
function validation($data, $files) {
$errors = parent::validation($data, $files);
- $rss = new moodle_simplepie($data['url']);
+ $rss = new moodle_simplepie();
+ // set timeout for longer than normal to try and grab the feed
+ $rss->set_timeout(10);
+ $rss->set_feed_url($data['url']);
+ $rss->init();
if ($rss->error()) {
$errors['url'] = get_string('errorloadingfeed', 'block_rss_client', $rss->error());