MediaWiki  master
thumb.php
Go to the documentation of this file.
1 <?php
31 
32 define( 'MW_NO_OUTPUT_COMPRESSION', 1 );
33 // T241340: thumb.php is included by thumb_handler.php which already defined
34 // MW_ENTRY_POINT to 'thumb_handler'
35 if ( !defined( 'MW_ENTRY_POINT' ) ) {
36  define( 'MW_ENTRY_POINT', 'thumb' );
37 }
38 require __DIR__ . '/includes/WebStart.php';
39 
40 wfThumbMain();
41 
42 function wfThumbMain() {
44 
45  // Don't use fancy MIME detection, just check the file extension for jpg/gif/png
47 
48  if ( defined( 'THUMB_HANDLER' ) ) {
49  // Called from thumb_handler.php via 404; extract params from the URI...
51  } else {
52  // Called directly, use $_GET params
53  wfStreamThumb( $wgRequest->getQueryValuesOnly() );
54  }
55 
56  $mediawiki = new MediaWiki();
57  $mediawiki->doPostOutputShutdown();
58 }
59 
65 function wfThumbHandle404() {
66  global $wgThumbPath;
67 
68  if ( $wgThumbPath ) {
70  } else {
71  // Determine the request path relative to the thumbnail zone base
72  $repo = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo();
73  $baseUrl = $repo->getZoneUrl( 'thumb' );
74  if ( substr( $baseUrl, 0, 1 ) === '/' ) {
75  $basePath = $baseUrl;
76  } else {
77  $basePath = parse_url( $baseUrl, PHP_URL_PATH );
78  }
79  $relPath = WebRequest::getRequestPathSuffix( $basePath );
80  }
81 
82  $params = wfExtractThumbRequestInfo( $relPath ); // basic wiki URL param extracting
83  if ( $params == null ) {
84  wfThumbError( 400, 'The specified thumbnail parameters are not recognized.' );
85  return;
86  }
87 
88  wfStreamThumb( $params ); // stream the thumbnail
89 }
90 
104 function wfStreamThumb( array $params ) {
105  global $wgVaryOnXFP;
106  $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
107 
108  $headers = []; // HTTP headers to send
109 
110  $fileName = $params['f'] ?? '';
111 
112  // Backwards compatibility parameters
113  if ( isset( $params['w'] ) ) {
114  $params['width'] = $params['w'];
115  unset( $params['w'] );
116  }
117  if ( isset( $params['width'] ) && substr( $params['width'], -2 ) == 'px' ) {
118  // strip the px (pixel) suffix, if found
119  $params['width'] = substr( $params['width'], 0, -2 );
120  }
121  if ( isset( $params['p'] ) ) {
122  $params['page'] = $params['p'];
123  }
124 
125  // Is this a thumb of an archived file?
126  $isOld = ( isset( $params['archived'] ) && $params['archived'] );
127  unset( $params['archived'] ); // handlers don't care
128 
129  // Is this a thumb of a temp file?
130  $isTemp = ( isset( $params['temp'] ) && $params['temp'] );
131  unset( $params['temp'] ); // handlers don't care
132 
133  // Some basic input validation
134  $fileName = strtr( $fileName, '\\/', '__' );
135  $localRepo = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo();
136 
137  // Actually fetch the image. Method depends on whether it is archived or not.
138  if ( $isTemp ) {
139  $repo = $localRepo->getTempRepo();
140  $img = new UnregisteredLocalFile( null, $repo,
141  # Temp files are hashed based on the name without the timestamp.
142  # The thumbnails will be hashed based on the entire name however.
143  # @todo fix this convention to actually be reasonable.
144  $repo->getZonePath( 'public' ) . '/' . $repo->getTempHashPath( $fileName ) . $fileName
145  );
146  } elseif ( $isOld ) {
147  // Format is <timestamp>!<name>
148  $bits = explode( '!', $fileName, 2 );
149  if ( count( $bits ) != 2 ) {
150  wfThumbError( 404, wfMessage( 'badtitletext' )->parse() );
151  return;
152  }
153  $title = Title::makeTitleSafe( NS_FILE, $bits[1] );
154  if ( !$title ) {
155  wfThumbError( 404, wfMessage( 'badtitletext' )->parse() );
156  return;
157  }
158  $img = $localRepo->newFromArchiveName( $title, $fileName );
159  } else {
160  $img = $localRepo->newFile( $fileName );
161  }
162 
163  // Check the source file title
164  if ( !$img ) {
165  wfThumbError( 404, wfMessage( 'badtitletext' )->parse() );
166  return;
167  }
168 
169  // Check permissions if there are read restrictions
170  $varyHeader = [];
171  if ( !in_array( 'read', $permissionManager->getGroupPermissions( [ '*' ] ), true ) ) {
172  $user = RequestContext::getMain()->getUser();
173  $imgTitle = $img->getTitle();
174 
175  if ( !$imgTitle || !$permissionManager->userCan( 'read', $user, $imgTitle ) ) {
176  wfThumbError( 403, 'Access denied. You do not have permission to access ' .
177  'the source file.' );
178  return;
179  }
180  $headers[] = 'Cache-Control: private';
181  $varyHeader[] = 'Cookie';
182  }
183 
184  // Check if the file is hidden
185  if ( $img->isDeleted( File::DELETED_FILE ) ) {
186  wfThumbErrorText( 404, "The source file '$fileName' does not exist." );
187  return;
188  }
189 
190  // Do rendering parameters extraction from thumbnail name.
191  if ( isset( $params['thumbName'] ) ) {
192  $params = wfExtractThumbParams( $img, $params );
193  }
194  if ( $params == null ) {
195  wfThumbError( 400, 'The specified thumbnail parameters are not recognized.' );
196  return;
197  }
198 
199  // Check the source file storage path
200  if ( !$img->exists() ) {
201  $redirectedLocation = false;
202  if ( !$isTemp ) {
203  // Check for file redirect
204  // Since redirects are associated with pages, not versions of files,
205  // we look for the most current version to see if its a redirect.
206  $possRedirFile = $localRepo->findFile( $img->getName() );
207  if ( $possRedirFile && $possRedirFile->getRedirected() !== null ) {
208  $redirTarget = $possRedirFile->getName();
209  $targetFile = $localRepo->newFile( Title::makeTitleSafe( NS_FILE, $redirTarget ) );
210  if ( $targetFile->exists() ) {
211  $newThumbName = $targetFile->thumbName( $params );
212  if ( $isOld ) {
214  $newThumbUrl = $targetFile->getArchiveThumbUrl(
215  $bits[0] . '!' . $targetFile->getName(), $newThumbName );
216  } else {
217  $newThumbUrl = $targetFile->getThumbUrl( $newThumbName );
218  }
219  $redirectedLocation = wfExpandUrl( $newThumbUrl, PROTO_CURRENT );
220  }
221  }
222  }
223 
224  if ( $redirectedLocation ) {
225  // File has been moved. Give redirect.
226  $response = RequestContext::getMain()->getRequest()->response();
227  $response->statusHeader( 302 );
228  $response->header( 'Location: ' . $redirectedLocation );
229  $response->header( 'Expires: ' .
230  gmdate( 'D, d M Y H:i:s', time() + 12 * 3600 ) . ' GMT' );
231  if ( $wgVaryOnXFP ) {
232  $varyHeader[] = 'X-Forwarded-Proto';
233  }
234  if ( count( $varyHeader ) ) {
235  $response->header( 'Vary: ' . implode( ', ', $varyHeader ) );
236  }
237  $response->header( 'Content-Length: 0' );
238  return;
239  }
240 
241  // If its not a redirect that has a target as a local file, give 404.
242  wfThumbErrorText( 404, "The source file '$fileName' does not exist." );
243  return;
244  } elseif ( $img->getPath() === false ) {
245  wfThumbErrorText( 400, "The source file '$fileName' is not locally accessible." );
246  return;
247  }
248 
249  // Check IMS against the source file
250  // This means that clients can keep a cached copy even after it has been deleted on the server
251  if ( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
252  // Fix IE brokenness
253  $imsString = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
254  // Calculate time
255  Wikimedia\suppressWarnings();
256  $imsUnix = strtotime( $imsString );
257  Wikimedia\restoreWarnings();
258  if ( wfTimestamp( TS_UNIX, $img->getTimestamp() ) <= $imsUnix ) {
259  HttpStatus::header( 304 );
260  return;
261  }
262  }
263 
264  $rel404 = $params['rel404'] ?? null;
265  unset( $params['r'] ); // ignore 'r' because we unconditionally pass File::RENDER
266  unset( $params['f'] ); // We're done with 'f' parameter.
267  unset( $params['rel404'] ); // moved to $rel404
268 
269  // Get the normalized thumbnail name from the parameters...
270  try {
271  $thumbName = $img->thumbName( $params );
272  if ( !strlen( $thumbName ) ) { // invalid params?
274  'Empty return from File::thumbName'
275  );
276  }
277  $thumbName2 = $img->thumbName( $params, File::THUMB_FULL_NAME ); // b/c; "long" style
279  wfThumbError(
280  400,
281  'The specified thumbnail parameters are not valid: ' . $e->getMessage()
282  );
283  return;
284  } catch ( MWException $e ) {
285  wfThumbError( 500, $e->getHTML(), 'Exception caught while extracting thumb name',
286  [ 'exception' => $e ] );
287  return;
288  }
289 
290  // For 404 handled thumbnails, we only use the base name of the URI
291  // for the thumb params and the parent directory for the source file name.
292  // Check that the zone relative path matches up so CDN caches won't pick
293  // up thumbs that would not be purged on source file deletion (T36231).
294  if ( $rel404 !== null ) { // thumbnail was handled via 404
295  if ( rawurldecode( $rel404 ) === $img->getThumbRel( $thumbName ) ) {
296  // Request for the canonical thumbnail name
297  } elseif ( rawurldecode( $rel404 ) === $img->getThumbRel( $thumbName2 ) ) {
298  // Request for the "long" thumbnail name; redirect to canonical name
299  $response = RequestContext::getMain()->getRequest()->response();
300  $response->statusHeader( 301 );
301  $response->header( 'Location: ' .
302  wfExpandUrl( $img->getThumbUrl( $thumbName ), PROTO_CURRENT ) );
303  $response->header( 'Expires: ' .
304  gmdate( 'D, d M Y H:i:s', time() + 7 * 86400 ) . ' GMT' );
305  if ( $wgVaryOnXFP ) {
306  $varyHeader[] = 'X-Forwarded-Proto';
307  }
308  if ( count( $varyHeader ) ) {
309  $response->header( 'Vary: ' . implode( ', ', $varyHeader ) );
310  }
311  return;
312  } else {
313  wfThumbErrorText( 404, "The given path of the specified thumbnail is incorrect;
314  expected '" . $img->getThumbRel( $thumbName ) . "' but got '" .
315  rawurldecode( $rel404 ) . "'." );
316  return;
317  }
318  }
319 
320  $dispositionType = isset( $params['download'] ) ? 'attachment' : 'inline';
321 
322  // Suggest a good name for users downloading this thumbnail
323  $headers[] =
324  "Content-Disposition: {$img->getThumbDisposition( $thumbName, $dispositionType )}";
325 
326  if ( count( $varyHeader ) ) {
327  $headers[] = 'Vary: ' . implode( ', ', $varyHeader );
328  }
329 
330  // Stream the file if it exists already...
331  $thumbPath = $img->getThumbPath( $thumbName );
332  if ( $img->getRepo()->fileExists( $thumbPath ) ) {
333  $starttime = microtime( true );
334  $status = $img->getRepo()->streamFileWithStatus( $thumbPath, $headers );
335  $streamtime = microtime( true ) - $starttime;
336 
337  if ( $status->isOK() ) {
338  MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
339  'media.thumbnail.stream', $streamtime
340  );
341  } else {
342  wfThumbError( 500, 'Could not stream the file', null, [ 'file' => $thumbName,
343  'path' => $thumbPath, 'error' => $status->getWikiText( false, false, 'en' ) ] );
344  }
345  return;
346  }
347 
348  $user = RequestContext::getMain()->getUser();
349  if ( !wfThumbIsStandard( $img, $params ) && $user->pingLimiter( 'renderfile-nonstandard' ) ) {
350  wfThumbError( 429, wfMessage( 'actionthrottledtext' )->parse() );
351  return;
352  } elseif ( $user->pingLimiter( 'renderfile' ) ) {
353  wfThumbError( 429, wfMessage( 'actionthrottledtext' )->parse() );
354  return;
355  }
356 
357  $thumbProxyUrl = $img->getRepo()->getThumbProxyUrl();
358 
359  if ( strlen( $thumbProxyUrl ) ) {
360  wfProxyThumbnailRequest( $img, $thumbName );
361  // No local fallback when in proxy mode
362  return;
363  } else {
364  // Generate the thumbnail locally
365  list( $thumb, $errorMsg ) = wfGenerateThumbnail( $img, $params, $thumbName, $thumbPath );
366  }
367 
370  // Check for thumbnail generation errors...
371  $msg = wfMessage( 'thumbnail_error' );
372  $errorCode = 500;
373 
374  if ( !$thumb ) {
375  $errorMsg = $errorMsg ?: $msg->rawParams( 'File::transform() returned false' )->escaped();
376  if ( $errorMsg instanceof MessageSpecifier &&
377  $errorMsg->getKey() === 'thumbnail_image-failure-limit'
378  ) {
379  $errorCode = 429;
380  }
381  } elseif ( $thumb->isError() ) {
382  $errorMsg = $thumb->getHtmlMsg();
383  $errorCode = $thumb->getHttpStatusCode();
384  } elseif ( !$thumb->hasFile() ) {
385  $errorMsg = $msg->rawParams( 'No path supplied in thumbnail object' )->escaped();
386  } elseif ( $thumb->fileIsSource() ) {
387  $errorMsg = $msg
388  ->rawParams( 'Image was not scaled, is the requested width bigger than the source?' )
389  ->escaped();
390  $errorCode = 400;
391  }
392 
393  if ( $errorMsg !== false ) {
394  wfThumbError( $errorCode, $errorMsg, null, [ 'file' => $thumbName, 'path' => $thumbPath ] );
395  } else {
396  // Stream the file if there were no errors
397  $status = $thumb->streamFileWithStatus( $headers );
398  if ( !$status->isOK() ) {
399  wfThumbError( 500, 'Could not stream the file', null, [
400  'file' => $thumbName, 'path' => $thumbPath,
401  'error' => $status->getWikiText( false, false, 'en' ) ] );
402  }
403  }
404 }
405 
412 function wfProxyThumbnailRequest( $img, $thumbName ) {
413  $thumbProxyUrl = $img->getRepo()->getThumbProxyUrl();
414 
415  // Instead of generating the thumbnail ourselves, we proxy the request to another service
416  $thumbProxiedUrl = $thumbProxyUrl . $img->getThumbRel( $thumbName );
417 
418  $req = MWHttpRequest::factory( $thumbProxiedUrl );
419  $secret = $img->getRepo()->getThumbProxySecret();
420 
421  // Pass a secret key shared with the proxied service if any
422  if ( strlen( $secret ) ) {
423  $req->setHeader( 'X-Swift-Secret', $secret );
424  }
425 
426  // Send request to proxied service
427  $status = $req->execute();
428 
430 
431  // Simply serve the response from the proxied service as-is
432  header( 'HTTP/1.1 ' . $req->getStatus() );
433 
434  $headers = $req->getResponseHeaders();
435 
436  foreach ( $headers as $key => $values ) {
437  foreach ( $values as $value ) {
438  header( $key . ': ' . $value, false );
439  }
440  }
441 
442  echo $req->getContent();
443 }
444 
454 function wfGenerateThumbnail( File $file, array $params, $thumbName, $thumbPath ) {
455  global $wgAttemptFailureEpoch;
456 
458  $key = $cache->makeKey(
459  'attempt-failures',
461  $file->getRepo()->getName(),
462  $file->getSha1(),
463  md5( $thumbName )
464  );
465 
466  // Check if this file keeps failing to render
467  if ( $cache->get( $key ) >= 4 ) {
468  return [ false, wfMessage( 'thumbnail_image-failure-limit', 4 ) ];
469  }
470 
471  $done = false;
472  // Record failures on PHP fatals in addition to caching exceptions
473  register_shutdown_function( static function () use ( $cache, &$done, $key ) {
474  if ( !$done ) { // transform() gave a fatal
475  // Randomize TTL to reduce stampedes
476  $cache->incrWithInit( $key, $cache::TTL_HOUR + mt_rand( 0, 300 ) );
477  }
478  } );
479 
480  $thumb = false;
481  $errorHtml = false;
482 
483  // guard thumbnail rendering with PoolCounter to avoid stampedes
484  // expensive files use a separate PoolCounter config so it is possible
485  // to set up a global limit on them
486  if ( $file->isExpensiveToThumbnail() ) {
487  $poolCounterType = 'FileRenderExpensive';
488  } else {
489  $poolCounterType = 'FileRender';
490  }
491 
492  // Thumbnail isn't already there, so create the new thumbnail...
493  try {
494  $work = new PoolCounterWorkViaCallback( $poolCounterType, sha1( $file->getName() ),
495  [
496  'doWork' => static function () use ( $file, $params ) {
497  return $file->transform( $params, File::RENDER_NOW );
498  },
499  'doCachedWork' => static function () use ( $file, $params, $thumbPath ) {
500  // If the worker that finished made this thumbnail then use it.
501  // Otherwise, it probably made a different thumbnail for this file.
502  return $file->getRepo()->fileExists( $thumbPath )
503  ? $file->transform( $params, File::RENDER_NOW )
504  : false; // retry once more in exclusive mode
505  },
506  'error' => static function ( Status $status ) {
507  return wfMessage( 'generic-pool-error' )->parse() . '<hr>' . $status->getHTML();
508  }
509  ]
510  );
511  $result = $work->execute();
512  if ( $result instanceof MediaTransformOutput ) {
513  $thumb = $result;
514  } elseif ( is_string( $result ) ) { // error
515  $errorHtml = $result;
516  }
517  } catch ( Exception $e ) {
518  // Tried to select a page on a non-paged file?
519  }
520 
522  $done = true; // no PHP fatal occurred
523 
524  if ( !$thumb || $thumb->isError() ) {
525  // Randomize TTL to reduce stampedes
526  $cache->incrWithInit( $key, $cache::TTL_HOUR + mt_rand( 0, 300 ) );
527  }
528 
529  return [ $thumb, $errorHtml ];
530 }
531 
551 function wfExtractThumbRequestInfo( $thumbRel ) {
552  $repo = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo();
553 
554  $hashDirReg = $subdirReg = '';
555  $hashLevels = $repo->getHashLevels();
556  for ( $i = 0; $i < $hashLevels; $i++ ) {
557  $subdirReg .= '[0-9a-f]';
558  $hashDirReg .= "$subdirReg/";
559  }
560 
561  // Check if this is a thumbnail of an original in the local file repo
562  if ( preg_match( "!^((archive/)?$hashDirReg([^/]*)/([^/]*))$!", $thumbRel, $m ) ) {
563  list( /*all*/, $rel, $archOrTemp, $filename, $thumbname ) = $m;
564  // Check if this is a thumbnail of an temp file in the local file repo
565  } elseif ( preg_match( "!^(temp/)($hashDirReg([^/]*)/([^/]*))$!", $thumbRel, $m ) ) {
566  list( /*all*/, $archOrTemp, $rel, $filename, $thumbname ) = $m;
567  } else {
568  return null; // not a valid looking thumbnail request
569  }
570 
571  $params = [ 'f' => $filename, 'rel404' => $rel ];
572  if ( $archOrTemp === 'archive/' ) {
573  $params['archived'] = 1;
574  } elseif ( $archOrTemp === 'temp/' ) {
575  $params['temp'] = 1;
576  }
577 
578  $params['thumbName'] = $thumbname;
579  return $params;
580 }
581 
590 function wfExtractThumbParams( $file, $params ) {
591  if ( !isset( $params['thumbName'] ) ) {
592  throw new InvalidArgumentException( "No thumbnail name passed to wfExtractThumbParams" );
593  }
594 
595  $thumbname = $params['thumbName'];
596  unset( $params['thumbName'] );
597 
598  // FIXME: Files in the temp zone don't set a MIME type, which means
599  // they don't have a handler. Which means we can't parse the param
600  // string. However, not a big issue as what good is a param string
601  // if you have no handler to make use of the param string and
602  // actually generate the thumbnail.
603  $handler = $file->getHandler();
604 
605  // Based on UploadStash::parseKey
606  $fileNamePos = strrpos( $thumbname, $params['f'] );
607  if ( $fileNamePos === false ) {
608  // Maybe using a short filename? (see FileRepo::nameForThumb)
609  $fileNamePos = strrpos( $thumbname, 'thumbnail' );
610  }
611 
612  if ( $handler && $fileNamePos !== false ) {
613  $paramString = substr( $thumbname, 0, $fileNamePos - 1 );
614  $extraParams = $handler->parseParamString( $paramString );
615  if ( $extraParams !== false ) {
616  return $params + $extraParams;
617  }
618  }
619 
620  // As a last ditch fallback, use the traditional common parameters
621  if ( preg_match( '!^(page(\d*)-)*(\d*)px-[^/]*$!', $thumbname, $matches ) ) {
622  list( /* all */, /* pagefull */, $pagenum, $size ) = $matches;
623  $params['width'] = $size;
624  if ( $pagenum ) {
625  $params['page'] = $pagenum;
626  }
627  return $params; // valid thumbnail URL
628  }
629  return null;
630 }
631 
639 function wfThumbErrorText( $status, $msgText ) {
640  wfThumbError( $status, htmlspecialchars( $msgText, ENT_NOQUOTES ) );
641 }
642 
653 function wfThumbError( $status, $msgHtml, $msgText = null, $context = [] ) {
654  global $wgShowHostnames;
655 
657 
658  if ( headers_sent() ) {
659  LoggerFactory::getInstance( 'thumbnail' )->error(
660  'Error after output had been started. Output may be corrupt or truncated. ' .
661  'Original error: ' . ( $msgText ?: $msgHtml ) . " (Status $status)",
662  $context
663  );
664  return;
665  }
666 
667  header( 'Cache-Control: no-cache' );
668  header( 'Content-Type: text/html; charset=utf-8' );
669  if ( $status == 400 || $status == 404 || $status == 429 ) {
670  HttpStatus::header( $status );
671  } elseif ( $status == 403 ) {
672  HttpStatus::header( 403 );
673  header( 'Vary: Cookie' );
674  } else {
675  LoggerFactory::getInstance( 'thumbnail' )->error( $msgText ?: $msgHtml, $context );
676  HttpStatus::header( 500 );
677  }
678  if ( $wgShowHostnames ) {
679  header( 'X-MW-Thumbnail-Renderer: ' . wfHostname() );
680  $url = htmlspecialchars(
681  $_SERVER['REQUEST_URI'] ?? '',
682  ENT_NOQUOTES
683  );
684  $hostname = htmlspecialchars( wfHostname(), ENT_NOQUOTES );
685  $debug = "<!-- $url -->\n<!-- $hostname -->\n";
686  } else {
687  $debug = '';
688  }
689  $content = <<<EOT
690 <!DOCTYPE html>
691 <html><head>
692 <meta charset="UTF-8" />
693 <title>Error generating thumbnail</title>
694 </head>
695 <body>
696 <h1>Error generating thumbnail</h1>
697 <p>
698 $msgHtml
699 </p>
700 $debug
701 </body>
702 </html>
703 
704 EOT;
705  header( 'Content-Length: ' . strlen( $content ) );
706  echo $content;
707 }
File\THUMB_FULL_NAME
const THUMB_FULL_NAME
Definition: File.php:88
MediaTransformError
Basic media transform error class.
Definition: MediaTransformError.php:31
wfThumbHandle404
wfThumbHandle404()
Handle a thumbnail request via thumbnail file URL.
Definition: thumb.php:65
ObjectCache\getLocalClusterInstance
static getLocalClusterInstance()
Get the main cluster-local cache object.
Definition: ObjectCache.php:272
wfThumbIsStandard
wfThumbIsStandard(File $file, array $params)
Returns true if these thumbnail parameters match one that MediaWiki requests from file description pa...
Definition: GlobalFunctions.php:2792
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:173
WebRequest\getRequestPathSuffix
static getRequestPathSuffix( $basePath)
If the request URL matches a given base path, extract the path part of the request URL after that bas...
Definition: WebRequest.php:233
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1832
UnregisteredLocalFile
A file object referring to either a standalone local file, or a file in a local repository with no da...
Definition: UnregisteredLocalFile.php:36
MessageSpecifier\getKey
getKey()
Returns the message key.
MessageSpecifier
Definition: MessageSpecifier.php:24
$wgShowHostnames
$wgShowHostnames
Expose backend server host names through the API and various HTML comments.
Definition: DefaultSettings.php:6868
wfExtractThumbRequestInfo
wfExtractThumbRequestInfo( $thumbRel)
Convert pathinfo type parameter, into normal request parameters.
Definition: thumb.php:551
$file
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition: router.php:42
wfHostname
wfHostname()
Get host name of the current machine, for use in error reporting.
Definition: GlobalFunctions.php:1294
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1231
PoolCounterWorkViaCallback
Convenience class for dealing with PoolCounters using callbacks.
Definition: PoolCounterWorkViaCallback.php:31
wfExtractThumbParams
wfExtractThumbParams( $file, $params)
Convert a thumbnail name (122px-foo.png) to parameters, using file handler.
Definition: thumb.php:590
Status
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition: Status.php:44
$debug
$debug
Definition: mcc.php:31
$wgAttemptFailureEpoch
$wgAttemptFailureEpoch
Certain operations are avoided if there were too many recent failures, for example,...
Definition: DefaultSettings.php:1417
File
Implements some public methods and some protected utility functions which are required by multiple ch...
Definition: File.php:63
MWException
MediaWiki exception.
Definition: MWException.php:29
MediaWiki\Logger\LoggerFactory
PSR-3 logger instance factory.
Definition: LoggerFactory.php:45
PoolCounterWork\execute
execute( $skipcache=false)
Get the result of the work (whatever it is), or the result of the error() function.
Definition: PoolCounterWork.php:127
$matches
$matches
Definition: NoLocalSettings.php:24
MWException\getHTML
getHTML()
If $wgShowExceptionDetails is true, return a HTML message with a backtrace to the error,...
Definition: MWException.php:112
MediaWiki
A helper class for throttling authentication attempts.
$wgVaryOnXFP
$wgVaryOnXFP
Add X-Forwarded-Proto to the Vary and Key headers for API requests and RSS/Atom feeds.
Definition: DefaultSettings.php:2993
$title
$title
Definition: testCompression.php:38
wfThumbMain
wfThumbMain()
Definition: thumb.php:42
PROTO_CURRENT
const PROTO_CURRENT
Definition: Defines.php:206
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:652
$content
$content
Definition: router.php:76
$mediawiki
$mediawiki
Definition: img_auth.php:48
$wgTrivialMimeDetection
$wgTrivialMimeDetection
Switch for trivial MIME detection.
Definition: DefaultSettings.php:1577
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:476
File\RENDER_NOW
const RENDER_NOW
Force rendering in the current process.
Definition: File.php:73
MediaTransformOutput
Base class for the output of MediaHandler::doTransform() and File::transform().
Definition: MediaTransformOutput.php:30
wfGenerateThumbnail
wfGenerateThumbnail(File $file, array $params, $thumbName, $thumbPath)
Actually try to generate a new thumbnail.
Definition: thumb.php:454
$cache
$cache
Definition: mcc.php:33
HttpStatus\header
static header( $code)
Output an HTTP status code header.
Definition: HttpStatus.php:96
wfThumbErrorText
wfThumbErrorText( $status, $msgText)
Output a thumbnail generation error message.
Definition: thumb.php:639
wfProxyThumbnailRequest
wfProxyThumbnailRequest( $img, $thumbName)
Proxies thumbnail request to a service that handles thumbnailing.
Definition: thumb.php:412
MediaTransformInvalidParametersException
MediaWiki exception thrown by some methods when the transform parameter array is invalid.
Definition: MediaTransformInvalidParametersException.php:27
File\DELETED_FILE
const DELETED_FILE
Definition: File.php:67
$wgRequest
if(! $wgDBerrorLogTZ) $wgRequest
Definition: Setup.php:651
NS_FILE
const NS_FILE
Definition: Defines.php:70
wfThumbError
wfThumbError( $status, $msgHtml, $msgText=null, $context=[])
Output a thumbnail generation error message.
Definition: thumb.php:653
MWHttpRequest\factory
static factory( $url, array $options=null, $caller=__METHOD__)
Generate a new request object.
Definition: MWHttpRequest.php:195
wfExpandUrl
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Definition: GlobalFunctions.php:495
MediaWiki\HeaderCallback\warnIfHeadersSent
static warnIfHeadersSent()
Log a warning message if headers have already been sent.
Definition: HeaderCallback.php:83
wfStreamThumb
wfStreamThumb(array $params)
Stream a thumbnail specified by parameters.
Definition: thumb.php:104
$wgThumbPath
$wgThumbPath
The base path for thumb_handler.php.
Definition: DefaultSettings.php:292