Permalink
Browse files

MDL-33564 rss: on error return HTTP error status

Also remove an unecessary debugging notice.
  • Loading branch information...
danpoltawski committed Jun 13, 2013
1 parent e28004e commit 20dbcc33e8bcf93513f6f9d070aec915dc982c82
Showing with 15 additions and 10 deletions.
  1. +2 −0 lib/upgrade.txt
  2. +13 −10 rss/file.php
View
@@ -126,6 +126,8 @@ information provided here is intended especially for developers.
enrol_cohort_enrol_all_users()
enrol_cohort_search_cohorts()
* The never unused webdav_locks table was dropped.
* rss_error() now supports returning of correct HTTP status of error and will return '404 Not Found'
unless other status is specified.
=== 2.9.1 ===
View
@@ -39,7 +39,6 @@
// RSS feeds must be enabled site-wide.
if (empty($CFG->enablerssfeeds)) {
debugging('DISABLED (admin variables)');
rss_error();
}
@@ -86,14 +85,14 @@
if (empty($context)) {
// This shouldnt happen. something bad is going on.
rss_error('rsserror');
rss_error();
}
// Make sure that $CFG->siteguest is set.
if (empty($CFG->siteguest)) {
if (!$guestid = $DB->get_field('user', 'id', array('username' => 'guest', 'mnethostid' => $CFG->mnet_localhost_id))) {
// Guest does not exist yet, weird.
rss_error('rsserror');
rss_error();
}
set_config('siteguest', $guestid);
}
@@ -111,7 +110,7 @@
// Authenticate the user from the token.
$userid = rss_get_userid_from_token($token);
if (!$userid) {
rss_error('rsserrorauth');
rss_error('rsserrorauth', 'rss.xml', 0, '403 Forbidden');
}
}
@@ -134,9 +133,9 @@
require_login($course, $autologinguest, $cm, $setwantsurltome, $preventredirect);
} catch (Exception $e) {
if (isguestuser()) {
rss_error('rsserrorguest');
rss_error('rsserrorguest', 'rss.xml', 0, '403 Forbidden');
} else {
rss_error('rsserrorauth');
rss_error('rsserrorauth', 'rss.xml', 0, '403 Forbidden');
}
}
@@ -177,11 +176,15 @@
* @category rss
*
* @param string $error the error type, default is rsserror
* @param string $filename the name of the file to create (NOT USED)
* @param int $lifetime UNSURE (NOT USED)
* @param string $filename the name of the file to created
* @param int $unused
* @param $statuscode http 1.1 statuscode indicicating the error
* @uses exit
*/
function rss_error($error='rsserror', $filename='rss.xml', $lifetime=0) {
send_file(rss_geterrorxmlfile($error), $filename, $lifetime, false, true);
function rss_error($error='rsserror', $filename='rss.xml', $unused=0, $statuscode='404 Not Found') {
header("HTTP/1.1 $statuscode");
header('Content-Disposition: inline; filename="'.$filename.'"');
header('Content-Type: application/xml');
echo rss_geterrorxmlfile($error);
exit;
}

0 comments on commit 20dbcc3

Please sign in to comment.