From e73cb1acb8215b8c3cccf2dfb20ca2deb43bea69 Mon Sep 17 00:00:00 2001 From: Jason Fowler Date: Mon, 18 Mar 2013 16:02:58 +0800 Subject: [PATCH] MDL-37818 - RSS - Prevent access to blocks while RSS context errors are displayed --- rss/file.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/rss/file.php b/rss/file.php index b9896db3781..d7e47c8f4f8 100644 --- a/rss/file.php +++ b/rss/file.php @@ -122,6 +122,11 @@ if ($token==="$inttoken") { } } +// Check the context actually exists +list($context, $course, $cm) = get_context_info_array($contextid); + +$PAGE->set_context($context); + $user = get_complete_user_data('id', $userid); // let enrol plugins deal with new enrolments if necessary @@ -129,14 +134,6 @@ enrol_check_plugins($user); session_set_user($user); //for login and capability checks -// Check the context actually exists -list($context, $course, $cm) = get_context_info_array($contextid); - -if (!$context) { - rss_error(); -} -$PAGE->set_context($context); - try { $autologinguest = true; $setwantsurltome = true; @@ -165,7 +162,11 @@ if (file_exists($componentdir)) { if (function_exists($functionname)) { // $pathname will be null if there was a problem (eg user doesn't have the necessary capabilities) // NOTE:the component providing the feed must do its own capability checks and security - $pathname = $functionname($context, $args); + try { + $pathname = $functionname($context, $args); + } catch (Exception $e) { + rss_error('rsserror'); + } } }