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