From: daniel Date: Thu, 18 Oct 2012 10:58:25 +0000 (+0200) Subject: [Bug 41128] Handle null content in action=raw. X-Git-Tag: 1.31.0-rc.0~21968 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=acedeeb36094aacba7612cecd93086aea24ed98b;p=lhc%2Fweb%2Fwiklou.git [Bug 41128] Handle null content in action=raw. In RawAction, there are several cases in which we have null instead of a Content object. Most importanty, this applied for deleted revisions and missing sections. Handle these cases gracefully. Change-Id: Iac8560755718a46dcc4dcf118322a66d1caefdae --- diff --git a/includes/actions/RawAction.php b/includes/actions/RawAction.php index ec3d60a10b..71cb397dd7 100644 --- a/includes/actions/RawAction.php +++ b/includes/actions/RawAction.php @@ -150,18 +150,28 @@ class RawAction extends FormlessAction { // Public-only due to cache headers $content = $rev->getContent(); - if ( !$content instanceof TextContent ) { + if ( $content === null ) { + // revision not found (or suppressed) + $text = false; + } elseif ( !$content instanceof TextContent ) { + // non-text content wfHttpError( 415, "Unsupported Media Type", "The requested page uses the content model `" . $content->getModel() . "` which is not supported via this interface." ); die(); + } else { + // want a section? + $section = $request->getIntOrNull( 'section' ); + if ( $section !== null ) { + $content = $content->getSection( $section ); + } + + if ( $content === null || $content === false ) { + // section not found (or section not supported, e.g. for JS and CSS) + $text = false; + } else { + $text = $content->getNativeData(); + } } - - $section = $request->getIntOrNull( 'section' ); - if ( $section !== null ) { - $content = $content->getSection( $section ); - } - - $text = $content->getNativeData(); } }