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