MediaWiki master
thumb.php
Go to the documentation of this file.
1<?php
38use Wikimedia\AtEase\AtEase;
39
40define( 'MW_NO_OUTPUT_COMPRESSION', 1 );
41// T241340: thumb.php is included by thumb_handler.php which already defined
42// MW_ENTRY_POINT to 'thumb_handler'
43if ( !defined( 'MW_ENTRY_POINT' ) ) {
44 define( 'MW_ENTRY_POINT', 'thumb' );
45}
46require __DIR__ . '/includes/WebStart.php';
47
49
50function wfThumbMain() {
52
53 ProfilingContext::singleton()->init( MW_ENTRY_POINT, 'stream' );
54
55 // Don't use fancy MIME detection, just check the file extension for jpg/gif/png
57
58 if ( defined( 'THUMB_HANDLER' ) ) {
59 // Called from thumb_handler.php via 404; extract params from the URI...
61 } else {
62 // Called directly, use $_GET params
63 wfStreamThumb( $wgRequest->getQueryValuesOnly() );
64 }
65
66 $mediawiki = new MediaWiki();
67 $mediawiki->doPostOutputShutdown();
68}
69
75function wfThumbHandle404() {
76 global $wgThumbPath;
77
78 if ( $wgThumbPath ) {
79 $relPath = WebRequest::getRequestPathSuffix( $wgThumbPath );
80 } else {
81 // Determine the request path relative to the thumbnail zone base
82 $repo = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo();
83 $baseUrl = $repo->getZoneUrl( 'thumb' );
84 if ( substr( $baseUrl, 0, 1 ) === '/' ) {
85 $basePath = $baseUrl;
86 } else {
87 $basePath = parse_url( $baseUrl, PHP_URL_PATH );
88 }
89 $relPath = WebRequest::getRequestPathSuffix( $basePath );
90 }
91
92 $params = wfExtractThumbRequestInfo( $relPath ); // basic wiki URL param extracting
93 if ( $params == null ) {
94 wfThumbError( 400, 'The specified thumbnail parameters are not recognized.' );
95 return;
96 }
97
98 wfStreamThumb( $params ); // stream the thumbnail
99}
100
114function wfStreamThumb( array $params ) {
115 global $wgVaryOnXFP;
116
117 $headers = []; // HTTP headers to send
118
119 $fileName = $params['f'] ?? '';
120
121 // Backwards compatibility parameters
122 if ( isset( $params['w'] ) ) {
123 $params['width'] = $params['w'];
124 unset( $params['w'] );
125 }
126 if ( isset( $params['width'] ) && substr( $params['width'], -2 ) == 'px' ) {
127 // strip the px (pixel) suffix, if found
128 $params['width'] = substr( $params['width'], 0, -2 );
129 }
130 if ( isset( $params['p'] ) ) {
131 $params['page'] = $params['p'];
132 }
133
134 // Is this a thumb of an archived file?
135 $isOld = ( isset( $params['archived'] ) && $params['archived'] );
136 unset( $params['archived'] ); // handlers don't care
137
138 // Is this a thumb of a temp file?
139 $isTemp = ( isset( $params['temp'] ) && $params['temp'] );
140 unset( $params['temp'] ); // handlers don't care
141
142 $services = MediaWikiServices::getInstance();
143
144 // Some basic input validation
145 $fileName = strtr( $fileName, '\\/', '__' );
146 $localRepo = $services->getRepoGroup()->getLocalRepo();
147
148 // Actually fetch the image. Method depends on whether it is archived or not.
149 if ( $isTemp ) {
150 $repo = $localRepo->getTempRepo();
151 $img = new UnregisteredLocalFile( null, $repo,
152 # Temp files are hashed based on the name without the timestamp.
153 # The thumbnails will be hashed based on the entire name however.
154 # @todo fix this convention to actually be reasonable.
155 $repo->getZonePath( 'public' ) . '/' . $repo->getTempHashPath( $fileName ) . $fileName
156 );
157 } elseif ( $isOld ) {
158 // Format is <timestamp>!<name>
159 $bits = explode( '!', $fileName, 2 );
160 if ( count( $bits ) != 2 ) {
161 wfThumbError( 404, wfMessage( 'badtitletext' )->parse() );
162 return;
163 }
164 $title = Title::makeTitleSafe( NS_FILE, $bits[1] );
165 if ( !$title ) {
166 wfThumbError( 404, wfMessage( 'badtitletext' )->parse() );
167 return;
168 }
169 $img = $localRepo->newFromArchiveName( $title, $fileName );
170 } else {
171 $img = $localRepo->newFile( $fileName );
172 }
173
174 // Check the source file title
175 if ( !$img ) {
176 wfThumbError( 404, wfMessage( 'badtitletext' )->parse() );
177 return;
178 }
179
180 // Check permissions if there are read restrictions
181 $varyHeader = [];
182 if ( !$services->getGroupPermissionsLookup()->groupHasPermission( '*', 'read' ) ) {
183 $authority = RequestContext::getMain()->getAuthority();
184 $imgTitle = $img->getTitle();
185
186 if ( !$imgTitle || !$authority->authorizeRead( 'read', $imgTitle ) ) {
187 wfThumbError( 403, 'Access denied. You do not have permission to access ' .
188 'the source file.' );
189 return;
190 }
191 $headers[] = 'Cache-Control: private';
192 $varyHeader[] = 'Cookie';
193 }
194
195 // Check if the file is hidden
196 if ( $img->isDeleted( File::DELETED_FILE ) ) {
197 wfThumbErrorText( 404, "The source file '$fileName' does not exist." );
198 return;
199 }
200
201 // Do rendering parameters extraction from thumbnail name.
202 if ( isset( $params['thumbName'] ) ) {
203 $params = wfExtractThumbParams( $img, $params );
204 }
205 if ( $params == null ) {
206 wfThumbError( 400, 'The specified thumbnail parameters are not recognized.' );
207 return;
208 }
209
210 // Check the source file storage path
211 if ( !$img->exists() ) {
212 $redirectedLocation = false;
213 if ( !$isTemp ) {
214 // Check for file redirect
215 // Since redirects are associated with pages, not versions of files,
216 // we look for the most current version to see if its a redirect.
217 $possRedirFile = $localRepo->findFile( $img->getName() );
218 if ( $possRedirFile && $possRedirFile->getRedirected() !== null ) {
219 $redirTarget = $possRedirFile->getName();
220 $targetFile = $localRepo->newFile( Title::makeTitleSafe( NS_FILE, $redirTarget ) );
221 if ( $targetFile->exists() ) {
222 $newThumbName = $targetFile->thumbName( $params );
223 if ( $isOld ) {
225 $newThumbUrl = $targetFile->getArchiveThumbUrl(
226 $bits[0] . '!' . $targetFile->getName(), $newThumbName );
227 } else {
228 $newThumbUrl = $targetFile->getThumbUrl( $newThumbName );
229 }
230 $redirectedLocation = wfExpandUrl( $newThumbUrl, PROTO_CURRENT );
231 }
232 }
233 }
234
235 if ( $redirectedLocation ) {
236 // File has been moved. Give redirect.
237 $response = RequestContext::getMain()->getRequest()->response();
238 $response->statusHeader( 302 );
239 $response->header( 'Location: ' . $redirectedLocation );
240 $response->header( 'Expires: ' .
241 gmdate( 'D, d M Y H:i:s', time() + 12 * 3600 ) . ' GMT' );
242 if ( $wgVaryOnXFP ) {
243 $varyHeader[] = 'X-Forwarded-Proto';
244 }
245 if ( count( $varyHeader ) ) {
246 $response->header( 'Vary: ' . implode( ', ', $varyHeader ) );
247 }
248 $response->header( 'Content-Length: 0' );
249 return;
250 }
251
252 // If its not a redirect that has a target as a local file, give 404.
253 wfThumbErrorText( 404, "The source file '$fileName' does not exist." );
254 return;
255 } elseif ( $img->getPath() === false ) {
256 wfThumbErrorText( 400, "The source file '$fileName' is not locally accessible." );
257 return;
258 }
259
260 // Check IMS against the source file
261 // This means that clients can keep a cached copy even after it has been deleted on the server
262 if ( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
263 // Fix IE brokenness
264 $imsString = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
265 // Calculate time
266 AtEase::suppressWarnings();
267 $imsUnix = strtotime( $imsString );
268 AtEase::restoreWarnings();
269 if ( wfTimestamp( TS_UNIX, $img->getTimestamp() ) <= $imsUnix ) {
270 HttpStatus::header( 304 );
271 return;
272 }
273 }
274
275 $rel404 = $params['rel404'] ?? null;
276 unset( $params['r'] ); // ignore 'r' because we unconditionally pass File::RENDER
277 unset( $params['f'] ); // We're done with 'f' parameter.
278 unset( $params['rel404'] ); // moved to $rel404
279
280 // Get the normalized thumbnail name from the parameters...
281 try {
282 $thumbName = $img->thumbName( $params );
283 if ( !strlen( $thumbName ?? '' ) ) { // invalid params?
285 'Empty return from File::thumbName'
286 );
287 }
288 $thumbName2 = $img->thumbName( $params, File::THUMB_FULL_NAME ); // b/c; "long" style
291 400,
292 'The specified thumbnail parameters are not valid: ' . $e->getMessage()
293 );
294 return;
295 }
296
297 // For 404 handled thumbnails, we only use the base name of the URI
298 // for the thumb params and the parent directory for the source file name.
299 // Check that the zone relative path matches up so CDN caches won't pick
300 // up thumbs that would not be purged on source file deletion (T36231).
301 if ( $rel404 !== null ) { // thumbnail was handled via 404
302 if ( rawurldecode( $rel404 ) === $img->getThumbRel( $thumbName ) ) {
303 // Request for the canonical thumbnail name
304 } elseif ( rawurldecode( $rel404 ) === $img->getThumbRel( $thumbName2 ) ) {
305 // Request for the "long" thumbnail name; redirect to canonical name
306 $response = RequestContext::getMain()->getRequest()->response();
307 $response->statusHeader( 301 );
308 $response->header( 'Location: ' .
309 wfExpandUrl( $img->getThumbUrl( $thumbName ), PROTO_CURRENT ) );
310 $response->header( 'Expires: ' .
311 gmdate( 'D, d M Y H:i:s', time() + 7 * 86400 ) . ' GMT' );
312 if ( $wgVaryOnXFP ) {
313 $varyHeader[] = 'X-Forwarded-Proto';
314 }
315 if ( count( $varyHeader ) ) {
316 $response->header( 'Vary: ' . implode( ', ', $varyHeader ) );
317 }
318 return;
319 } else {
320 wfThumbErrorText( 404, "The given path of the specified thumbnail is incorrect;
321 expected '" . $img->getThumbRel( $thumbName ) . "' but got '" .
322 rawurldecode( $rel404 ) . "'." );
323 return;
324 }
325 }
326
327 $dispositionType = isset( $params['download'] ) ? 'attachment' : 'inline';
328
329 // Suggest a good name for users downloading this thumbnail
330 $headers[] =
331 'Content-Disposition: ' . $img->getThumbDisposition( $thumbName, $dispositionType );
332
333 if ( count( $varyHeader ) ) {
334 $headers[] = 'Vary: ' . implode( ', ', $varyHeader );
335 }
336
337 // Stream the file if it exists already...
338 $thumbPath = $img->getThumbPath( $thumbName );
339 if ( $img->getRepo()->fileExists( $thumbPath ) ) {
340 $starttime = microtime( true );
341 $status = $img->getRepo()->streamFileWithStatus( $thumbPath, $headers );
342 $streamtime = microtime( true ) - $starttime;
343
344 if ( $status->isOK() ) {
345 $services->getStatsdDataFactory()->timing(
346 'media.thumbnail.stream', $streamtime
347 );
348 } else {
349 wfThumbError( 500, 'Could not stream the file', null, [ 'file' => $thumbName,
350 'path' => $thumbPath, 'error' => $status->getWikiText( false, false, 'en' ) ] );
351 }
352 return;
353 }
354
355 $authority = RequestContext::getMain()->getAuthority();
356 $status = PermissionStatus::newEmpty();
357 if ( !wfThumbIsStandard( $img, $params )
358 && !$authority->authorizeAction( 'renderfile-nonstandard', $status )
359 ) {
360 $statusFormatter = $services->getFormatterFactory()
361 ->getStatusFormatter( RequestContext::getMain() );
362
363 wfThumbError( 429, $statusFormatter->getHTML( $status ) );
364 return;
365 } elseif ( !$authority->authorizeAction( 'renderfile', $status ) ) {
366 $statusFormatter = $services->getFormatterFactory()
367 ->getStatusFormatter( RequestContext::getMain() );
368
369 wfThumbError( 429, $statusFormatter->getHTML( $status ) );
370 return;
371 }
372
373 $thumbProxyUrl = $img->getRepo()->getThumbProxyUrl();
374
375 if ( strlen( $thumbProxyUrl ?? '' ) ) {
376 wfProxyThumbnailRequest( $img, $thumbName );
377 // No local fallback when in proxy mode
378 return;
379 } else {
380 // Generate the thumbnail locally
381 [ $thumb, $errorMsg ] = wfGenerateThumbnail( $img, $params, $thumbName, $thumbPath );
382 }
383
386 // Check for thumbnail generation errors...
387 $msg = wfMessage( 'thumbnail_error' );
388 $errorCode = 500;
389
390 if ( !$thumb ) {
391 $errorMsg = $errorMsg ?: $msg->rawParams( 'File::transform() returned false' )->escaped();
392 if ( $errorMsg instanceof MessageSpecifier &&
393 $errorMsg->getKey() === 'thumbnail_image-failure-limit'
394 ) {
395 $errorCode = 429;
396 }
397 } elseif ( $thumb->isError() ) {
398 $errorMsg = $thumb->getHtmlMsg();
399 $errorCode = $thumb->getHttpStatusCode();
400 } elseif ( !$thumb->hasFile() ) {
401 $errorMsg = $msg->rawParams( 'No path supplied in thumbnail object' )->escaped();
402 } elseif ( $thumb->fileIsSource() ) {
403 $errorMsg = $msg
404 ->rawParams( 'Image was not scaled, is the requested width bigger than the source?' )
405 ->escaped();
406 $errorCode = 400;
407 }
408
409 if ( $errorMsg !== false ) {
410 wfThumbError( $errorCode, $errorMsg, null, [ 'file' => $thumbName, 'path' => $thumbPath ] );
411 } else {
412 // Stream the file if there were no errors
413 $status = $thumb->streamFileWithStatus( $headers );
414 if ( !$status->isOK() ) {
415 wfThumbError( 500, 'Could not stream the file', null, [
416 'file' => $thumbName, 'path' => $thumbPath,
417 'error' => $status->getWikiText( false, false, 'en' ) ] );
418 }
419 }
420}
421
428function wfProxyThumbnailRequest( $img, $thumbName ) {
429 $thumbProxyUrl = $img->getRepo()->getThumbProxyUrl();
430
431 // Instead of generating the thumbnail ourselves, we proxy the request to another service
432 $thumbProxiedUrl = $thumbProxyUrl . $img->getThumbRel( $thumbName );
433
434 $req = MediaWikiServices::getInstance()->getHttpRequestFactory()->create( $thumbProxiedUrl );
435 $secret = $img->getRepo()->getThumbProxySecret();
436
437 // Pass a secret key shared with the proxied service if any
438 if ( strlen( $secret ?? '' ) ) {
439 $req->setHeader( 'X-Swift-Secret', $secret );
440 }
441
442 // Send request to proxied service
443 $req->execute();
444
445 \MediaWiki\Request\HeaderCallback::warnIfHeadersSent();
446
447 // Simply serve the response from the proxied service as-is
448 header( 'HTTP/1.1 ' . $req->getStatus() );
449
450 $headers = $req->getResponseHeaders();
451
452 foreach ( $headers as $key => $values ) {
453 foreach ( $values as $value ) {
454 header( $key . ': ' . $value, false );
455 }
456 }
457
458 echo $req->getContent();
459}
460
470function wfGenerateThumbnail( File $file, array $params, $thumbName, $thumbPath ) {
472
473 $cache = ObjectCache::getLocalClusterInstance();
474 $key = $cache->makeKey(
475 'attempt-failures',
477 $file->getRepo()->getName(),
478 $file->getSha1(),
479 md5( $thumbName )
480 );
481
482 // Check if this file keeps failing to render
483 if ( $cache->get( $key ) >= 4 ) {
484 return [ false, wfMessage( 'thumbnail_image-failure-limit', 4 ) ];
485 }
486
487 $done = false;
488 // Record failures on PHP fatals in addition to caching exceptions
489 register_shutdown_function( static function () use ( $cache, &$done, $key ) {
490 if ( !$done ) { // transform() gave a fatal
491 // Randomize TTL to reduce stampedes
492 $cache->incrWithInit( $key, $cache::TTL_HOUR + mt_rand( 0, 300 ) );
493 }
494 } );
495
496 $thumb = false;
497 $errorHtml = false;
498
499 // guard thumbnail rendering with PoolCounter to avoid stampedes
500 // expensive files use a separate PoolCounter config so it is possible
501 // to set up a global limit on them
502 if ( $file->isExpensiveToThumbnail() ) {
503 $poolCounterType = 'FileRenderExpensive';
504 } else {
505 $poolCounterType = 'FileRender';
506 }
507
508 // Thumbnail isn't already there, so create the new thumbnail...
509 try {
510 $work = new PoolCounterWorkViaCallback( $poolCounterType, sha1( $file->getName() ),
511 [
512 'doWork' => static function () use ( $file, $params ) {
513 return $file->transform( $params, File::RENDER_NOW );
514 },
515 'doCachedWork' => static function () use ( $file, $params, $thumbPath ) {
516 // If the worker that finished made this thumbnail then use it.
517 // Otherwise, it probably made a different thumbnail for this file.
518 return $file->getRepo()->fileExists( $thumbPath )
519 ? $file->transform( $params, File::RENDER_NOW )
520 : false; // retry once more in exclusive mode
521 },
522 'error' => static function ( Status $status ) {
523 return wfMessage( 'generic-pool-error' )->parse() . '<hr>' . $status->getHTML();
524 }
525 ]
526 );
527 $result = $work->execute();
528 if ( $result instanceof MediaTransformOutput ) {
529 $thumb = $result;
530 } elseif ( is_string( $result ) ) { // error
531 $errorHtml = $result;
532 }
533 } catch ( Exception $e ) {
534 // Tried to select a page on a non-paged file?
535 }
536
538 $done = true; // no PHP fatal occurred
539
540 if ( !$thumb || $thumb->isError() ) {
541 // Randomize TTL to reduce stampedes
542 $cache->incrWithInit( $key, $cache::TTL_HOUR + mt_rand( 0, 300 ) );
543 }
544
545 return [ $thumb, $errorHtml ];
546}
547
567function wfExtractThumbRequestInfo( $thumbRel ) {
568 $repo = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo();
569
570 $hashDirReg = $subdirReg = '';
571 $hashLevels = $repo->getHashLevels();
572 for ( $i = 0; $i < $hashLevels; $i++ ) {
573 $subdirReg .= '[0-9a-f]';
574 $hashDirReg .= "$subdirReg/";
575 }
576
577 // Check if this is a thumbnail of an original in the local file repo
578 if ( preg_match( "!^((archive/)?$hashDirReg([^/]*)/([^/]*))$!", $thumbRel, $m ) ) {
579 [ /*all*/, $rel, $archOrTemp, $filename, $thumbname ] = $m;
580 // Check if this is a thumbnail of a temp file in the local file repo
581 } elseif ( preg_match( "!^(temp/)($hashDirReg([^/]*)/([^/]*))$!", $thumbRel, $m ) ) {
582 [ /*all*/, $archOrTemp, $rel, $filename, $thumbname ] = $m;
583 } else {
584 return null; // not a valid looking thumbnail request
585 }
586
587 $params = [ 'f' => $filename, 'rel404' => $rel ];
588 if ( $archOrTemp === 'archive/' ) {
589 $params['archived'] = 1;
590 } elseif ( $archOrTemp === 'temp/' ) {
591 $params['temp'] = 1;
592 }
593
594 $params['thumbName'] = $thumbname;
595 return $params;
596}
597
606function wfExtractThumbParams( $file, $params ) {
607 if ( !isset( $params['thumbName'] ) ) {
608 throw new InvalidArgumentException( "No thumbnail name passed to wfExtractThumbParams" );
609 }
610
611 $thumbname = $params['thumbName'];
612 unset( $params['thumbName'] );
613
614 // FIXME: Files in the temp zone don't set a MIME type, which means
615 // they don't have a handler. Which means we can't parse the param
616 // string. However, not a big issue as what good is a param string
617 // if you have no handler to make use of the param string and
618 // actually generate the thumbnail.
619 $handler = $file->getHandler();
620
621 // Based on UploadStash::parseKey
622 $fileNamePos = strrpos( $thumbname, $params['f'] );
623 if ( $fileNamePos === false ) {
624 // Maybe using a short filename? (see FileRepo::nameForThumb)
625 $fileNamePos = strrpos( $thumbname, 'thumbnail' );
626 }
627
628 if ( $handler && $fileNamePos !== false ) {
629 $paramString = substr( $thumbname, 0, $fileNamePos - 1 );
630 $extraParams = $handler->parseParamString( $paramString );
631 if ( $extraParams !== false ) {
632 return $params + $extraParams;
633 }
634 }
635
636 // As a last ditch fallback, use the traditional common parameters
637 if ( preg_match( '!^(page(\d*)-)*(\d*)px-[^/]*$!', $thumbname, $matches ) ) {
638 [ /* all */, /* pagefull */, $pagenum, $size ] = $matches;
639 $params['width'] = $size;
640 if ( $pagenum ) {
641 $params['page'] = $pagenum;
642 }
643 return $params; // valid thumbnail URL
644 }
645 return null;
646}
647
655function wfThumbErrorText( $status, $msgText ) {
656 wfThumbError( $status, htmlspecialchars( $msgText, ENT_NOQUOTES ) );
657}
658
669function wfThumbError( $status, $msgHtml, $msgText = null, $context = [] ) {
670 global $wgShowHostnames;
671
672 \MediaWiki\Request\HeaderCallback::warnIfHeadersSent();
673
674 if ( headers_sent() ) {
675 LoggerFactory::getInstance( 'thumbnail' )->error(
676 'Error after output had been started. Output may be corrupt or truncated. ' .
677 'Original error: ' . ( $msgText ?: $msgHtml ) . " (Status $status)",
678 $context
679 );
680 return;
681 }
682
683 header( 'Cache-Control: no-cache' );
684 header( 'Content-Type: text/html; charset=utf-8' );
685 if ( $status == 400 || $status == 404 || $status == 429 ) {
686 HttpStatus::header( $status );
687 } elseif ( $status == 403 ) {
688 HttpStatus::header( 403 );
689 header( 'Vary: Cookie' );
690 } else {
691 LoggerFactory::getInstance( 'thumbnail' )->error( $msgText ?: $msgHtml, $context );
692 HttpStatus::header( 500 );
693 }
694 if ( $wgShowHostnames ) {
695 header( 'X-MW-Thumbnail-Renderer: ' . wfHostname() );
696 $url = htmlspecialchars(
697 $_SERVER['REQUEST_URI'] ?? '',
698 ENT_NOQUOTES
699 );
700 $hostname = htmlspecialchars( wfHostname(), ENT_NOQUOTES );
701 $debug = "<!-- $url -->\n<!-- $hostname -->\n";
702 } else {
703 $debug = '';
704 }
705 $content = <<<EOT
706<!DOCTYPE html>
707<html><head>
708<meta charset="UTF-8" />
709<title>Error generating thumbnail</title>
710</head>
711<body>
712<h1>Error generating thumbnail</h1>
713<p>
714$msgHtml
715</p>
716$debug
717</body>
718</html>
719
720EOT;
721 header( 'Content-Length: ' . strlen( $content ) );
722 echo $content;
723}
const NS_FILE
Definition Defines.php:70
const PROTO_CURRENT
Definition Defines.php:205
wfThumbIsStandard(File $file, array $params)
Returns true if these thumbnail parameters match one that MediaWiki requests from file description pa...
wfHostname()
Get host name of the current machine, for use in error reporting.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL using $wgServer (or one of its alternatives).
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
global $wgRequest
Definition Setup.php:415
const MW_ENTRY_POINT
Definition api.php:35
Implements some public methods and some protected utility functions which are required by multiple ch...
Definition File.php:73
isExpensiveToThumbnail()
True if creating thumbnails from the file is large or otherwise resource-intensive.
Definition File.php:2485
getName()
Return the name of this file.
Definition File.php:341
getRepo()
Returns the repository.
Definition File.php:2050
transform( $params, $flags=0)
Transform a media file.
Definition File.php:1177
getSha1()
Get the SHA-1 base 36 hash of the file.
Definition File.php:2331
Basic media transform error class.
MediaWiki exception thrown by some methods when the transform parameter array is invalid.
Base class for the output of MediaHandler::doTransform() and File::transform().
Group all the pieces relevant to the context of a request into one instance.
Create PSR-3 logger objects.
Service locator for MediaWiki core services.
A StatusValue for permission errors.
Convenience class for dealing with PoolCounter using callbacks.
execute( $skipcache=false)
Get the result of the work (whatever it is), or the result of the error() function.
Class for tracking request-level classification information for profiling/stats/logging.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition Status.php:54
Represents a title within MediaWiki.
Definition Title.php:78
File without associated database record.
$wgShowHostnames
Config variable stub for the ShowHostnames setting, for use by phpdoc and IDEs.
$wgThumbPath
Config variable stub for the ThumbPath setting, for use by phpdoc and IDEs.
$wgVaryOnXFP
Config variable stub for the VaryOnXFP setting, for use by phpdoc and IDEs.
$wgAttemptFailureEpoch
Config variable stub for the AttemptFailureEpoch setting, for use by phpdoc and IDEs.
$wgTrivialMimeDetection
Config variable stub for the TrivialMimeDetection setting, for use by phpdoc and IDEs.
$mediawiki
Definition img_auth.php:54
getKey()
Returns the message key.
A helper class for throttling authentication attempts.
wfThumbHandle404()
Handle a thumbnail request via thumbnail file URL.
Definition thumb.php:75
wfThumbError( $status, $msgHtml, $msgText=null, $context=[])
Output a thumbnail generation error message.
Definition thumb.php:669
wfStreamThumb(array $params)
Stream a thumbnail specified by parameters.
Definition thumb.php:114
wfGenerateThumbnail(File $file, array $params, $thumbName, $thumbPath)
Actually try to generate a new thumbnail.
Definition thumb.php:470
wfProxyThumbnailRequest( $img, $thumbName)
Proxies thumbnail request to a service that handles thumbnailing.
Definition thumb.php:428
wfExtractThumbRequestInfo( $thumbRel)
Convert pathinfo type parameter, into normal request parameters.
Definition thumb.php:567
wfThumbMain()
Definition thumb.php:50
wfThumbErrorText( $status, $msgText)
Output a thumbnail generation error message.
Definition thumb.php:655
wfExtractThumbParams( $file, $params)
Convert a thumbnail name (122px-foo.png) to parameters, using file handler.
Definition thumb.php:606