MediaWiki  1.29.2
File.php
Go to the documentation of this file.
1 <?php
9 
51 abstract class File implements IDBAccessObject {
52  // Bitfield values akin to the Revision deletion constants
53  const DELETED_FILE = 1;
54  const DELETED_COMMENT = 2;
55  const DELETED_USER = 4;
56  const DELETED_RESTRICTED = 8;
57 
59  const RENDER_NOW = 1;
64  const RENDER_FORCE = 2;
65 
66  const DELETE_SOURCE = 1;
67 
68  // Audience options for File::getDescription()
69  const FOR_PUBLIC = 1;
70  const FOR_THIS_USER = 2;
71  const RAW = 3;
72 
73  // Options for File::thumbName()
74  const THUMB_FULL_NAME = 1;
75 
96  public $repo;
97 
99  protected $title;
100 
102  protected $lastError;
103 
105  protected $redirected;
106 
108  protected $redirectedTitle;
109 
111  protected $fsFile;
112 
114  protected $handler;
115 
117  protected $url;
118 
120  protected $extension;
121 
123  protected $name;
124 
126  protected $path;
127 
129  protected $hashPath;
130 
134  protected $pageCount;
135 
137  protected $transformScript;
138 
140  protected $redirectTitle;
141 
143  protected $canRender;
144 
148  protected $isSafeFile;
149 
151  protected $repoClass = 'FileRepo';
152 
154  protected $tmpBucketedThumbCache = [];
155 
166  function __construct( $title, $repo ) {
167  // Some subclasses do not use $title, but set name/title some other way
168  if ( $title !== false ) {
169  $title = self::normalizeTitle( $title, 'exception' );
170  }
171  $this->title = $title;
172  $this->repo = $repo;
173  }
174 
184  static function normalizeTitle( $title, $exception = false ) {
185  $ret = $title;
186  if ( $ret instanceof Title ) {
187  # Normalize NS_MEDIA -> NS_FILE
188  if ( $ret->getNamespace() == NS_MEDIA ) {
189  $ret = Title::makeTitleSafe( NS_FILE, $ret->getDBkey() );
190  # Sanity check the title namespace
191  } elseif ( $ret->getNamespace() !== NS_FILE ) {
192  $ret = null;
193  }
194  } else {
195  # Convert strings to Title objects
196  $ret = Title::makeTitleSafe( NS_FILE, (string)$ret );
197  }
198  if ( !$ret && $exception !== false ) {
199  throw new MWException( "`$title` is not a valid file title." );
200  }
201 
202  return $ret;
203  }
204 
205  function __get( $name ) {
206  $function = [ $this, 'get' . ucfirst( $name ) ];
207  if ( !is_callable( $function ) ) {
208  return null;
209  } else {
210  $this->$name = call_user_func( $function );
211 
212  return $this->$name;
213  }
214  }
215 
224  static function normalizeExtension( $extension ) {
225  $lower = strtolower( $extension );
226  $squish = [
227  'htm' => 'html',
228  'jpeg' => 'jpg',
229  'mpeg' => 'mpg',
230  'tiff' => 'tif',
231  'ogv' => 'ogg' ];
232  if ( isset( $squish[$lower] ) ) {
233  return $squish[$lower];
234  } elseif ( preg_match( '/^[0-9a-z]+$/', $lower ) ) {
235  return $lower;
236  } else {
237  return '';
238  }
239  }
240 
249  static function checkExtensionCompatibility( File $old, $new ) {
250  $oldMime = $old->getMimeType();
251  $n = strrpos( $new, '.' );
252  $newExt = self::normalizeExtension( $n ? substr( $new, $n + 1 ) : '' );
254 
255  return $mimeMagic->isMatchingExtension( $newExt, $oldMime );
256  }
257 
263  function upgradeRow() {
264  }
265 
273  public static function splitMime( $mime ) {
274  if ( strpos( $mime, '/' ) !== false ) {
275  return explode( '/', $mime, 2 );
276  } else {
277  return [ $mime, 'unknown' ];
278  }
279  }
280 
288  public static function compare( File $a, File $b ) {
289  return strcmp( $a->getName(), $b->getName() );
290  }
291 
297  public function getName() {
298  if ( !isset( $this->name ) ) {
299  $this->assertRepoDefined();
300  $this->name = $this->repo->getNameFromTitle( $this->title );
301  }
302 
303  return $this->name;
304  }
305 
311  function getExtension() {
312  if ( !isset( $this->extension ) ) {
313  $n = strrpos( $this->getName(), '.' );
314  $this->extension = self::normalizeExtension(
315  $n ? substr( $this->getName(), $n + 1 ) : '' );
316  }
317 
318  return $this->extension;
319  }
320 
326  public function getTitle() {
327  return $this->title;
328  }
329 
335  public function getOriginalTitle() {
336  if ( $this->redirected ) {
337  return $this->getRedirectedTitle();
338  }
339 
340  return $this->title;
341  }
342 
348  public function getUrl() {
349  if ( !isset( $this->url ) ) {
350  $this->assertRepoDefined();
351  $ext = $this->getExtension();
352  $this->url = $this->repo->getZoneUrl( 'public', $ext ) . '/' . $this->getUrlRel();
353  }
354 
355  return $this->url;
356  }
357 
358  /*
359  * Get short description URL for a files based on the page ID
360  *
361  * @return string|null
362  * @since 1.27
363  */
364  public function getDescriptionShortUrl() {
365  return null;
366  }
367 
375  public function getFullUrl() {
376  return wfExpandUrl( $this->getUrl(), PROTO_RELATIVE );
377  }
378 
382  public function getCanonicalUrl() {
383  return wfExpandUrl( $this->getUrl(), PROTO_CANONICAL );
384  }
385 
389  function getViewURL() {
390  if ( $this->mustRender() ) {
391  if ( $this->canRender() ) {
392  return $this->createThumb( $this->getWidth() );
393  } else {
394  wfDebug( __METHOD__ . ': supposed to render ' . $this->getName() .
395  ' (' . $this->getMimeType() . "), but can't!\n" );
396 
397  return $this->getUrl(); # hm... return NULL?
398  }
399  } else {
400  return $this->getUrl();
401  }
402  }
403 
417  public function getPath() {
418  if ( !isset( $this->path ) ) {
419  $this->assertRepoDefined();
420  $this->path = $this->repo->getZonePath( 'public' ) . '/' . $this->getRel();
421  }
422 
423  return $this->path;
424  }
425 
433  public function getLocalRefPath() {
434  $this->assertRepoDefined();
435  if ( !isset( $this->fsFile ) ) {
436  $starttime = microtime( true );
437  $this->fsFile = $this->repo->getLocalReference( $this->getPath() );
438 
439  $statTiming = microtime( true ) - $starttime;
440  MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
441  'media.thumbnail.generate.fetchoriginal', 1000 * $statTiming );
442 
443  if ( !$this->fsFile ) {
444  $this->fsFile = false; // null => false; cache negative hits
445  }
446  }
447 
448  return ( $this->fsFile )
449  ? $this->fsFile->getPath()
450  : false;
451  }
452 
463  public function getWidth( $page = 1 ) {
464  return false;
465  }
466 
477  public function getHeight( $page = 1 ) {
478  return false;
479  }
480 
490  public function getThumbnailBucket( $desiredWidth, $page = 1 ) {
492 
493  $imageWidth = $this->getWidth( $page );
494 
495  if ( $imageWidth === false ) {
496  return false;
497  }
498 
499  if ( $desiredWidth > $imageWidth ) {
500  return false;
501  }
502 
503  if ( !$wgThumbnailBuckets ) {
504  return false;
505  }
506 
507  $sortedBuckets = $wgThumbnailBuckets;
508 
509  sort( $sortedBuckets );
510 
511  foreach ( $sortedBuckets as $bucket ) {
512  if ( $bucket >= $imageWidth ) {
513  return false;
514  }
515 
516  if ( $bucket - $wgThumbnailMinimumBucketDistance > $desiredWidth ) {
517  return $bucket;
518  }
519  }
520 
521  // Image is bigger than any available bucket
522  return false;
523  }
524 
532  public function getUser( $type = 'text' ) {
533  return null;
534  }
535 
541  public function getLength() {
542  $handler = $this->getHandler();
543  if ( $handler ) {
544  return $handler->getLength( $this );
545  } else {
546  return 0;
547  }
548  }
549 
555  public function isVectorized() {
556  $handler = $this->getHandler();
557  if ( $handler ) {
558  return $handler->isVectorized( $this );
559  } else {
560  return false;
561  }
562  }
563 
575  public function getAvailableLanguages() {
576  $handler = $this->getHandler();
577  if ( $handler ) {
578  return $handler->getAvailableLanguages( $this );
579  } else {
580  return [];
581  }
582  }
583 
591  public function getDefaultRenderLanguage() {
592  $handler = $this->getHandler();
593  if ( $handler ) {
594  return $handler->getDefaultRenderLanguage( $this );
595  } else {
596  return null;
597  }
598  }
599 
610  public function canAnimateThumbIfAppropriate() {
611  $handler = $this->getHandler();
612  if ( !$handler ) {
613  // We cannot handle image whatsoever, thus
614  // one would not expect it to be animated
615  // so true.
616  return true;
617  } else {
618  if ( $this->allowInlineDisplay()
619  && $handler->isAnimatedImage( $this )
620  && !$handler->canAnimateThumbnail( $this )
621  ) {
622  // Image is animated, but thumbnail isn't.
623  // This is unexpected to the user.
624  return false;
625  } else {
626  // Image is not animated, so one would
627  // not expect thumb to be
628  return true;
629  }
630  }
631  }
632 
639  public function getMetadata() {
640  return false;
641  }
642 
649  public function getCommonMetaArray() {
650  $handler = $this->getHandler();
651 
652  if ( !$handler ) {
653  return false;
654  }
655 
656  return $handler->getCommonMetaArray( $this );
657  }
658 
667  public function convertMetadataVersion( $metadata, $version ) {
668  $handler = $this->getHandler();
669  if ( !is_array( $metadata ) ) {
670  // Just to make the return type consistent
671  $metadata = unserialize( $metadata );
672  }
673  if ( $handler ) {
674  return $handler->convertMetadataVersion( $metadata, $version );
675  } else {
676  return $metadata;
677  }
678  }
679 
686  public function getBitDepth() {
687  return 0;
688  }
689 
696  public function getSize() {
697  return false;
698  }
699 
707  function getMimeType() {
708  return 'unknown/unknown';
709  }
710 
718  function getMediaType() {
719  return MEDIATYPE_UNKNOWN;
720  }
721 
734  function canRender() {
735  if ( !isset( $this->canRender ) ) {
736  $this->canRender = $this->getHandler() && $this->handler->canRender( $this ) && $this->exists();
737  }
738 
739  return $this->canRender;
740  }
741 
746  protected function getCanRender() {
747  return $this->canRender();
748  }
749 
760  function mustRender() {
761  return $this->getHandler() && $this->handler->mustRender( $this );
762  }
763 
769  function allowInlineDisplay() {
770  return $this->canRender();
771  }
772 
786  function isSafeFile() {
787  if ( !isset( $this->isSafeFile ) ) {
788  $this->isSafeFile = $this->getIsSafeFileUncached();
789  }
790 
791  return $this->isSafeFile;
792  }
793 
799  protected function getIsSafeFile() {
800  return $this->isSafeFile();
801  }
802 
808  protected function getIsSafeFileUncached() {
810 
811  if ( $this->allowInlineDisplay() ) {
812  return true;
813  }
814  if ( $this->isTrustedFile() ) {
815  return true;
816  }
817 
818  $type = $this->getMediaType();
819  $mime = $this->getMimeType();
820  # wfDebug( "LocalFile::isSafeFile: type= $type, mime= $mime\n" );
821 
822  if ( !$type || $type === MEDIATYPE_UNKNOWN ) {
823  return false; # unknown type, not trusted
824  }
825  if ( in_array( $type, $wgTrustedMediaFormats ) ) {
826  return true;
827  }
828 
829  if ( $mime === "unknown/unknown" ) {
830  return false; # unknown type, not trusted
831  }
832  if ( in_array( $mime, $wgTrustedMediaFormats ) ) {
833  return true;
834  }
835 
836  return false;
837  }
838 
852  function isTrustedFile() {
853  # this could be implemented to check a flag in the database,
854  # look for signatures, etc
855  return false;
856  }
857 
867  public function load( $flags = 0 ) {
868  }
869 
877  public function exists() {
878  return $this->getPath() && $this->repo->fileExists( $this->path );
879  }
880 
887  public function isVisible() {
888  return $this->exists();
889  }
890 
894  function getTransformScript() {
895  if ( !isset( $this->transformScript ) ) {
896  $this->transformScript = false;
897  if ( $this->repo ) {
898  $script = $this->repo->getThumbScriptUrl();
899  if ( $script ) {
900  $this->transformScript = wfAppendQuery( $script, [ 'f' => $this->getName() ] );
901  }
902  }
903  }
904 
905  return $this->transformScript;
906  }
907 
915  function getUnscaledThumb( $handlerParams = [] ) {
916  $hp =& $handlerParams;
917  $page = isset( $hp['page'] ) ? $hp['page'] : false;
918  $width = $this->getWidth( $page );
919  if ( !$width ) {
920  return $this->iconThumb();
921  }
922  $hp['width'] = $width;
923  // be sure to ignore any height specification as well (T64258)
924  unset( $hp['height'] );
925 
926  return $this->transform( $hp );
927  }
928 
938  public function thumbName( $params, $flags = 0 ) {
939  $name = ( $this->repo && !( $flags & self::THUMB_FULL_NAME ) )
940  ? $this->repo->nameForThumb( $this->getName() )
941  : $this->getName();
942 
943  return $this->generateThumbName( $name, $params );
944  }
945 
953  public function generateThumbName( $name, $params ) {
954  if ( !$this->getHandler() ) {
955  return null;
956  }
957  $extension = $this->getExtension();
958  list( $thumbExt, ) = $this->getHandler()->getThumbType(
959  $extension, $this->getMimeType(), $params );
960  $thumbName = $this->getHandler()->makeParamString( $params );
961 
962  if ( $this->repo->supportsSha1URLs() ) {
963  $thumbName .= '-' . $this->getSha1() . '.' . $thumbExt;
964  } else {
965  $thumbName .= '-' . $name;
966 
967  if ( $thumbExt != $extension ) {
968  $thumbName .= ".$thumbExt";
969  }
970  }
971 
972  return $thumbName;
973  }
974 
992  public function createThumb( $width, $height = -1 ) {
993  $params = [ 'width' => $width ];
994  if ( $height != -1 ) {
995  $params['height'] = $height;
996  }
997  $thumb = $this->transform( $params );
998  if ( !$thumb || $thumb->isError() ) {
999  return '';
1000  }
1001 
1002  return $thumb->getUrl();
1003  }
1004 
1014  protected function transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags ) {
1016 
1017  $handler = $this->getHandler();
1018  if ( $handler && $wgIgnoreImageErrors && !( $flags & self::RENDER_NOW ) ) {
1019  return $handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
1020  } else {
1021  return new MediaTransformError( 'thumbnail_error',
1022  $params['width'], 0, wfMessage( 'thumbnail-dest-create' ) );
1023  }
1024  }
1025 
1034  function transform( $params, $flags = 0 ) {
1036 
1037  do {
1038  if ( !$this->canRender() ) {
1039  $thumb = $this->iconThumb();
1040  break; // not a bitmap or renderable image, don't try
1041  }
1042 
1043  // Get the descriptionUrl to embed it as comment into the thumbnail. T21791.
1044  $descriptionUrl = $this->getDescriptionUrl();
1045  if ( $descriptionUrl ) {
1046  $params['descriptionUrl'] = wfExpandUrl( $descriptionUrl, PROTO_CANONICAL );
1047  }
1048 
1049  $handler = $this->getHandler();
1050  $script = $this->getTransformScript();
1051  if ( $script && !( $flags & self::RENDER_NOW ) ) {
1052  // Use a script to transform on client request, if possible
1053  $thumb = $handler->getScriptedTransform( $this, $script, $params );
1054  if ( $thumb ) {
1055  break;
1056  }
1057  }
1058 
1059  $normalisedParams = $params;
1060  $handler->normaliseParams( $this, $normalisedParams );
1061 
1062  $thumbName = $this->thumbName( $normalisedParams );
1063  $thumbUrl = $this->getThumbUrl( $thumbName );
1064  $thumbPath = $this->getThumbPath( $thumbName ); // final thumb path
1065 
1066  if ( $this->repo ) {
1067  // Defer rendering if a 404 handler is set up...
1068  if ( $this->repo->canTransformVia404() && !( $flags & self::RENDER_NOW ) ) {
1069  // XXX: Pass in the storage path even though we are not rendering anything
1070  // and the path is supposed to be an FS path. This is due to getScalerType()
1071  // getting called on the path and clobbering $thumb->getUrl() if it's false.
1072  $thumb = $handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
1073  break;
1074  }
1075  // Check if an up-to-date thumbnail already exists...
1076  wfDebug( __METHOD__ . ": Doing stat for $thumbPath\n" );
1077  if ( !( $flags & self::RENDER_FORCE ) && $this->repo->fileExists( $thumbPath ) ) {
1078  $timestamp = $this->repo->getFileTimestamp( $thumbPath );
1079  if ( $timestamp !== false && $timestamp >= $wgThumbnailEpoch ) {
1080  // XXX: Pass in the storage path even though we are not rendering anything
1081  // and the path is supposed to be an FS path. This is due to getScalerType()
1082  // getting called on the path and clobbering $thumb->getUrl() if it's false.
1083  $thumb = $handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
1084  $thumb->setStoragePath( $thumbPath );
1085  break;
1086  }
1087  } elseif ( $flags & self::RENDER_FORCE ) {
1088  wfDebug( __METHOD__ . " forcing rendering per flag File::RENDER_FORCE\n" );
1089  }
1090 
1091  // If the backend is ready-only, don't keep generating thumbnails
1092  // only to return transformation errors, just return the error now.
1093  if ( $this->repo->getReadOnlyReason() !== false ) {
1094  $thumb = $this->transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags );
1095  break;
1096  }
1097  }
1098 
1099  $tmpFile = $this->makeTransformTmpFile( $thumbPath );
1100 
1101  if ( !$tmpFile ) {
1102  $thumb = $this->transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags );
1103  } else {
1104  $thumb = $this->generateAndSaveThumb( $tmpFile, $params, $flags );
1105  }
1106  } while ( false );
1107 
1108  return is_object( $thumb ) ? $thumb : false;
1109  }
1110 
1118  public function generateAndSaveThumb( $tmpFile, $transformParams, $flags ) {
1120 
1121  $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
1122 
1123  $handler = $this->getHandler();
1124 
1125  $normalisedParams = $transformParams;
1126  $handler->normaliseParams( $this, $normalisedParams );
1127 
1128  $thumbName = $this->thumbName( $normalisedParams );
1129  $thumbUrl = $this->getThumbUrl( $thumbName );
1130  $thumbPath = $this->getThumbPath( $thumbName ); // final thumb path
1131 
1132  $tmpThumbPath = $tmpFile->getPath();
1133 
1134  if ( $handler->supportsBucketing() ) {
1135  $this->generateBucketsIfNeeded( $normalisedParams, $flags );
1136  }
1137 
1138  $starttime = microtime( true );
1139 
1140  // Actually render the thumbnail...
1141  $thumb = $handler->doTransform( $this, $tmpThumbPath, $thumbUrl, $transformParams );
1142  $tmpFile->bind( $thumb ); // keep alive with $thumb
1143 
1144  $statTiming = microtime( true ) - $starttime;
1145  $stats->timing( 'media.thumbnail.generate.transform', 1000 * $statTiming );
1146 
1147  if ( !$thumb ) { // bad params?
1148  $thumb = false;
1149  } elseif ( $thumb->isError() ) { // transform error
1151  $this->lastError = $thumb->toText();
1152  // Ignore errors if requested
1153  if ( $wgIgnoreImageErrors && !( $flags & self::RENDER_NOW ) ) {
1154  $thumb = $handler->getTransform( $this, $tmpThumbPath, $thumbUrl, $transformParams );
1155  }
1156  } elseif ( $this->repo && $thumb->hasFile() && !$thumb->fileIsSource() ) {
1157  // Copy the thumbnail from the file system into storage...
1158 
1159  $starttime = microtime( true );
1160 
1161  $disposition = $this->getThumbDisposition( $thumbName );
1162  $status = $this->repo->quickImport( $tmpThumbPath, $thumbPath, $disposition );
1163  if ( $status->isOK() ) {
1164  $thumb->setStoragePath( $thumbPath );
1165  } else {
1166  $thumb = $this->transformErrorOutput( $thumbPath, $thumbUrl, $transformParams, $flags );
1167  }
1168 
1169  $statTiming = microtime( true ) - $starttime;
1170  $stats->timing( 'media.thumbnail.generate.store', 1000 * $statTiming );
1171 
1172  // Give extensions a chance to do something with this thumbnail...
1173  Hooks::run( 'FileTransformed', [ $this, $thumb, $tmpThumbPath, $thumbPath ] );
1174  }
1175 
1176  return $thumb;
1177  }
1178 
1185  protected function generateBucketsIfNeeded( $params, $flags = 0 ) {
1186  if ( !$this->repo
1187  || !isset( $params['physicalWidth'] )
1188  || !isset( $params['physicalHeight'] )
1189  ) {
1190  return false;
1191  }
1192 
1193  $bucket = $this->getThumbnailBucket( $params['physicalWidth'] );
1194 
1195  if ( !$bucket || $bucket == $params['physicalWidth'] ) {
1196  return false;
1197  }
1198 
1199  $bucketPath = $this->getBucketThumbPath( $bucket );
1200 
1201  if ( $this->repo->fileExists( $bucketPath ) ) {
1202  return false;
1203  }
1204 
1205  $starttime = microtime( true );
1206 
1207  $params['physicalWidth'] = $bucket;
1208  $params['width'] = $bucket;
1209 
1210  $params = $this->getHandler()->sanitizeParamsForBucketing( $params );
1211 
1212  $tmpFile = $this->makeTransformTmpFile( $bucketPath );
1213 
1214  if ( !$tmpFile ) {
1215  return false;
1216  }
1217 
1218  $thumb = $this->generateAndSaveThumb( $tmpFile, $params, $flags );
1219 
1220  $buckettime = microtime( true ) - $starttime;
1221 
1222  if ( !$thumb || $thumb->isError() ) {
1223  return false;
1224  }
1225 
1226  $this->tmpBucketedThumbCache[$bucket] = $tmpFile->getPath();
1227  // For the caching to work, we need to make the tmp file survive as long as
1228  // this object exists
1229  $tmpFile->bind( $this );
1230 
1231  MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
1232  'media.thumbnail.generate.bucket', 1000 * $buckettime );
1233 
1234  return true;
1235  }
1236 
1242  public function getThumbnailSource( $params ) {
1243  if ( $this->repo
1244  && $this->getHandler()->supportsBucketing()
1245  && isset( $params['physicalWidth'] )
1246  && $bucket = $this->getThumbnailBucket( $params['physicalWidth'] )
1247  ) {
1248  if ( $this->getWidth() != 0 ) {
1249  $bucketHeight = round( $this->getHeight() * ( $bucket / $this->getWidth() ) );
1250  } else {
1251  $bucketHeight = 0;
1252  }
1253 
1254  // Try to avoid reading from storage if the file was generated by this script
1255  if ( isset( $this->tmpBucketedThumbCache[$bucket] ) ) {
1256  $tmpPath = $this->tmpBucketedThumbCache[$bucket];
1257 
1258  if ( file_exists( $tmpPath ) ) {
1259  return [
1260  'path' => $tmpPath,
1261  'width' => $bucket,
1262  'height' => $bucketHeight
1263  ];
1264  }
1265  }
1266 
1267  $bucketPath = $this->getBucketThumbPath( $bucket );
1268 
1269  if ( $this->repo->fileExists( $bucketPath ) ) {
1270  $fsFile = $this->repo->getLocalReference( $bucketPath );
1271 
1272  if ( $fsFile ) {
1273  return [
1274  'path' => $fsFile->getPath(),
1275  'width' => $bucket,
1276  'height' => $bucketHeight
1277  ];
1278  }
1279  }
1280  }
1281 
1282  // Thumbnailing a very large file could result in network saturation if
1283  // everyone does it at once.
1284  if ( $this->getSize() >= 1e7 ) { // 10MB
1285  $that = $this;
1286  $work = new PoolCounterWorkViaCallback( 'GetLocalFileCopy', sha1( $this->getName() ),
1287  [
1288  'doWork' => function () use ( $that ) {
1289  return $that->getLocalRefPath();
1290  }
1291  ]
1292  );
1293  $srcPath = $work->execute();
1294  } else {
1295  $srcPath = $this->getLocalRefPath();
1296  }
1297 
1298  // Original file
1299  return [
1300  'path' => $srcPath,
1301  'width' => $this->getWidth(),
1302  'height' => $this->getHeight()
1303  ];
1304  }
1305 
1311  protected function getBucketThumbPath( $bucket ) {
1312  $thumbName = $this->getBucketThumbName( $bucket );
1313  return $this->getThumbPath( $thumbName );
1314  }
1315 
1321  protected function getBucketThumbName( $bucket ) {
1322  return $this->thumbName( [ 'physicalWidth' => $bucket ] );
1323  }
1324 
1330  protected function makeTransformTmpFile( $thumbPath ) {
1331  $thumbExt = FileBackend::extensionFromPath( $thumbPath );
1332  return TempFSFile::factory( 'transform_', $thumbExt, wfTempDir() );
1333  }
1334 
1340  function getThumbDisposition( $thumbName, $dispositionType = 'inline' ) {
1341  $fileName = $this->name; // file name to suggest
1342  $thumbExt = FileBackend::extensionFromPath( $thumbName );
1343  if ( $thumbExt != '' && $thumbExt !== $this->getExtension() ) {
1344  $fileName .= ".$thumbExt";
1345  }
1346 
1347  return FileBackend::makeContentDisposition( $dispositionType, $fileName );
1348  }
1349 
1356  function migrateThumbFile( $thumbName ) {
1357  }
1358 
1365  function getHandler() {
1366  if ( !isset( $this->handler ) ) {
1367  $this->handler = MediaHandler::getHandler( $this->getMimeType() );
1368  }
1369 
1370  return $this->handler;
1371  }
1372 
1378  function iconThumb() {
1379  global $wgResourceBasePath, $IP;
1380  $assetsPath = "$wgResourceBasePath/resources/assets/file-type-icons/";
1381  $assetsDirectory = "$IP/resources/assets/file-type-icons/";
1382 
1383  $try = [ 'fileicon-' . $this->getExtension() . '.png', 'fileicon.png' ];
1384  foreach ( $try as $icon ) {
1385  if ( file_exists( $assetsDirectory . $icon ) ) { // always FS
1386  $params = [ 'width' => 120, 'height' => 120 ];
1387 
1388  return new ThumbnailImage( $this, $assetsPath . $icon, false, $params );
1389  }
1390  }
1391 
1392  return null;
1393  }
1394 
1400  function getLastError() {
1401  return $this->lastError;
1402  }
1403 
1410  function getThumbnails() {
1411  return [];
1412  }
1413 
1421  function purgeCache( $options = [] ) {
1422  }
1423 
1429  function purgeDescription() {
1430  $title = $this->getTitle();
1431  if ( $title ) {
1433  $title->purgeSquid();
1434  }
1435  }
1436 
1441  function purgeEverything() {
1442  // Delete thumbnails and refresh file metadata cache
1443  $this->purgeCache();
1444  $this->purgeDescription();
1445 
1446  // Purge cache of all pages using this file
1447  $title = $this->getTitle();
1448  if ( $title ) {
1449  DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'imagelinks' ) );
1450  }
1451  }
1452 
1464  function getHistory( $limit = null, $start = null, $end = null, $inc = true ) {
1465  return [];
1466  }
1467 
1477  public function nextHistoryLine() {
1478  return false;
1479  }
1480 
1487  public function resetHistory() {
1488  }
1489 
1497  function getHashPath() {
1498  if ( !isset( $this->hashPath ) ) {
1499  $this->assertRepoDefined();
1500  $this->hashPath = $this->repo->getHashPath( $this->getName() );
1501  }
1502 
1503  return $this->hashPath;
1504  }
1505 
1512  function getRel() {
1513  return $this->getHashPath() . $this->getName();
1514  }
1515 
1523  function getArchiveRel( $suffix = false ) {
1524  $path = 'archive/' . $this->getHashPath();
1525  if ( $suffix === false ) {
1526  $path = substr( $path, 0, -1 );
1527  } else {
1528  $path .= $suffix;
1529  }
1530 
1531  return $path;
1532  }
1533 
1541  function getThumbRel( $suffix = false ) {
1542  $path = $this->getRel();
1543  if ( $suffix !== false ) {
1544  $path .= '/' . $suffix;
1545  }
1546 
1547  return $path;
1548  }
1549 
1556  function getUrlRel() {
1557  return $this->getHashPath() . rawurlencode( $this->getName() );
1558  }
1559 
1568  function getArchiveThumbRel( $archiveName, $suffix = false ) {
1569  $path = 'archive/' . $this->getHashPath() . $archiveName . "/";
1570  if ( $suffix === false ) {
1571  $path = substr( $path, 0, -1 );
1572  } else {
1573  $path .= $suffix;
1574  }
1575 
1576  return $path;
1577  }
1578 
1585  function getArchivePath( $suffix = false ) {
1586  $this->assertRepoDefined();
1587 
1588  return $this->repo->getZonePath( 'public' ) . '/' . $this->getArchiveRel( $suffix );
1589  }
1590 
1598  function getArchiveThumbPath( $archiveName, $suffix = false ) {
1599  $this->assertRepoDefined();
1600 
1601  return $this->repo->getZonePath( 'thumb' ) . '/' .
1602  $this->getArchiveThumbRel( $archiveName, $suffix );
1603  }
1604 
1611  function getThumbPath( $suffix = false ) {
1612  $this->assertRepoDefined();
1613 
1614  return $this->repo->getZonePath( 'thumb' ) . '/' . $this->getThumbRel( $suffix );
1615  }
1616 
1623  function getTranscodedPath( $suffix = false ) {
1624  $this->assertRepoDefined();
1625 
1626  return $this->repo->getZonePath( 'transcoded' ) . '/' . $this->getThumbRel( $suffix );
1627  }
1628 
1635  function getArchiveUrl( $suffix = false ) {
1636  $this->assertRepoDefined();
1637  $ext = $this->getExtension();
1638  $path = $this->repo->getZoneUrl( 'public', $ext ) . '/archive/' . $this->getHashPath();
1639  if ( $suffix === false ) {
1640  $path = substr( $path, 0, -1 );
1641  } else {
1642  $path .= rawurlencode( $suffix );
1643  }
1644 
1645  return $path;
1646  }
1647 
1655  function getArchiveThumbUrl( $archiveName, $suffix = false ) {
1656  $this->assertRepoDefined();
1657  $ext = $this->getExtension();
1658  $path = $this->repo->getZoneUrl( 'thumb', $ext ) . '/archive/' .
1659  $this->getHashPath() . rawurlencode( $archiveName ) . "/";
1660  if ( $suffix === false ) {
1661  $path = substr( $path, 0, -1 );
1662  } else {
1663  $path .= rawurlencode( $suffix );
1664  }
1665 
1666  return $path;
1667  }
1668 
1676  function getZoneUrl( $zone, $suffix = false ) {
1677  $this->assertRepoDefined();
1678  $ext = $this->getExtension();
1679  $path = $this->repo->getZoneUrl( $zone, $ext ) . '/' . $this->getUrlRel();
1680  if ( $suffix !== false ) {
1681  $path .= '/' . rawurlencode( $suffix );
1682  }
1683 
1684  return $path;
1685  }
1686 
1693  function getThumbUrl( $suffix = false ) {
1694  return $this->getZoneUrl( 'thumb', $suffix );
1695  }
1696 
1703  function getTranscodedUrl( $suffix = false ) {
1704  return $this->getZoneUrl( 'transcoded', $suffix );
1705  }
1706 
1713  function getVirtualUrl( $suffix = false ) {
1714  $this->assertRepoDefined();
1715  $path = $this->repo->getVirtualUrl() . '/public/' . $this->getUrlRel();
1716  if ( $suffix !== false ) {
1717  $path .= '/' . rawurlencode( $suffix );
1718  }
1719 
1720  return $path;
1721  }
1722 
1729  function getArchiveVirtualUrl( $suffix = false ) {
1730  $this->assertRepoDefined();
1731  $path = $this->repo->getVirtualUrl() . '/public/archive/' . $this->getHashPath();
1732  if ( $suffix === false ) {
1733  $path = substr( $path, 0, -1 );
1734  } else {
1735  $path .= rawurlencode( $suffix );
1736  }
1737 
1738  return $path;
1739  }
1740 
1747  function getThumbVirtualUrl( $suffix = false ) {
1748  $this->assertRepoDefined();
1749  $path = $this->repo->getVirtualUrl() . '/thumb/' . $this->getUrlRel();
1750  if ( $suffix !== false ) {
1751  $path .= '/' . rawurlencode( $suffix );
1752  }
1753 
1754  return $path;
1755  }
1756 
1760  function isHashed() {
1761  $this->assertRepoDefined();
1762 
1763  return (bool)$this->repo->getHashLevels();
1764  }
1765 
1769  function readOnlyError() {
1770  throw new MWException( static::class . ': write operations are not supported' );
1771  }
1772 
1788  function recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '',
1789  $watch = false, $timestamp = false, User $user = null
1790  ) {
1791  $this->readOnlyError();
1792  }
1793 
1815  function publish( $src, $flags = 0, array $options = [] ) {
1816  $this->readOnlyError();
1817  }
1818 
1823  function formatMetadata( $context = false ) {
1824  if ( !$this->getHandler() ) {
1825  return false;
1826  }
1827 
1828  return $this->getHandler()->formatMetadata( $this, $context );
1829  }
1830 
1836  function isLocal() {
1837  return $this->repo && $this->repo->isLocal();
1838  }
1839 
1845  function getRepoName() {
1846  return $this->repo ? $this->repo->getName() : 'unknown';
1847  }
1848 
1854  function getRepo() {
1855  return $this->repo;
1856  }
1857 
1864  function isOld() {
1865  return false;
1866  }
1867 
1875  function isDeleted( $field ) {
1876  return false;
1877  }
1878 
1884  function getVisibility() {
1885  return 0;
1886  }
1887 
1893  function wasDeleted() {
1894  $title = $this->getTitle();
1895 
1896  return $title && $title->isDeletedQuick();
1897  }
1898 
1911  function move( $target ) {
1912  $this->readOnlyError();
1913  }
1914 
1930  function delete( $reason, $suppress = false, $user = null ) {
1931  $this->readOnlyError();
1932  }
1933 
1948  function restore( $versions = [], $unsuppress = false ) {
1949  $this->readOnlyError();
1950  }
1951 
1959  function isMultipage() {
1960  return $this->getHandler() && $this->handler->isMultiPage( $this );
1961  }
1962 
1969  function pageCount() {
1970  if ( !isset( $this->pageCount ) ) {
1971  if ( $this->getHandler() && $this->handler->isMultiPage( $this ) ) {
1972  $this->pageCount = $this->handler->pageCount( $this );
1973  } else {
1974  $this->pageCount = false;
1975  }
1976  }
1977 
1978  return $this->pageCount;
1979  }
1980 
1990  static function scaleHeight( $srcWidth, $srcHeight, $dstWidth ) {
1991  // Exact integer multiply followed by division
1992  if ( $srcWidth == 0 ) {
1993  return 0;
1994  } else {
1995  return (int)round( $srcHeight * $dstWidth / $srcWidth );
1996  }
1997  }
1998 
2009  function getImageSize( $filePath ) {
2010  if ( !$this->getHandler() ) {
2011  return false;
2012  }
2013 
2014  return $this->getHandler()->getImageSize( $this, $filePath );
2015  }
2016 
2023  function getDescriptionUrl() {
2024  if ( $this->repo ) {
2025  return $this->repo->getDescriptionUrl( $this->getName() );
2026  } else {
2027  return false;
2028  }
2029  }
2030 
2037  function getDescriptionText( $lang = false ) {
2038  global $wgLang;
2039 
2040  if ( !$this->repo || !$this->repo->fetchDescription ) {
2041  return false;
2042  }
2043 
2044  $lang = $lang ?: $wgLang;
2045 
2046  $renderUrl = $this->repo->getDescriptionRenderUrl( $this->getName(), $lang->getCode() );
2047  if ( $renderUrl ) {
2049  $key = $this->repo->getLocalCacheKey(
2050  'RemoteFileDescription',
2051  'url',
2052  $lang->getCode(),
2053  $this->getName()
2054  );
2055 
2056  return $cache->getWithSetCallback(
2057  $key,
2058  $this->repo->descriptionCacheExpiry ?: $cache::TTL_UNCACHEABLE,
2059  function ( $oldValue, &$ttl, array &$setOpts ) use ( $renderUrl ) {
2060  wfDebug( "Fetching shared description from $renderUrl\n" );
2061  $res = Http::get( $renderUrl, [], __METHOD__ );
2062  if ( !$res ) {
2064  }
2065 
2066  return $res;
2067  }
2068  );
2069  }
2070 
2071  return false;
2072  }
2073 
2086  function getDescription( $audience = self::FOR_PUBLIC, User $user = null ) {
2087  return null;
2088  }
2089 
2095  function getTimestamp() {
2096  $this->assertRepoDefined();
2097 
2098  return $this->repo->getFileTimestamp( $this->getPath() );
2099  }
2100 
2108  public function getDescriptionTouched() {
2109  return false;
2110  }
2111 
2117  function getSha1() {
2118  $this->assertRepoDefined();
2119 
2120  return $this->repo->getFileSha1( $this->getPath() );
2121  }
2122 
2128  function getStorageKey() {
2129  $hash = $this->getSha1();
2130  if ( !$hash ) {
2131  return false;
2132  }
2133  $ext = $this->getExtension();
2134  $dotExt = $ext === '' ? '' : ".$ext";
2135 
2136  return $hash . $dotExt;
2137  }
2138 
2147  function userCan( $field, User $user = null ) {
2148  return true;
2149  }
2150 
2154  function getStreamHeaders() {
2155  $handler = $this->getHandler();
2156  if ( $handler ) {
2157  return $handler->getStreamHeaders( $this->getMetadata() );
2158  } else {
2159  return [];
2160  }
2161  }
2162 
2166  function getLongDesc() {
2167  $handler = $this->getHandler();
2168  if ( $handler ) {
2169  return $handler->getLongDesc( $this );
2170  } else {
2171  return MediaHandler::getGeneralLongDesc( $this );
2172  }
2173  }
2174 
2178  function getShortDesc() {
2179  $handler = $this->getHandler();
2180  if ( $handler ) {
2181  return $handler->getShortDesc( $this );
2182  } else {
2183  return MediaHandler::getGeneralShortDesc( $this );
2184  }
2185  }
2186 
2190  function getDimensionsString() {
2191  $handler = $this->getHandler();
2192  if ( $handler ) {
2193  return $handler->getDimensionsString( $this );
2194  } else {
2195  return '';
2196  }
2197  }
2198 
2202  function getRedirected() {
2203  return $this->redirected;
2204  }
2205 
2209  function getRedirectedTitle() {
2210  if ( $this->redirected ) {
2211  if ( !$this->redirectTitle ) {
2212  $this->redirectTitle = Title::makeTitle( NS_FILE, $this->redirected );
2213  }
2214 
2215  return $this->redirectTitle;
2216  }
2217 
2218  return null;
2219  }
2220 
2225  function redirectedFrom( $from ) {
2226  $this->redirected = $from;
2227  }
2228 
2232  function isMissing() {
2233  return false;
2234  }
2235 
2240  public function isCacheable() {
2241  return true;
2242  }
2243 
2248  protected function assertRepoDefined() {
2249  if ( !( $this->repo instanceof $this->repoClass ) ) {
2250  throw new MWException( "A {$this->repoClass} object is not set for this File.\n" );
2251  }
2252  }
2253 
2258  protected function assertTitleDefined() {
2259  if ( !( $this->title instanceof Title ) ) {
2260  throw new MWException( "A Title object is not set for this File.\n" );
2261  }
2262  }
2263 
2268  public function isExpensiveToThumbnail() {
2269  $handler = $this->getHandler();
2270  return $handler ? $handler->isExpensiveToThumbnail( $this ) : false;
2271  }
2272 
2278  public function isTransformedLocally() {
2279  return true;
2280  }
2281 }
File\getExtension
getExtension()
Get the file extension, e.g.
Definition: File.php:311
File\THUMB_FULL_NAME
const THUMB_FULL_NAME
Definition: File.php:74
function
when a variable name is used in a function
Definition: design.txt:93
File\wasDeleted
wasDeleted()
Was this file ever deleted from the wiki?
Definition: File.php:1893
File\redirectedFrom
redirectedFrom( $from)
Definition: File.php:2225
File\getDescriptionTouched
getDescriptionTouched()
Returns the timestamp (in TS_MW format) of the last change of the description page.
Definition: File.php:2108
File\getPath
getPath()
Return the storage path to the file.
Definition: File.php:417
MediaTransformError
Basic media transform error class.
Definition: MediaTransformOutput.php:441
ThumbnailImage
Media transform output for images.
Definition: MediaTransformOutput.php:277
File\checkExtensionCompatibility
static checkExtensionCompatibility(File $old, $new)
Checks if file extensions are compatible.
Definition: File.php:249
$context
error also a ContextSource you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition: hooks.txt:2612
File\$repo
FileRepo LocalRepo ForeignAPIRepo bool $repo
Some member variables can be lazy-initialised using __get().
Definition: File.php:96
MediaHandler\getCommonMetaArray
getCommonMetaArray(File $file)
Get an array of standard (FormatMetadata type) metadata values.
Definition: MediaHandler.php:235
File\canAnimateThumbIfAppropriate
canAnimateThumbIfAppropriate()
Will the thumbnail be animated if one would expect it to be.
Definition: File.php:610
MediaHandler\normaliseParams
normaliseParams( $image, &$params)
Changes the parameter array as necessary, ready for transformation.
PROTO_CANONICAL
const PROTO_CANONICAL
Definition: Defines.php:221
File\getArchiveThumbPath
getArchiveThumbPath( $archiveName, $suffix=false)
Get the path of an archived file's thumbs, or a particular thumb if $suffix is specified.
Definition: File.php:1598
WANObjectCache\TTL_UNCACHEABLE
const TTL_UNCACHEABLE
Idiom for getWithSetCallback() callbacks to avoid calling set()
Definition: WANObjectCache.php:127
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
File\getHeight
getHeight( $page=1)
Return the height of the image.
Definition: File.php:477
File\DELETED_USER
const DELETED_USER
Definition: File.php:55
File\$tmpBucketedThumbCache
array $tmpBucketedThumbCache
Cache of tmp filepaths pointing to generated bucket thumbnails, keyed by width.
Definition: File.php:154
File\getDescriptionShortUrl
getDescriptionShortUrl()
Definition: File.php:364
File\getBitDepth
getBitDepth()
Return the bit depth of the file Overridden by LocalFile STUB.
Definition: File.php:686
File\getUrlRel
getUrlRel()
Get urlencoded path of the file relative to the public zone root.
Definition: File.php:1556
File\migrateThumbFile
migrateThumbFile( $thumbName)
Hook into transform() to allow migration of thumbnail files STUB Overridden by LocalFile.
Definition: File.php:1356
File\isMultipage
isMultipage()
Returns 'true' if this file is a type which supports multiple pages, e.g.
Definition: File.php:1959
File\getFullUrl
getFullUrl()
Return a fully-qualified URL to the file.
Definition: File.php:375
File\getZoneUrl
getZoneUrl( $zone, $suffix=false)
Get the URL of the zone directory, or a particular file if $suffix is specified.
Definition: File.php:1676
File\DELETED_RESTRICTED
const DELETED_RESTRICTED
Definition: File.php:56
File\getMetadata
getMetadata()
Get handler-specific metadata Overridden by LocalFile, UnregisteredLocalFile STUB.
Definition: File.php:639
File\RAW
const RAW
Definition: File.php:71
File\getStreamHeaders
getStreamHeaders()
Definition: File.php:2154
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
File\getIsSafeFileUncached
getIsSafeFileUncached()
Uncached accessor.
Definition: File.php:808
File\$transformScript
string $transformScript
URL of transformscript (for example thumb.php)
Definition: File.php:137
File\getRel
getRel()
Get the path of the file relative to the public zone root.
Definition: File.php:1512
File\isExpensiveToThumbnail
isExpensiveToThumbnail()
True if creating thumbnails from the file is large or otherwise resource-intensive.
Definition: File.php:2268
File\isMissing
isMissing()
Definition: File.php:2232
File\getOriginalTitle
getOriginalTitle()
Return the title used to find this file.
Definition: File.php:335
File\$redirectTitle
Title $redirectTitle
Definition: File.php:140
MediaHandler\getShortDesc
getShortDesc( $file)
Short description.
Definition: MediaHandler.php:586
File\getLastError
getLastError()
Get last thumbnailing error.
Definition: File.php:1400
$status
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Definition: hooks.txt:1049
File\getTimestamp
getTimestamp()
Get the 14-character timestamp of the file upload.
Definition: File.php:2095
File\getSha1
getSha1()
Get the SHA-1 base 36 hash of the file.
Definition: File.php:2117
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
File\convertMetadataVersion
convertMetadataVersion( $metadata, $version)
get versioned metadata
Definition: File.php:667
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:246
File\getUser
getUser( $type='text')
Returns ID or name of user who uploaded the file STUB.
Definition: File.php:532
DeferredUpdates\addUpdate
static addUpdate(DeferrableUpdate $update, $stage=self::POSTSEND)
Add an update to the deferred list to be run later by execute()
Definition: DeferredUpdates.php:76
FileBackend\extensionFromPath
static extensionFromPath( $path, $case='lowercase')
Get the final extension from a storage or FS path.
Definition: FileBackend.php:1507
unserialize
unserialize( $serialized)
Definition: ApiMessage.php:185
File\RENDER_FORCE
const RENDER_FORCE
Force rendering even if thumbnail already exist and using RENDER_NOW I.e.
Definition: File.php:64
File\getUrl
getUrl()
Return the URL of the file.
Definition: File.php:348
NS_FILE
const NS_FILE
Definition: Defines.php:68
File\compare
static compare(File $a, File $b)
Callback for usort() to do file sorts by name.
Definition: File.php:288
$params
$params
Definition: styleTest.css.php:40
File\getTranscodedUrl
getTranscodedUrl( $suffix=false)
Get the URL of the transcoded directory, or a particular file if $suffix is specified.
Definition: File.php:1703
File\getThumbnailSource
getThumbnailSource( $params)
Returns the most appropriate source image for the thumbnail, given a target thumbnail size.
Definition: File.php:1242
MEDIATYPE_UNKNOWN
const MEDIATYPE_UNKNOWN
Definition: defines.php:26
File\getWidth
getWidth( $page=1)
Return the width of the image.
Definition: File.php:463
File\recordUpload
recordUpload( $oldver, $desc, $license='', $copyStatus='', $source='', $watch=false, $timestamp=false, User $user=null)
Record a file upload in the upload log and the image table STUB Overridden by LocalFile.
Definition: File.php:1788
File\getMediaType
getMediaType()
Return the type of the media in the file.
Definition: File.php:718
File\restore
restore( $versions=[], $unsuppress=false)
Restore all or specified deleted revisions to the given file.
Definition: File.php:1948
$res
$res
Definition: database.txt:21
File\getCanonicalUrl
getCanonicalUrl()
Definition: File.php:382
File\splitMime
static splitMime( $mime)
Split an internet media type into its two components; if not a two-part name, set the minor type to '...
Definition: File.php:273
File\isVisible
isVisible()
Returns true if file exists in the repository and can be included in a page.
Definition: File.php:887
PoolCounterWorkViaCallback
Convenience class for dealing with PoolCounters using callbacks.
Definition: PoolCounterWorkViaCallback.php:28
$wgThumbnailBuckets
$wgThumbnailBuckets
When defined, is an array of image widths used as buckets for thumbnail generation.
Definition: DefaultSettings.php:1374
$type
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition: hooks.txt:2536
MediaHandler\getLongDesc
getLongDesc( $file)
Long description.
Definition: MediaHandler.php:596
IDBAccessObject
Interface for database access objects.
Definition: IDBAccessObject.php:55
File\$repoClass
string $repoClass
Required Repository class type.
Definition: File.php:151
File\getArchiveRel
getArchiveRel( $suffix=false)
Get the path of an archived file relative to the public zone root.
Definition: File.php:1523
File\isDeleted
isDeleted( $field)
Is this file a "deleted" file in a private archive? STUB.
Definition: File.php:1875
File\getVisibility
getVisibility()
Return the deletion bitfield STUB.
Definition: File.php:1884
File\getDescriptionText
getDescriptionText( $lang=false)
Get the HTML text of the description page, if available.
Definition: File.php:2037
$wgThumbnailMinimumBucketDistance
$wgThumbnailMinimumBucketDistance
When using thumbnail buckets as defined above, this sets the minimum distance to the bucket above the...
Definition: DefaultSettings.php:1391
MediaHandler\supportsBucketing
supportsBucketing()
Returns whether or not this handler supports the chained generation of thumbnails according to bucket...
Definition: MediaHandler.php:829
File\FOR_PUBLIC
const FOR_PUBLIC
Definition: File.php:69
File\normalizeTitle
static normalizeTitle( $title, $exception=false)
Given a string or Title object return either a valid Title object with namespace NS_FILE or null.
Definition: File.php:184
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
MediaHandler\getAvailableLanguages
getAvailableLanguages(File $file)
Get list of languages file can be viewed in.
Definition: MediaHandler.php:780
File\exists
exists()
Returns true if file exists in the repository.
Definition: File.php:877
File\getThumbVirtualUrl
getThumbVirtualUrl( $suffix=false)
Get the virtual URL for a thumbnail file or directory.
Definition: File.php:1747
$wgThumbnailEpoch
$wgThumbnailEpoch
If rendered thumbnail files are older than this timestamp, they will be rerendered on demand as if th...
Definition: DefaultSettings.php:1180
File\upgradeRow
upgradeRow()
Upgrade the database row if there is one Called by ImagePage STUB.
Definition: File.php:263
FileRepo
Base class for file repositories.
Definition: FileRepo.php:37
wfAppendQuery
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Definition: GlobalFunctions.php:500
File\$path
string $path
The storage path corresponding to one of the zones.
Definition: File.php:126
handler
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves set to a MediaTransformOutput the error message to be returned in an array you should do so by altering $wgNamespaceProtection and $wgNamespaceContentModels outside the handler
Definition: hooks.txt:783
File\isCacheable
isCacheable()
Check if this file object is small and can be cached.
Definition: File.php:2240
File\$canRender
bool $canRender
Whether the output of transform() for this file is likely to be valid.
Definition: File.php:143
File\getBucketThumbName
getBucketThumbName( $bucket)
Returns the name of the thumb for a given bucket.
Definition: File.php:1321
File
Implements some public methods and some protected utility functions which are required by multiple ch...
Definition: File.php:51
MediaHandler\isExpensiveToThumbnail
isExpensiveToThumbnail( $file)
True if creating thumbnails from the file is large or otherwise resource-intensive.
Definition: MediaHandler.php:819
File\getMimeType
getMimeType()
Returns the MIME type of the file.
Definition: File.php:707
File\getDefaultRenderLanguage
getDefaultRenderLanguage()
In files that support multiple language, what is the default language to use if none specified.
Definition: File.php:591
File\$url
string $url
The URL corresponding to one of the four basic zones.
Definition: File.php:117
MWException
MediaWiki exception.
Definition: MWException.php:26
File\getLocalRefPath
getLocalRefPath()
Get an FS copy or original of this file and return the path.
Definition: File.php:433
File\DELETED_COMMENT
const DELETED_COMMENT
Definition: File.php:54
File\transformErrorOutput
transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags)
Return either a MediaTransformError or placeholder thumbnail (if $wgIgnoreImageErrors)
Definition: File.php:1014
File\getIsSafeFile
getIsSafeFile()
Accessor for __get()
Definition: File.php:799
$starttime
$starttime
Definition: api.php:40
File\$redirectedTitle
Title $redirectedTitle
Definition: File.php:108
File\getThumbPath
getThumbPath( $suffix=false)
Get the path of the thumbnail directory, or a particular file if $suffix is specified.
Definition: File.php:1611
File\pageCount
pageCount()
Returns the number of pages of a multipage document, or false for documents which aren't multipage do...
Definition: File.php:1969
File\nextHistoryLine
nextHistoryLine()
Return the history of this file, line by line.
Definition: File.php:1477
File\normalizeExtension
static normalizeExtension( $extension)
Normalize a file extension to the common form, making it lowercase and checking some synonyms,...
Definition: File.php:224
PoolCounterWork\execute
execute( $skipcache=false)
Get the result of the work (whatever it is), or the result of the error() function.
Definition: PoolCounterWork.php:104
$page
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Definition: hooks.txt:2536
File\getArchiveVirtualUrl
getArchiveVirtualUrl( $suffix=false)
Get the public zone virtual URL for an archived version source file.
Definition: File.php:1729
MediaHandler\canAnimateThumbnail
canAnimateThumbnail( $file)
If the material is animated, we can animate the thumbnail.
Definition: MediaHandler.php:387
not
if not
Definition: COPYING.txt:307
File\purgeCache
purgeCache( $options=[])
Purge shared caches such as thumbnails and DB data caching STUB Overridden by LocalFile.
Definition: File.php:1421
$IP
$IP
Definition: update.php:3
$limit
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers please use GetContentModels hook to make them known to core if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive $limit
Definition: hooks.txt:1049
File\getTransformScript
getTransformScript()
Definition: File.php:894
$wgLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
Definition: design.txt:56
File\FOR_THIS_USER
const FOR_THIS_USER
Definition: File.php:70
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:514
File\getArchiveThumbRel
getArchiveThumbRel( $archiveName, $suffix=false)
Get the path, relative to the thumbnail zone root, for an archived file's thumbs directory or a speci...
Definition: File.php:1568
$mimeMagic
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array change it to the message you want to define you are encouraged to submit patches to MediaWiki s core to add new MIME types to mime types $mimeMagic
Definition: hooks.txt:2179
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
MimeMagic\singleton
static singleton()
Get an instance of this class.
Definition: MimeMagic.php:33
File\getStorageKey
getStorageKey()
Get the deletion archive key, "<sha1>.<ext>".
Definition: File.php:2128
File\__construct
__construct( $title, $repo)
Call this constructor from child classes.
Definition: File.php:166
File\isHashed
isHashed()
Definition: File.php:1760
File\generateAndSaveThumb
generateAndSaveThumb( $tmpFile, $transformParams, $flags)
Generates a thumbnail according to the given parameters and saves it to storage.
Definition: File.php:1118
wfDebug
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:999
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
File\getCommonMetaArray
getCommonMetaArray()
Like getMetadata but returns a handler independent array of common values.
Definition: File.php:649
File\getThumbRel
getThumbRel( $suffix=false)
Get the path, relative to the thumbnail zone root, of the thumbnail directory or a particular file if...
Definition: File.php:1541
TempFSFile\factory
static factory( $prefix, $extension='', $tmpDirectory=null)
Make a new temporary file on the file system.
Definition: TempFSFile.php:55
File\isTransformedLocally
isTransformedLocally()
Whether the thumbnails created on the same server as this code is running.
Definition: File.php:2278
Http\get
static get( $url, $options=[], $caller=__METHOD__)
Simple wrapper for Http::request( 'GET' )
Definition: Http.php:98
MediaHandler\getDimensionsString
getDimensionsString( $file)
Shown in file history box on image description page.
Definition: MediaHandler.php:647
File\canRender
canRender()
Checks if the output of transform() for this file is likely to be valid.
Definition: File.php:734
File\$fsFile
FSFile bool $fsFile
False if undefined.
Definition: File.php:111
$mime
if( $ext=='php'|| $ext=='php5') $mime
Definition: router.php:65
File\getRedirectedTitle
getRedirectedTitle()
Definition: File.php:2209
MediaHandler\convertMetadataVersion
convertMetadataVersion( $metadata, $version=1)
Convert metadata version.
Definition: MediaHandler.php:158
MediaHandler\getGeneralShortDesc
static getGeneralShortDesc( $file)
Used instead of getShortDesc if there is no handler registered for file.
Definition: MediaHandler.php:606
File\$pageCount
string false $pageCount
Number of pages of a multipage document, or false for documents which aren't multipage documents.
Definition: File.php:134
HTMLCacheUpdate
Class to invalidate the HTML cache of all the pages linking to a given title.
Definition: HTMLCacheUpdate.php:29
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:538
File\getAvailableLanguages
getAvailableLanguages()
Gives a (possibly empty) list of languages to render the file in.
Definition: File.php:575
File\iconThumb
iconThumb()
Get a ThumbnailImage representing a file type icon.
Definition: File.php:1378
File\purgeDescription
purgeDescription()
Purge the file description page, but don't go after pages using the file.
Definition: File.php:1429
File\isOld
isOld()
Returns true if the image is an old version STUB.
Definition: File.php:1864
File\$handler
MediaHandler $handler
Definition: File.php:114
NS_MEDIA
const NS_MEDIA
Definition: Defines.php:50
File\assertTitleDefined
assertTitleDefined()
Assert that $this->title is set to a Title.
Definition: File.php:2258
$wgIgnoreImageErrors
$wgIgnoreImageErrors
If set, inline scaled images will still produce "<img>" tags ready for output instead of showing an e...
Definition: DefaultSettings.php:1201
MediaHandler\getTransform
getTransform( $image, $dstPath, $dstUrl, $params)
Get a MediaTransformOutput object representing the transformed output.
Definition: MediaHandler.php:265
File\getHistory
getHistory( $limit=null, $start=null, $end=null, $inc=true)
Return a fragment of the history of file.
Definition: File.php:1464
title
title
Definition: parserTests.txt:211
File\generateThumbName
generateThumbName( $name, $params)
Generate a thumbnail file name from a name and specified parameters.
Definition: File.php:953
File\formatMetadata
formatMetadata( $context=false)
Definition: File.php:1823
File\createThumb
createThumb( $width, $height=-1)
Create a thumbnail of the image having the specified width/height.
Definition: File.php:992
File\$title
Title string bool $title
Definition: File.php:99
File\getDescriptionUrl
getDescriptionUrl()
Get the URL of the image description page.
Definition: File.php:2023
PROTO_RELATIVE
const PROTO_RELATIVE
Definition: Defines.php:219
$ret
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition: hooks.txt:1956
File\getArchiveThumbUrl
getArchiveThumbUrl( $archiveName, $suffix=false)
Get the URL of the archived file's thumbs, or a particular thumb if $suffix is specified.
Definition: File.php:1655
File\getName
getName()
Return the name of this file.
Definition: File.php:297
File\getArchiveUrl
getArchiveUrl( $suffix=false)
Get the URL of the archive directory, or a particular file if $suffix is specified.
Definition: File.php:1635
File\getThumbDisposition
getThumbDisposition( $thumbName, $dispositionType='inline')
Definition: File.php:1340
MediaHandler\getStreamHeaders
getStreamHeaders( $metadata)
Get useful response headers for GET/HEAD requests for a file with the given metadata.
Definition: MediaHandler.php:313
FSFile
Class representing a non-directory file on the file system.
Definition: FSFile.php:29
MediaHandler\doTransform
doTransform( $image, $dstPath, $dstUrl, $params, $flags=0)
Get a MediaTransformOutput object representing the transformed output.
File\isSafeFile
isSafeFile()
Determines if this media file is in a format that is unlikely to contain viruses or malicious content...
Definition: File.php:786
File\getRepoName
getRepoName()
Returns the name of the repository.
Definition: File.php:1845
File\DELETE_SOURCE
const DELETE_SOURCE
Definition: File.php:66
File\publish
publish( $src, $flags=0, array $options=[])
Move or copy a file to its public location.
Definition: File.php:1815
File\$extension
string $extension
File extension.
Definition: File.php:120
File\getBucketThumbPath
getBucketThumbPath( $bucket)
Returns the repo path of the thumb for a given bucket.
Definition: File.php:1311
File\$hashPath
string $hashPath
Relative path including trailing slash.
Definition: File.php:129
File\scaleHeight
static scaleHeight( $srcWidth, $srcHeight, $dstWidth)
Calculate the height of a thumbnail using the source and destination width.
Definition: File.php:1990
$handlerParams
see documentation in includes Linker php for Linker::makeImageLink & $handlerParams
Definition: hooks.txt:1767
File\RENDER_NOW
const RENDER_NOW
Force rendering in the current process.
Definition: File.php:59
File\transform
transform( $params, $flags=0)
Transform a media file.
Definition: File.php:1034
File\getTitle
getTitle()
Return the associated title object.
Definition: File.php:326
File\readOnlyError
readOnlyError()
Definition: File.php:1769
Title
Represents a title within MediaWiki.
Definition: Title.php:39
ForeignAPIRepo
A foreign repository with a remote MediaWiki with an API thingy.
Definition: ForeignAPIRepo.php:41
wfTempDir
wfTempDir()
Tries to get the system directory for temporary files.
Definition: GlobalFunctions.php:2061
File\$isSafeFile
bool $isSafeFile
Whether this media file is in a format that is unlikely to contain viruses or malicious content.
Definition: File.php:148
File\getThumbnailBucket
getThumbnailBucket( $desiredWidth, $page=1)
Return the smallest bucket from $wgThumbnailBuckets which is at least $wgThumbnailMinimumBucketDistan...
Definition: File.php:490
type
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type
Definition: postgres.txt:22
$cache
$cache
Definition: mcc.php:33
File\move
move( $target)
Move file to the new title.
Definition: File.php:1911
File\assertRepoDefined
assertRepoDefined()
Assert that $this->repo is set to a valid FileRepo instance.
Definition: File.php:2248
ObjectCache\getMainWANInstance
static getMainWANInstance()
Get the main WAN cache object.
Definition: ObjectCache.php:370
$ext
$ext
Definition: NoLocalSettings.php:25
File\getShortDesc
getShortDesc()
Definition: File.php:2178
File\getDescription
getDescription( $audience=self::FOR_PUBLIC, User $user=null)
Get description of file revision STUB.
Definition: File.php:2086
File\getLength
getLength()
Get the duration of a media file in seconds.
Definition: File.php:541
File\getLongDesc
getLongDesc()
Definition: File.php:2166
File\isLocal
isLocal()
Returns true if the file comes from the local file repository.
Definition: File.php:1836
Title\purgeSquid
purgeSquid()
Purge all applicable CDN URLs.
Definition: Title.php:3642
MediaHandler\getHandler
static getHandler( $type)
Get a MediaHandler for a given MIME type from the instance cache.
Definition: MediaHandler.php:46
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
File\getCanRender
getCanRender()
Accessor for __get()
Definition: File.php:746
MediaHandler\isAnimatedImage
isAnimatedImage( $file)
The material is an image, and is animated.
Definition: MediaHandler.php:376
$source
$source
Definition: mwdoc-filter.php:45
MediaHandler\isVectorized
isVectorized( $file)
The material is vectorized and thus scaling is lossless.
Definition: MediaHandler.php:364
File\mustRender
mustRender()
Return true if the file is of a type that can't be directly rendered by typical browsers and needs to...
Definition: File.php:760
File\load
load( $flags=0)
Load any lazy-loaded file object fields from source.
Definition: File.php:867
Title\isDeletedQuick
isDeletedQuick()
Is there a version of this page in the deletion archive?
Definition: Title.php:3194
File\resetHistory
resetHistory()
Reset the history pointer to the first element of the history.
Definition: File.php:1487
MediaHandler\getScriptedTransform
getScriptedTransform( $image, $script, $params)
Get a MediaTransformOutput object representing an alternate of the transformed output which will call...
Definition: MediaHandler.php:251
wfMessage
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
File\getRedirected
getRedirected()
Definition: File.php:2202
File\$name
string $name
The name of a file from its title object.
Definition: File.php:123
File\DELETED_FILE
const DELETED_FILE
Definition: File.php:53
name
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at name
Definition: design.txt:12
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
MediaHandler\getGeneralLongDesc
static getGeneralLongDesc( $file)
Used instead of getLongDesc if there is no handler registered for file.
Definition: MediaHandler.php:618
File\getRepo
getRepo()
Returns the repository.
Definition: File.php:1854
File\allowInlineDisplay
allowInlineDisplay()
Alias for canRender()
Definition: File.php:769
Title\invalidateCache
invalidateCache( $purgeTime=null)
Updates page_touched for this page; called from LinksUpdate.php.
Definition: Title.php:4454
MediaWikiServices
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
File\getThumbUrl
getThumbUrl( $suffix=false)
Get the URL of the thumbnail directory, or a particular file if $suffix is specified.
Definition: File.php:1693
File\isVectorized
isVectorized()
Return true if the file is vectorized.
Definition: File.php:555
File\getDimensionsString
getDimensionsString()
Definition: File.php:2190
File\getHandler
getHandler()
Get a MediaHandler instance for this file.
Definition: File.php:1365
File\__get
__get( $name)
Definition: File.php:205
$wgTrustedMediaFormats
$wgTrustedMediaFormats
list of trusted media-types and MIME types.
Definition: DefaultSettings.php:944
File\userCan
userCan( $field, User $user=null)
Determine if the current user is allowed to view a particular field of this file, if it's marked as d...
Definition: File.php:2147
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:50
File\generateBucketsIfNeeded
generateBucketsIfNeeded( $params, $flags=0)
Generates chained bucketed thumbnails if needed.
Definition: File.php:1185
File\thumbName
thumbName( $params, $flags=0)
Return the file name of a thumbnail with the specified parameters.
Definition: File.php:938
File\$lastError
string $lastError
Text of last error.
Definition: File.php:102
File\$redirected
string $redirected
Main part of the title, with underscores (Title::getDBkey)
Definition: File.php:105
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
File\getImageSize
getImageSize( $filePath)
Get an image size array like that returned by getImageSize(), or false if it can't be determined.
Definition: File.php:2009
FSFile\getPath
getPath()
Returns the file system path.
Definition: FSFile.php:50
File\makeTransformTmpFile
makeTransformTmpFile( $thumbPath)
Creates a temp FS file with the same extension and the thumbnail.
Definition: File.php:1330
$options
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Definition: hooks.txt:1049
File\getArchivePath
getArchivePath( $suffix=false)
Get the path of the archived file.
Definition: File.php:1585
File\purgeEverything
purgeEverything()
Purge metadata and all affected pages when the file is created, deleted, or majorly updated.
Definition: File.php:1441
File\getUnscaledThumb
getUnscaledThumb( $handlerParams=[])
Get a ThumbnailImage which is the same size as the source.
Definition: File.php:915
File\getHashPath
getHashPath()
Get the filename hash component of the directory including trailing slash, e.g.
Definition: File.php:1497
$flags
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition: hooks.txt:2749
File\isTrustedFile
isTrustedFile()
Returns true if the file is flagged as trusted.
Definition: File.php:852
LocalRepo
A repository that stores files in the local filesystem and registers them in the wiki's own database.
Definition: LocalRepo.php:35
File\getSize
getSize()
Return the size of the image file, in bytes Overridden by LocalFile, UnregisteredLocalFile STUB.
Definition: File.php:696
MediaHandler
Base media handler class.
Definition: MediaHandler.php:30
MediaHandler\getLength
getLength( $file)
If its an audio file, return the length of the file.
Definition: MediaHandler.php:810
wfExpandUrl
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Definition: GlobalFunctions.php:552
array
the array() calling protocol came about after MediaWiki 1.4rc1.
File\getThumbnails
getThumbnails()
Get all thumbnail names previously generated for this file STUB Overridden by LocalFile.
Definition: File.php:1410
MediaHandler\getDefaultRenderLanguage
getDefaultRenderLanguage(File $file)
On file types that support renderings in multiple languages, which language is used by default if uns...
Definition: MediaHandler.php:796
File\getTranscodedPath
getTranscodedPath( $suffix=false)
Get the path of the transcoded directory, or a particular file if $suffix is specified.
Definition: File.php:1623
File\getViewURL
getViewURL()
Definition: File.php:389
File\getVirtualUrl
getVirtualUrl( $suffix=false)
Get the public zone virtual URL for a current version source file.
Definition: File.php:1713
FileBackend\makeContentDisposition
static makeContentDisposition( $type, $filename='')
Build a Content-Disposition header value per RFC 6266.
Definition: FileBackend.php:1540