from other users originating from Special:EmailUser.
=== New developer features in 1.34 ===
+* The ImgAuthModifyHeaders hook was added to img_auth.php to allow modification
+ of headers in private wikis.
* Language::formatTimePeriod now supports the new 'avoidhours' option to output
strings like "5 days ago" instead of "5 days 13 hours ago".
$page: ImagePage object
&$toc: Array of <li> strings
-'ImgAuthBeforeStream': executed before file is streamed to user, but only when
+'ImgAuthBeforeStream': Executed before file is streamed to user, but only when
using img_auth.php.
&$title: the Title object of the file as it would appear for the upload page
&$path: the original file and path name when img_auth was invoked by the web
$result[2 through n]=Parameters passed to body text message. Please note the
header message cannot receive/use parameters.
+'ImgAuthModifyHeaders': Executed just before a file is streamed to a user via
+img_auth.php, allowing headers to be modified beforehand.
+$title: LinkTarget object
+&$headers: HTTP headers ( name => value, names are case insensitive ).
+ Two headers get special handling: If-Modified-Since (value must be
+ a valid HTTP date) and Range (must be of the form "bytes=(\d*-\d*)")
+ will be honored when streaming the file.
+
'ImportHandleLogItemXMLTag': When parsing a XML tag in a log item.
Return false to stop further processing of the tag
$reader: XMLReader object
$headers = []; // extra HTTP headers to send
+ $title = Title::makeTitleSafe( NS_FILE, $name );
+
if ( !$publicWiki ) {
// For private wikis, run extra auth checks and set cache control headers
- $headers[] = 'Cache-Control: private';
- $headers[] = 'Vary: Cookie';
+ $headers['Cache-Control'] = 'private';
+ $headers['Vary'] = 'Cookie';
- $title = Title::makeTitleSafe( NS_FILE, $name );
if ( !$title instanceof Title ) { // files have valid titles
wfForbidden( 'img-auth-accessdenied', 'img-auth-badtitle', $name );
return;
}
}
- $options = []; // HTTP header options
if ( isset( $_SERVER['HTTP_RANGE'] ) ) {
- $options['range'] = $_SERVER['HTTP_RANGE'];
+ $headers['Range'] = $_SERVER['HTTP_RANGE'];
}
if ( isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
- $options['if-modified-since'] = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
+ $headers['If-Modified-Since'] = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
}
if ( $request->getCheck( 'download' ) ) {
- $headers[] = 'Content-Disposition: attachment';
+ $headers['Content-Disposition'] = 'attachment';
}
+ // Allow modification of headers before streaming a file
+ Hooks::run( 'ImgAuthModifyHeaders', [ $title->getTitleValue(), &$headers ] );
+
// Stream the requested file
+ list( $headers, $options ) = HTTPFileStreamer::preprocessHeaders( $headers );
wfDebugLog( 'img_auth', "Streaming `" . $filename . "`." );
$repo->streamFileWithStatus( $filename, $headers, $options );
}