MediaWiki REL1_33
File.php
Go to the documentation of this file.
1<?php
9
32// @phan-file-suppress PhanTypeMissingReturn false positives
52abstract class File implements IDBAccessObject {
53 // Bitfield values akin to the Revision deletion constants
54 const DELETED_FILE = 1;
55 const DELETED_COMMENT = 2;
56 const DELETED_USER = 4;
58
60 const RENDER_NOW = 1;
65 const RENDER_FORCE = 2;
66
67 const DELETE_SOURCE = 1;
68
69 // Audience options for File::getDescription()
70 const FOR_PUBLIC = 1;
71 const FOR_THIS_USER = 2;
72 const RAW = 3;
73
74 // Options for File::thumbName()
75 const THUMB_FULL_NAME = 1;
76
97 public $repo;
98
100 protected $title;
101
103 protected $lastError;
104
106 protected $redirected;
107
110
112 protected $fsFile;
113
115 protected $handler;
116
118 protected $url;
119
121 protected $extension;
122
124 protected $name;
125
127 protected $path;
128
130 protected $hashPath;
131
135 protected $pageCount;
136
139
141 protected $redirectTitle;
142
144 protected $canRender;
145
149 protected $isSafeFile;
150
152 protected $repoClass = FileRepo::class;
153
156
167 function __construct( $title, $repo ) {
168 // Some subclasses do not use $title, but set name/title some other way
169 if ( $title !== false ) {
170 $title = self::normalizeTitle( $title, 'exception' );
171 }
172 $this->title = $title;
173 $this->repo = $repo;
174 }
175
185 static function normalizeTitle( $title, $exception = false ) {
186 $ret = $title;
187 if ( $ret instanceof Title ) {
188 # Normalize NS_MEDIA -> NS_FILE
189 if ( $ret->getNamespace() == NS_MEDIA ) {
190 $ret = Title::makeTitleSafe( NS_FILE, $ret->getDBkey() );
191 # Sanity check the title namespace
192 } elseif ( $ret->getNamespace() !== NS_FILE ) {
193 $ret = null;
194 }
195 } else {
196 # Convert strings to Title objects
197 $ret = Title::makeTitleSafe( NS_FILE, (string)$ret );
198 }
199 if ( !$ret && $exception !== false ) {
200 throw new MWException( "`$title` is not a valid file title." );
201 }
202
203 return $ret;
204 }
205
206 function __get( $name ) {
207 $function = [ $this, 'get' . ucfirst( $name ) ];
208 if ( !is_callable( $function ) ) {
209 return null;
210 } else {
211 $this->$name = $function();
212
213 return $this->$name;
214 }
215 }
216
225 static function normalizeExtension( $extension ) {
226 $lower = strtolower( $extension );
227 $squish = [
228 'htm' => 'html',
229 'jpeg' => 'jpg',
230 'mpeg' => 'mpg',
231 'tiff' => 'tif',
232 'ogv' => 'ogg' ];
233 if ( isset( $squish[$lower] ) ) {
234 return $squish[$lower];
235 } elseif ( preg_match( '/^[0-9a-z]+$/', $lower ) ) {
236 return $lower;
237 } else {
238 return '';
239 }
240 }
241
250 static function checkExtensionCompatibility( File $old, $new ) {
251 $oldMime = $old->getMimeType();
252 $n = strrpos( $new, '.' );
253 $newExt = self::normalizeExtension( $n ? substr( $new, $n + 1 ) : '' );
254 $mimeMagic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
255
256 return $mimeMagic->isMatchingExtension( $newExt, $oldMime );
257 }
258
264 function upgradeRow() {
265 }
266
274 public static function splitMime( $mime ) {
275 if ( strpos( $mime, '/' ) !== false ) {
276 return explode( '/', $mime, 2 );
277 } else {
278 return [ $mime, 'unknown' ];
279 }
280 }
281
289 public static function compare( File $a, File $b ) {
290 return strcmp( $a->getName(), $b->getName() );
291 }
292
298 public function getName() {
299 if ( !isset( $this->name ) ) {
300 $this->assertRepoDefined();
301 $this->name = $this->repo->getNameFromTitle( $this->title );
302 }
303
304 return $this->name;
305 }
306
312 function getExtension() {
313 if ( !isset( $this->extension ) ) {
314 $n = strrpos( $this->getName(), '.' );
315 $this->extension = self::normalizeExtension(
316 $n ? substr( $this->getName(), $n + 1 ) : '' );
317 }
318
319 return $this->extension;
320 }
321
327 public function getTitle() {
328 return $this->title;
329 }
330
336 public function getOriginalTitle() {
337 if ( $this->redirected ) {
338 return $this->getRedirectedTitle();
339 }
340
341 return $this->title;
342 }
343
349 public function getUrl() {
350 if ( !isset( $this->url ) ) {
351 $this->assertRepoDefined();
352 $ext = $this->getExtension();
353 $this->url = $this->repo->getZoneUrl( 'public', $ext ) . '/' . $this->getUrlRel();
354 }
355
356 return $this->url;
357 }
358
365 public function getDescriptionShortUrl() {
366 return null;
367 }
368
376 public function getFullUrl() {
377 return wfExpandUrl( $this->getUrl(), PROTO_RELATIVE );
378 }
379
383 public function getCanonicalUrl() {
384 return wfExpandUrl( $this->getUrl(), PROTO_CANONICAL );
385 }
386
390 function getViewURL() {
391 if ( $this->mustRender() ) {
392 if ( $this->canRender() ) {
393 return $this->createThumb( $this->getWidth() );
394 } else {
395 wfDebug( __METHOD__ . ': supposed to render ' . $this->getName() .
396 ' (' . $this->getMimeType() . "), but can't!\n" );
397
398 return $this->getUrl(); # hm... return NULL?
399 }
400 } else {
401 return $this->getUrl();
402 }
403 }
404
418 public function getPath() {
419 if ( !isset( $this->path ) ) {
420 $this->assertRepoDefined();
421 $this->path = $this->repo->getZonePath( 'public' ) . '/' . $this->getRel();
422 }
423
424 return $this->path;
425 }
426
434 public function getLocalRefPath() {
435 $this->assertRepoDefined();
436 if ( !isset( $this->fsFile ) ) {
437 $starttime = microtime( true );
438 $this->fsFile = $this->repo->getLocalReference( $this->getPath() );
439
440 $statTiming = microtime( true ) - $starttime;
441 MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
442 'media.thumbnail.generate.fetchoriginal', 1000 * $statTiming );
443
444 if ( !$this->fsFile ) {
445 $this->fsFile = false; // null => false; cache negative hits
446 }
447 }
448
449 return ( $this->fsFile )
450 ? $this->fsFile->getPath()
451 : false;
452 }
453
464 public function getWidth( $page = 1 ) {
465 return false;
466 }
467
478 public function getHeight( $page = 1 ) {
479 return false;
480 }
481
491 public function getThumbnailBucket( $desiredWidth, $page = 1 ) {
493
494 $imageWidth = $this->getWidth( $page );
495
496 if ( $imageWidth === false ) {
497 return false;
498 }
499
500 if ( $desiredWidth > $imageWidth ) {
501 return false;
502 }
503
504 if ( !$wgThumbnailBuckets ) {
505 return false;
506 }
507
508 $sortedBuckets = $wgThumbnailBuckets;
509
510 sort( $sortedBuckets );
511
512 foreach ( $sortedBuckets as $bucket ) {
513 if ( $bucket >= $imageWidth ) {
514 return false;
515 }
516
517 if ( $bucket - $wgThumbnailMinimumBucketDistance > $desiredWidth ) {
518 return $bucket;
519 }
520 }
521
522 // Image is bigger than any available bucket
523 return false;
524 }
525
533 public function getUser( $type = 'text' ) {
534 return null;
535 }
536
542 public function getLength() {
543 $handler = $this->getHandler();
544 if ( $handler ) {
545 return $handler->getLength( $this );
546 } else {
547 return 0;
548 }
549 }
550
556 public function isVectorized() {
557 $handler = $this->getHandler();
558 if ( $handler ) {
559 return $handler->isVectorized( $this );
560 } else {
561 return false;
562 }
563 }
564
576 public function getAvailableLanguages() {
577 $handler = $this->getHandler();
578 if ( $handler ) {
579 return $handler->getAvailableLanguages( $this );
580 } else {
581 return [];
582 }
583 }
584
592 public function getMatchedLanguage( $userPreferredLanguage ) {
593 $handler = $this->getHandler();
594 if ( $handler ) {
596 $userPreferredLanguage,
598 );
599 }
600
601 return null;
602 }
603
611 public function getDefaultRenderLanguage() {
612 $handler = $this->getHandler();
613 if ( $handler ) {
614 return $handler->getDefaultRenderLanguage( $this );
615 } else {
616 return null;
617 }
618 }
619
631 $handler = $this->getHandler();
632 if ( !$handler ) {
633 // We cannot handle image whatsoever, thus
634 // one would not expect it to be animated
635 // so true.
636 return true;
637 }
638
639 return !$this->allowInlineDisplay()
640 // Image is not animated, so one would
641 // not expect thumb to be
642 || !$handler->isAnimatedImage( $this )
643 // Image is animated, but thumbnail isn't.
644 // This is unexpected to the user.
645 || $handler->canAnimateThumbnail( $this );
646 }
647
654 public function getMetadata() {
655 return false;
656 }
657
664 public function getCommonMetaArray() {
665 $handler = $this->getHandler();
666
667 if ( !$handler ) {
668 return false;
669 }
670
671 return $handler->getCommonMetaArray( $this );
672 }
673
682 public function convertMetadataVersion( $metadata, $version ) {
683 $handler = $this->getHandler();
684 if ( !is_array( $metadata ) ) {
685 // Just to make the return type consistent
686 $metadata = unserialize( $metadata );
687 }
688 if ( $handler ) {
689 return $handler->convertMetadataVersion( $metadata, $version );
690 } else {
691 return $metadata;
692 }
693 }
694
701 public function getBitDepth() {
702 return 0;
703 }
704
711 public function getSize() {
712 return false;
713 }
714
722 function getMimeType() {
723 return 'unknown/unknown';
724 }
725
733 function getMediaType() {
734 return MEDIATYPE_UNKNOWN;
735 }
736
749 function canRender() {
750 if ( !isset( $this->canRender ) ) {
751 $this->canRender = $this->getHandler() && $this->handler->canRender( $this ) && $this->exists();
752 }
753
754 return $this->canRender;
755 }
756
761 protected function getCanRender() {
762 return $this->canRender();
763 }
764
775 function mustRender() {
776 return $this->getHandler() && $this->handler->mustRender( $this );
777 }
778
785 return $this->canRender();
786 }
787
801 function isSafeFile() {
802 if ( !isset( $this->isSafeFile ) ) {
803 $this->isSafeFile = $this->getIsSafeFileUncached();
804 }
805
806 return $this->isSafeFile;
807 }
808
814 protected function getIsSafeFile() {
815 return $this->isSafeFile();
816 }
817
823 protected function getIsSafeFileUncached() {
825
826 if ( $this->allowInlineDisplay() ) {
827 return true;
828 }
829 if ( $this->isTrustedFile() ) {
830 return true;
831 }
832
833 $type = $this->getMediaType();
834 $mime = $this->getMimeType();
835 # wfDebug( "LocalFile::isSafeFile: type= $type, mime= $mime\n" );
836
837 if ( !$type || $type === MEDIATYPE_UNKNOWN ) {
838 return false; # unknown type, not trusted
839 }
840 if ( in_array( $type, $wgTrustedMediaFormats ) ) {
841 return true;
842 }
843
844 if ( $mime === "unknown/unknown" ) {
845 return false; # unknown type, not trusted
846 }
847 if ( in_array( $mime, $wgTrustedMediaFormats ) ) {
848 return true;
849 }
850
851 return false;
852 }
853
867 function isTrustedFile() {
868 # this could be implemented to check a flag in the database,
869 # look for signatures, etc
870 return false;
871 }
872
882 public function load( $flags = 0 ) {
883 }
884
892 public function exists() {
893 return $this->getPath() && $this->repo->fileExists( $this->path );
894 }
895
902 public function isVisible() {
903 return $this->exists();
904 }
905
910 if ( !isset( $this->transformScript ) ) {
911 $this->transformScript = false;
912 if ( $this->repo ) {
913 $script = $this->repo->getThumbScriptUrl();
914 if ( $script ) {
915 $this->transformScript = wfAppendQuery( $script, [ 'f' => $this->getName() ] );
916 }
917 }
918 }
919
921 }
922
931 $hp =& $handlerParams;
932 $page = $hp['page'] ?? false;
933 $width = $this->getWidth( $page );
934 if ( !$width ) {
935 return $this->iconThumb();
936 }
937 $hp['width'] = $width;
938 // be sure to ignore any height specification as well (T64258)
939 unset( $hp['height'] );
940
941 return $this->transform( $hp );
942 }
943
953 public function thumbName( $params, $flags = 0 ) {
954 $name = ( $this->repo && !( $flags & self::THUMB_FULL_NAME ) )
955 ? $this->repo->nameForThumb( $this->getName() )
956 : $this->getName();
957
958 return $this->generateThumbName( $name, $params );
959 }
960
968 public function generateThumbName( $name, $params ) {
969 if ( !$this->getHandler() ) {
970 return null;
971 }
972 $extension = $this->getExtension();
973 list( $thumbExt, ) = $this->getHandler()->getThumbType(
974 $extension, $this->getMimeType(), $params );
975 $thumbName = $this->getHandler()->makeParamString( $params );
976
977 if ( $this->repo->supportsSha1URLs() ) {
978 $thumbName .= '-' . $this->getSha1() . '.' . $thumbExt;
979 } else {
980 $thumbName .= '-' . $name;
981
982 if ( $thumbExt != $extension ) {
983 $thumbName .= ".$thumbExt";
984 }
985 }
986
987 return $thumbName;
988 }
989
1007 public function createThumb( $width, $height = -1 ) {
1008 $params = [ 'width' => $width ];
1009 if ( $height != -1 ) {
1010 $params['height'] = $height;
1011 }
1012 $thumb = $this->transform( $params );
1013 if ( !$thumb || $thumb->isError() ) {
1014 return '';
1015 }
1016
1017 return $thumb->getUrl();
1018 }
1019
1029 protected function transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags ) {
1030 global $wgIgnoreImageErrors;
1031
1032 $handler = $this->getHandler();
1033 if ( $handler && $wgIgnoreImageErrors && !( $flags & self::RENDER_NOW ) ) {
1034 return $handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
1035 } else {
1036 return new MediaTransformError( 'thumbnail_error',
1037 $params['width'], 0, wfMessage( 'thumbnail-dest-create' ) );
1038 }
1039 }
1040
1049 function transform( $params, $flags = 0 ) {
1050 global $wgThumbnailEpoch;
1051
1052 do {
1053 if ( !$this->canRender() ) {
1054 $thumb = $this->iconThumb();
1055 break; // not a bitmap or renderable image, don't try
1056 }
1057
1058 // Get the descriptionUrl to embed it as comment into the thumbnail. T21791.
1059 $descriptionUrl = $this->getDescriptionUrl();
1060 if ( $descriptionUrl ) {
1061 $params['descriptionUrl'] = wfExpandUrl( $descriptionUrl, PROTO_CANONICAL );
1062 }
1063
1064 $handler = $this->getHandler();
1065 $script = $this->getTransformScript();
1066 if ( $script && !( $flags & self::RENDER_NOW ) ) {
1067 // Use a script to transform on client request, if possible
1068 $thumb = $handler->getScriptedTransform( $this, $script, $params );
1069 if ( $thumb ) {
1070 break;
1071 }
1072 }
1073
1074 $normalisedParams = $params;
1075 $handler->normaliseParams( $this, $normalisedParams );
1076
1077 $thumbName = $this->thumbName( $normalisedParams );
1078 $thumbUrl = $this->getThumbUrl( $thumbName );
1079 $thumbPath = $this->getThumbPath( $thumbName ); // final thumb path
1080
1081 if ( $this->repo ) {
1082 // Defer rendering if a 404 handler is set up...
1083 if ( $this->repo->canTransformVia404() && !( $flags & self::RENDER_NOW ) ) {
1084 // XXX: Pass in the storage path even though we are not rendering anything
1085 // and the path is supposed to be an FS path. This is due to getScalerType()
1086 // getting called on the path and clobbering $thumb->getUrl() if it's false.
1087 $thumb = $handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
1088 break;
1089 }
1090 // Check if an up-to-date thumbnail already exists...
1091 wfDebug( __METHOD__ . ": Doing stat for $thumbPath\n" );
1092 if ( !( $flags & self::RENDER_FORCE ) && $this->repo->fileExists( $thumbPath ) ) {
1093 $timestamp = $this->repo->getFileTimestamp( $thumbPath );
1094 if ( $timestamp !== false && $timestamp >= $wgThumbnailEpoch ) {
1095 // XXX: Pass in the storage path even though we are not rendering anything
1096 // and the path is supposed to be an FS path. This is due to getScalerType()
1097 // getting called on the path and clobbering $thumb->getUrl() if it's false.
1098 $thumb = $handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
1099 $thumb->setStoragePath( $thumbPath );
1100 break;
1101 }
1102 } elseif ( $flags & self::RENDER_FORCE ) {
1103 wfDebug( __METHOD__ . " forcing rendering per flag File::RENDER_FORCE\n" );
1104 }
1105
1106 // If the backend is ready-only, don't keep generating thumbnails
1107 // only to return transformation errors, just return the error now.
1108 if ( $this->repo->getReadOnlyReason() !== false ) {
1109 $thumb = $this->transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags );
1110 break;
1111 }
1112 }
1113
1114 $tmpFile = $this->makeTransformTmpFile( $thumbPath );
1115
1116 if ( !$tmpFile ) {
1117 $thumb = $this->transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags );
1118 } else {
1119 $thumb = $this->generateAndSaveThumb( $tmpFile, $params, $flags );
1120 }
1121 } while ( false );
1122
1123 return is_object( $thumb ) ? $thumb : false;
1124 }
1125
1133 public function generateAndSaveThumb( $tmpFile, $transformParams, $flags ) {
1134 global $wgIgnoreImageErrors;
1135
1136 $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
1137
1138 $handler = $this->getHandler();
1139
1140 $normalisedParams = $transformParams;
1141 $handler->normaliseParams( $this, $normalisedParams );
1142
1143 $thumbName = $this->thumbName( $normalisedParams );
1144 $thumbUrl = $this->getThumbUrl( $thumbName );
1145 $thumbPath = $this->getThumbPath( $thumbName ); // final thumb path
1146
1147 $tmpThumbPath = $tmpFile->getPath();
1148
1149 if ( $handler->supportsBucketing() ) {
1150 $this->generateBucketsIfNeeded( $normalisedParams, $flags );
1151 }
1152
1153 $starttime = microtime( true );
1154
1155 // Actually render the thumbnail...
1156 $thumb = $handler->doTransform( $this, $tmpThumbPath, $thumbUrl, $transformParams );
1157 $tmpFile->bind( $thumb ); // keep alive with $thumb
1158
1159 $statTiming = microtime( true ) - $starttime;
1160 $stats->timing( 'media.thumbnail.generate.transform', 1000 * $statTiming );
1161
1162 if ( !$thumb ) { // bad params?
1163 $thumb = false;
1164 } elseif ( $thumb->isError() ) { // transform error
1166 $this->lastError = $thumb->toText();
1167 // Ignore errors if requested
1168 if ( $wgIgnoreImageErrors && !( $flags & self::RENDER_NOW ) ) {
1169 $thumb = $handler->getTransform( $this, $tmpThumbPath, $thumbUrl, $transformParams );
1170 }
1171 } elseif ( $this->repo && $thumb->hasFile() && !$thumb->fileIsSource() ) {
1172 // Copy the thumbnail from the file system into storage...
1173
1174 $starttime = microtime( true );
1175
1176 $disposition = $this->getThumbDisposition( $thumbName );
1177 $status = $this->repo->quickImport( $tmpThumbPath, $thumbPath, $disposition );
1178 if ( $status->isOK() ) {
1179 $thumb->setStoragePath( $thumbPath );
1180 } else {
1181 $thumb = $this->transformErrorOutput( $thumbPath, $thumbUrl, $transformParams, $flags );
1182 }
1183
1184 $statTiming = microtime( true ) - $starttime;
1185 $stats->timing( 'media.thumbnail.generate.store', 1000 * $statTiming );
1186
1187 // Give extensions a chance to do something with this thumbnail...
1188 Hooks::run( 'FileTransformed', [ $this, $thumb, $tmpThumbPath, $thumbPath ] );
1189 }
1190
1191 return $thumb;
1192 }
1193
1200 protected function generateBucketsIfNeeded( $params, $flags = 0 ) {
1201 if ( !$this->repo
1202 || !isset( $params['physicalWidth'] )
1203 || !isset( $params['physicalHeight'] )
1204 ) {
1205 return false;
1206 }
1207
1208 $bucket = $this->getThumbnailBucket( $params['physicalWidth'] );
1209
1210 if ( !$bucket || $bucket == $params['physicalWidth'] ) {
1211 return false;
1212 }
1213
1214 $bucketPath = $this->getBucketThumbPath( $bucket );
1215
1216 if ( $this->repo->fileExists( $bucketPath ) ) {
1217 return false;
1218 }
1219
1220 $starttime = microtime( true );
1221
1222 $params['physicalWidth'] = $bucket;
1223 $params['width'] = $bucket;
1224
1225 $params = $this->getHandler()->sanitizeParamsForBucketing( $params );
1226
1227 $tmpFile = $this->makeTransformTmpFile( $bucketPath );
1228
1229 if ( !$tmpFile ) {
1230 return false;
1231 }
1232
1233 $thumb = $this->generateAndSaveThumb( $tmpFile, $params, $flags );
1234
1235 $buckettime = microtime( true ) - $starttime;
1236
1237 if ( !$thumb || $thumb->isError() ) {
1238 return false;
1239 }
1240
1241 $this->tmpBucketedThumbCache[$bucket] = $tmpFile->getPath();
1242 // For the caching to work, we need to make the tmp file survive as long as
1243 // this object exists
1244 $tmpFile->bind( $this );
1245
1246 MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
1247 'media.thumbnail.generate.bucket', 1000 * $buckettime );
1248
1249 return true;
1250 }
1251
1257 public function getThumbnailSource( $params ) {
1258 if ( $this->repo
1259 && $this->getHandler()->supportsBucketing()
1260 && isset( $params['physicalWidth'] )
1261 && $bucket = $this->getThumbnailBucket( $params['physicalWidth'] )
1262 ) {
1263 if ( $this->getWidth() != 0 ) {
1264 $bucketHeight = round( $this->getHeight() * ( $bucket / $this->getWidth() ) );
1265 } else {
1266 $bucketHeight = 0;
1267 }
1268
1269 // Try to avoid reading from storage if the file was generated by this script
1270 if ( isset( $this->tmpBucketedThumbCache[$bucket] ) ) {
1271 $tmpPath = $this->tmpBucketedThumbCache[$bucket];
1272
1273 if ( file_exists( $tmpPath ) ) {
1274 return [
1275 'path' => $tmpPath,
1276 'width' => $bucket,
1277 'height' => $bucketHeight
1278 ];
1279 }
1280 }
1281
1282 $bucketPath = $this->getBucketThumbPath( $bucket );
1283
1284 if ( $this->repo->fileExists( $bucketPath ) ) {
1285 $fsFile = $this->repo->getLocalReference( $bucketPath );
1286
1287 if ( $fsFile ) {
1288 return [
1289 'path' => $fsFile->getPath(),
1290 'width' => $bucket,
1291 'height' => $bucketHeight
1292 ];
1293 }
1294 }
1295 }
1296
1297 // Thumbnailing a very large file could result in network saturation if
1298 // everyone does it at once.
1299 if ( $this->getSize() >= 1e7 ) { // 10MB
1300 $work = new PoolCounterWorkViaCallback( 'GetLocalFileCopy', sha1( $this->getName() ),
1301 [
1302 'doWork' => function () {
1303 return $this->getLocalRefPath();
1304 }
1305 ]
1306 );
1307 $srcPath = $work->execute();
1308 } else {
1309 $srcPath = $this->getLocalRefPath();
1310 }
1311
1312 // Original file
1313 return [
1314 'path' => $srcPath,
1315 'width' => $this->getWidth(),
1316 'height' => $this->getHeight()
1317 ];
1318 }
1319
1325 protected function getBucketThumbPath( $bucket ) {
1326 $thumbName = $this->getBucketThumbName( $bucket );
1327 return $this->getThumbPath( $thumbName );
1328 }
1329
1335 protected function getBucketThumbName( $bucket ) {
1336 return $this->thumbName( [ 'physicalWidth' => $bucket ] );
1337 }
1338
1344 protected function makeTransformTmpFile( $thumbPath ) {
1345 $thumbExt = FileBackend::extensionFromPath( $thumbPath );
1346 return TempFSFile::factory( 'transform_', $thumbExt, wfTempDir() );
1347 }
1348
1354 function getThumbDisposition( $thumbName, $dispositionType = 'inline' ) {
1355 $fileName = $this->name; // file name to suggest
1356 $thumbExt = FileBackend::extensionFromPath( $thumbName );
1357 if ( $thumbExt != '' && $thumbExt !== $this->getExtension() ) {
1358 $fileName .= ".$thumbExt";
1359 }
1360
1361 return FileBackend::makeContentDisposition( $dispositionType, $fileName );
1362 }
1363
1370 function migrateThumbFile( $thumbName ) {
1371 }
1372
1379 function getHandler() {
1380 if ( !isset( $this->handler ) ) {
1381 $this->handler = MediaHandler::getHandler( $this->getMimeType() );
1382 }
1383
1384 return $this->handler;
1385 }
1386
1392 function iconThumb() {
1393 global $wgResourceBasePath, $IP;
1394 $assetsPath = "$wgResourceBasePath/resources/assets/file-type-icons/";
1395 $assetsDirectory = "$IP/resources/assets/file-type-icons/";
1396
1397 $try = [ 'fileicon-' . $this->getExtension() . '.png', 'fileicon.png' ];
1398 foreach ( $try as $icon ) {
1399 if ( file_exists( $assetsDirectory . $icon ) ) { // always FS
1400 $params = [ 'width' => 120, 'height' => 120 ];
1401
1402 return new ThumbnailImage( $this, $assetsPath . $icon, false, $params );
1403 }
1404 }
1405
1406 return null;
1407 }
1408
1414 function getLastError() {
1415 return $this->lastError;
1416 }
1417
1424 function getThumbnails() {
1425 return [];
1426 }
1427
1435 function purgeCache( $options = [] ) {
1436 }
1437
1443 function purgeDescription() {
1444 $title = $this->getTitle();
1445 if ( $title ) {
1447 $title->purgeSquid();
1448 }
1449 }
1450
1455 function purgeEverything() {
1456 // Delete thumbnails and refresh file metadata cache
1457 $this->purgeCache();
1458 $this->purgeDescription();
1459
1460 // Purge cache of all pages using this file
1461 $title = $this->getTitle();
1462 if ( $title ) {
1463 DeferredUpdates::addUpdate(
1464 new HTMLCacheUpdate( $title, 'imagelinks', 'file-purge' )
1465 );
1466 }
1467 }
1468
1480 function getHistory( $limit = null, $start = null, $end = null, $inc = true ) {
1481 return [];
1482 }
1483
1493 public function nextHistoryLine() {
1494 return false;
1495 }
1496
1503 public function resetHistory() {
1504 }
1505
1513 function getHashPath() {
1514 if ( !isset( $this->hashPath ) ) {
1515 $this->assertRepoDefined();
1516 $this->hashPath = $this->repo->getHashPath( $this->getName() );
1517 }
1518
1519 return $this->hashPath;
1520 }
1521
1528 function getRel() {
1529 return $this->getHashPath() . $this->getName();
1530 }
1531
1539 function getArchiveRel( $suffix = false ) {
1540 $path = 'archive/' . $this->getHashPath();
1541 if ( $suffix === false ) {
1542 $path = rtrim( $path, '/' );
1543 } else {
1544 $path .= $suffix;
1545 }
1546
1547 return $path;
1548 }
1549
1557 function getThumbRel( $suffix = false ) {
1558 $path = $this->getRel();
1559 if ( $suffix !== false ) {
1560 $path .= '/' . $suffix;
1561 }
1562
1563 return $path;
1564 }
1565
1572 function getUrlRel() {
1573 return $this->getHashPath() . rawurlencode( $this->getName() );
1574 }
1575
1584 function getArchiveThumbRel( $archiveName, $suffix = false ) {
1585 $path = $this->getArchiveRel( $archiveName );
1586 if ( $suffix !== false ) {
1587 $path .= '/' . $suffix;
1588 }
1589
1590 return $path;
1591 }
1592
1599 function getArchivePath( $suffix = false ) {
1600 $this->assertRepoDefined();
1601
1602 return $this->repo->getZonePath( 'public' ) . '/' . $this->getArchiveRel( $suffix );
1603 }
1604
1612 function getArchiveThumbPath( $archiveName, $suffix = false ) {
1613 $this->assertRepoDefined();
1614
1615 return $this->repo->getZonePath( 'thumb' ) . '/' .
1616 $this->getArchiveThumbRel( $archiveName, $suffix );
1617 }
1618
1625 function getThumbPath( $suffix = false ) {
1626 $this->assertRepoDefined();
1627
1628 return $this->repo->getZonePath( 'thumb' ) . '/' . $this->getThumbRel( $suffix );
1629 }
1630
1637 function getTranscodedPath( $suffix = false ) {
1638 $this->assertRepoDefined();
1639
1640 return $this->repo->getZonePath( 'transcoded' ) . '/' . $this->getThumbRel( $suffix );
1641 }
1642
1649 function getArchiveUrl( $suffix = false ) {
1650 $this->assertRepoDefined();
1651 $ext = $this->getExtension();
1652 $path = $this->repo->getZoneUrl( 'public', $ext ) . '/archive/' . $this->getHashPath();
1653 if ( $suffix === false ) {
1654 $path = rtrim( $path, '/' );
1655 } else {
1656 $path .= rawurlencode( $suffix );
1657 }
1658
1659 return $path;
1660 }
1661
1669 function getArchiveThumbUrl( $archiveName, $suffix = false ) {
1670 $this->assertRepoDefined();
1671 $ext = $this->getExtension();
1672 $path = $this->repo->getZoneUrl( 'thumb', $ext ) . '/archive/' .
1673 $this->getHashPath() . rawurlencode( $archiveName );
1674 if ( $suffix !== false ) {
1675 $path .= '/' . rawurlencode( $suffix );
1676 }
1677
1678 return $path;
1679 }
1680
1688 function getZoneUrl( $zone, $suffix = false ) {
1689 $this->assertRepoDefined();
1690 $ext = $this->getExtension();
1691 $path = $this->repo->getZoneUrl( $zone, $ext ) . '/' . $this->getUrlRel();
1692 if ( $suffix !== false ) {
1693 $path .= '/' . rawurlencode( $suffix );
1694 }
1695
1696 return $path;
1697 }
1698
1705 function getThumbUrl( $suffix = false ) {
1706 return $this->getZoneUrl( 'thumb', $suffix );
1707 }
1708
1715 function getTranscodedUrl( $suffix = false ) {
1716 return $this->getZoneUrl( 'transcoded', $suffix );
1717 }
1718
1725 function getVirtualUrl( $suffix = false ) {
1726 $this->assertRepoDefined();
1727 $path = $this->repo->getVirtualUrl() . '/public/' . $this->getUrlRel();
1728 if ( $suffix !== false ) {
1729 $path .= '/' . rawurlencode( $suffix );
1730 }
1731
1732 return $path;
1733 }
1734
1741 function getArchiveVirtualUrl( $suffix = false ) {
1742 $this->assertRepoDefined();
1743 $path = $this->repo->getVirtualUrl() . '/public/archive/' . $this->getHashPath();
1744 if ( $suffix === false ) {
1745 $path = rtrim( $path, '/' );
1746 } else {
1747 $path .= rawurlencode( $suffix );
1748 }
1749
1750 return $path;
1751 }
1752
1759 function getThumbVirtualUrl( $suffix = false ) {
1760 $this->assertRepoDefined();
1761 $path = $this->repo->getVirtualUrl() . '/thumb/' . $this->getUrlRel();
1762 if ( $suffix !== false ) {
1763 $path .= '/' . rawurlencode( $suffix );
1764 }
1765
1766 return $path;
1767 }
1768
1772 function isHashed() {
1773 $this->assertRepoDefined();
1774
1775 return (bool)$this->repo->getHashLevels();
1776 }
1777
1781 function readOnlyError() {
1782 throw new MWException( static::class . ': write operations are not supported' );
1783 }
1784
1800 function recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '',
1801 $watch = false, $timestamp = false, User $user = null
1802 ) {
1803 $this->readOnlyError();
1804 }
1805
1827 function publish( $src, $flags = 0, array $options = [] ) {
1828 $this->readOnlyError();
1829 }
1830
1835 function formatMetadata( $context = false ) {
1836 if ( !$this->getHandler() ) {
1837 return false;
1838 }
1839
1840 return $this->getHandler()->formatMetadata( $this, $context );
1841 }
1842
1848 function isLocal() {
1849 return $this->repo && $this->repo->isLocal();
1850 }
1851
1857 function getRepoName() {
1858 return $this->repo ? $this->repo->getName() : 'unknown';
1859 }
1860
1866 function getRepo() {
1867 return $this->repo;
1868 }
1869
1876 function isOld() {
1877 return false;
1878 }
1879
1887 function isDeleted( $field ) {
1888 return false;
1889 }
1890
1896 function getVisibility() {
1897 return 0;
1898 }
1899
1905 function wasDeleted() {
1906 $title = $this->getTitle();
1907
1908 return $title && $title->isDeletedQuick();
1909 }
1910
1923 function move( $target ) {
1924 $this->readOnlyError();
1925 }
1926
1942 function delete( $reason, $suppress = false, $user = null ) {
1943 $this->readOnlyError();
1944 }
1945
1960 function restore( $versions = [], $unsuppress = false ) {
1961 $this->readOnlyError();
1962 }
1963
1971 function isMultipage() {
1972 return $this->getHandler() && $this->handler->isMultiPage( $this );
1973 }
1974
1981 function pageCount() {
1982 if ( !isset( $this->pageCount ) ) {
1983 if ( $this->getHandler() && $this->handler->isMultiPage( $this ) ) {
1984 $this->pageCount = $this->handler->pageCount( $this );
1985 } else {
1986 $this->pageCount = false;
1987 }
1988 }
1989
1990 return $this->pageCount;
1991 }
1992
2002 static function scaleHeight( $srcWidth, $srcHeight, $dstWidth ) {
2003 // Exact integer multiply followed by division
2004 if ( $srcWidth == 0 ) {
2005 return 0;
2006 } else {
2007 return (int)round( $srcHeight * $dstWidth / $srcWidth );
2008 }
2009 }
2010
2021 function getImageSize( $filePath ) {
2022 if ( !$this->getHandler() ) {
2023 return false;
2024 }
2025
2026 return $this->getHandler()->getImageSize( $this, $filePath );
2027 }
2028
2036 if ( $this->repo ) {
2037 return $this->repo->getDescriptionUrl( $this->getName() );
2038 } else {
2039 return false;
2040 }
2041 }
2042
2049 function getDescriptionText( Language $lang = null ) {
2050 global $wgLang;
2051
2052 if ( !$this->repo || !$this->repo->fetchDescription ) {
2053 return false;
2054 }
2055
2056 $lang = $lang ?? $wgLang;
2057
2058 $renderUrl = $this->repo->getDescriptionRenderUrl( $this->getName(), $lang->getCode() );
2059 if ( $renderUrl ) {
2060 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
2061 $key = $this->repo->getLocalCacheKey(
2062 'RemoteFileDescription',
2063 $lang->getCode(),
2064 md5( $this->getName() )
2065 );
2066 $fname = __METHOD__;
2067
2068 return $cache->getWithSetCallback(
2069 $key,
2070 $this->repo->descriptionCacheExpiry ?: $cache::TTL_UNCACHEABLE,
2071 function ( $oldValue, &$ttl, array &$setOpts ) use ( $renderUrl, $fname ) {
2072 wfDebug( "Fetching shared description from $renderUrl\n" );
2073 $res = Http::get( $renderUrl, [], $fname );
2074 if ( !$res ) {
2075 $ttl = WANObjectCache::TTL_UNCACHEABLE;
2076 }
2077
2078 return $res;
2079 }
2080 );
2081 }
2082
2083 return false;
2084 }
2085
2098 function getDescription( $audience = self::FOR_PUBLIC, User $user = null ) {
2099 return null;
2100 }
2101
2107 function getTimestamp() {
2108 $this->assertRepoDefined();
2109
2110 return $this->repo->getFileTimestamp( $this->getPath() );
2111 }
2112
2120 public function getDescriptionTouched() {
2121 return false;
2122 }
2123
2129 function getSha1() {
2130 $this->assertRepoDefined();
2131
2132 return $this->repo->getFileSha1( $this->getPath() );
2133 }
2134
2140 function getStorageKey() {
2141 $hash = $this->getSha1();
2142 if ( !$hash ) {
2143 return false;
2144 }
2145 $ext = $this->getExtension();
2146 $dotExt = $ext === '' ? '' : ".$ext";
2147
2148 return $hash . $dotExt;
2149 }
2150
2159 function userCan( $field, User $user = null ) {
2160 return true;
2161 }
2162
2168 $handler = $this->getHandler();
2169 if ( $handler ) {
2170 $metadata = $this->getMetadata();
2171
2172 if ( is_string( $metadata ) ) {
2173 $metadata = Wikimedia\quietCall( 'unserialize', $metadata );
2174 }
2175
2176 if ( !is_array( $metadata ) ) {
2177 $metadata = [];
2178 }
2179
2180 return $handler->getContentHeaders( $metadata );
2181 }
2182
2183 return [];
2184 }
2185
2189 function getLongDesc() {
2190 $handler = $this->getHandler();
2191 if ( $handler ) {
2192 return $handler->getLongDesc( $this );
2193 } else {
2194 return MediaHandler::getGeneralLongDesc( $this );
2195 }
2196 }
2197
2201 function getShortDesc() {
2202 $handler = $this->getHandler();
2203 if ( $handler ) {
2204 return $handler->getShortDesc( $this );
2205 } else {
2206 return MediaHandler::getGeneralShortDesc( $this );
2207 }
2208 }
2209
2214 $handler = $this->getHandler();
2215 if ( $handler ) {
2216 return $handler->getDimensionsString( $this );
2217 } else {
2218 return '';
2219 }
2220 }
2221
2225 function getRedirected() {
2226 return $this->redirected;
2227 }
2228
2233 if ( $this->redirected ) {
2234 if ( !$this->redirectTitle ) {
2235 $this->redirectTitle = Title::makeTitle( NS_FILE, $this->redirected );
2236 }
2237
2238 return $this->redirectTitle;
2239 }
2240
2241 return null;
2242 }
2243
2248 function redirectedFrom( $from ) {
2249 $this->redirected = $from;
2250 }
2251
2255 function isMissing() {
2256 return false;
2257 }
2258
2263 public function isCacheable() {
2264 return true;
2265 }
2266
2271 protected function assertRepoDefined() {
2272 if ( !( $this->repo instanceof $this->repoClass ) ) {
2273 throw new MWException( "A {$this->repoClass} object is not set for this File.\n" );
2274 }
2275 }
2276
2281 protected function assertTitleDefined() {
2282 if ( !( $this->title instanceof Title ) ) {
2283 throw new MWException( "A Title object is not set for this File.\n" );
2284 }
2285 }
2286
2291 public function isExpensiveToThumbnail() {
2292 $handler = $this->getHandler();
2293 return $handler ? $handler->isExpensiveToThumbnail( $this ) : false;
2294 }
2295
2301 public function isTransformedLocally() {
2302 return true;
2303 }
2304}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
unserialize( $serialized)
$wgIgnoreImageErrors
If set, inline scaled images will still produce "<img>" tags ready for output instead of showing an e...
$wgThumbnailBuckets
When defined, is an array of image widths used as buckets for thumbnail generation.
$wgThumbnailMinimumBucketDistance
When using thumbnail buckets as defined above, this sets the minimum distance to the bucket above the...
$wgResourceBasePath
The default 'remoteBasePath' value for instances of ResourceLoaderFileModule.
$wgThumbnailEpoch
If rendered thumbnail files are older than this timestamp, they will be rerendered on demand as if th...
$wgTrustedMediaFormats
list of trusted media-types and MIME types.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfTempDir()
Tries to get the system directory for temporary files.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Definition Setup.php:123
$wgLang
Definition Setup.php:875
$IP
Definition WebStart.php:41
$starttime
Definition api.php:37
Class representing a non-directory file on the file system.
Definition FSFile.php:29
getPath()
Returns the file system path.
Definition FSFile.php:50
static extensionFromPath( $path, $case='lowercase')
Get the final extension from a storage or FS path.
static makeContentDisposition( $type, $filename='')
Build a Content-Disposition header value per RFC 6266.
Base class for file repositories.
Definition FileRepo.php:39
Implements some public methods and some protected utility functions which are required by multiple ch...
Definition File.php:52
getStorageKey()
Get the deletion archive key, "<sha1>.<ext>".
Definition File.php:2140
string $url
The URL corresponding to one of the four basic zones.
Definition File.php:118
getVisibility()
Return the deletion bitfield STUB.
Definition File.php:1896
isVectorized()
Return true if the file is vectorized.
Definition File.php:556
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:1800
restore( $versions=[], $unsuppress=false)
Restore all or specified deleted revisions to the given file.
Definition File.php:1960
isExpensiveToThumbnail()
True if creating thumbnails from the file is large or otherwise resource-intensive.
Definition File.php:2291
isLocal()
Returns true if the file comes from the local file repository.
Definition File.php:1848
getThumbRel( $suffix=false)
Get the path, relative to the thumbnail zone root, of the thumbnail directory or a particular file if...
Definition File.php:1557
getLastError()
Get last thumbnailing error.
Definition File.php:1414
getShortDesc()
Definition File.php:2201
generateAndSaveThumb( $tmpFile, $transformParams, $flags)
Generates a thumbnail according to the given parameters and saves it to storage.
Definition File.php:1133
MediaHandler $handler
Definition File.php:115
purgeDescription()
Purge the file description page, but don't go after pages using the file.
Definition File.php:1443
__construct( $title, $repo)
Call this constructor from child classes.
Definition File.php:167
getIsSafeFileUncached()
Uncached accessor.
Definition File.php:823
getArchivePath( $suffix=false)
Get the path of the archived file.
Definition File.php:1599
getBucketThumbName( $bucket)
Returns the name of the thumb for a given bucket.
Definition File.php:1335
FSFile bool $fsFile
False if undefined.
Definition File.php:112
const RENDER_NOW
Force rendering in the current process.
Definition File.php:60
getPath()
Return the storage path to the file.
Definition File.php:418
getThumbPath( $suffix=false)
Get the path of the thumbnail directory, or a particular file if $suffix is specified.
Definition File.php:1625
getThumbVirtualUrl( $suffix=false)
Get the virtual URL for a thumbnail file or directory.
Definition File.php:1759
getIsSafeFile()
Accessor for __get()
Definition File.php:814
redirectedFrom( $from)
Definition File.php:2248
getDescriptionTouched()
Returns the timestamp (in TS_MW format) of the last change of the description page.
Definition File.php:2120
transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags)
Return either a MediaTransformError or placeholder thumbnail (if $wgIgnoreImageErrors)
Definition File.php:1029
array $tmpBucketedThumbCache
Cache of tmp filepaths pointing to generated bucket thumbnails, keyed by width.
Definition File.php:155
getMimeType()
Returns the MIME type of the file.
Definition File.php:722
getSize()
Return the size of the image file, in bytes Overridden by LocalFile, UnregisteredLocalFile STUB.
Definition File.php:711
string $extension
File extension.
Definition File.php:121
pageCount()
Returns the number of pages of a multipage document, or false for documents which aren't multipage do...
Definition File.php:1981
getMediaType()
Return the type of the media in the file.
Definition File.php:733
string $redirected
Main part of the title, with underscores (Title::getDBkey)
Definition File.php:106
getTranscodedUrl( $suffix=false)
Get the URL of the transcoded directory, or a particular file if $suffix is specified.
Definition File.php:1715
bool $isSafeFile
Whether this media file is in a format that is unlikely to contain viruses or malicious content.
Definition File.php:149
getRel()
Get the path of the file relative to the public zone root.
Definition File.php:1528
getLength()
Get the duration of a media file in seconds.
Definition File.php:542
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:185
getTimestamp()
Get the 14-character timestamp of the file upload.
Definition File.php:2107
assertRepoDefined()
Assert that $this->repo is set to a valid FileRepo instance.
Definition File.php:2271
getName()
Return the name of this file.
Definition File.php:298
resetHistory()
Reset the history pointer to the first element of the history.
Definition File.php:1503
canAnimateThumbIfAppropriate()
Will the thumbnail be animated if one would expect it to be.
Definition File.php:630
getWidth( $page=1)
Return the width of the image.
Definition File.php:464
getLocalRefPath()
Get an FS copy or original of this file and return the path.
Definition File.php:434
exists()
Returns true if file exists in the repository.
Definition File.php:892
const DELETE_SOURCE
Definition File.php:67
getMatchedLanguage( $userPreferredLanguage)
Get the language code from the available languages for this file that matches the language requested ...
Definition File.php:592
getThumbUrl( $suffix=false)
Get the URL of the thumbnail directory, or a particular file if $suffix is specified.
Definition File.php:1705
Title $redirectedTitle
Definition File.php:109
allowInlineDisplay()
Alias for canRender()
Definition File.php:784
string false $pageCount
Number of pages of a multipage document, or false for documents which aren't multipage documents.
Definition File.php:135
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:775
getVirtualUrl( $suffix=false)
Get the public zone virtual URL for a current version source file.
Definition File.php:1725
isTrustedFile()
Returns true if the file is flagged as trusted.
Definition File.php:867
getHistory( $limit=null, $start=null, $end=null, $inc=true)
Return a fragment of the history of file.
Definition File.php:1480
isCacheable()
Check if this file object is small and can be cached.
Definition File.php:2263
getTransformScript()
Definition File.php:909
isMissing()
Definition File.php:2255
isVisible()
Returns true if file exists in the repository and can be included in a page.
Definition File.php:902
iconThumb()
Get a ThumbnailImage representing a file type icon.
Definition File.php:1392
getRepo()
Returns the repository.
Definition File.php:1866
getZoneUrl( $zone, $suffix=false)
Get the URL of the zone directory, or a particular file if $suffix is specified.
Definition File.php:1688
getDimensionsString()
Definition File.php:2213
const DELETED_COMMENT
Definition File.php:55
upgradeRow()
Upgrade the database row if there is one Called by ImagePage STUB.
Definition File.php:264
convertMetadataVersion( $metadata, $version)
get versioned metadata
Definition File.php:682
const FOR_PUBLIC
Definition File.php:70
getCanRender()
Accessor for __get()
Definition File.php:761
getDescriptionText(Language $lang=null)
Get the HTML text of the description page, if available.
Definition File.php:2049
getArchiveVirtualUrl( $suffix=false)
Get the public zone virtual URL for an archived version source file.
Definition File.php:1741
assertTitleDefined()
Assert that $this->title is set to a Title.
Definition File.php:2281
getArchiveThumbPath( $archiveName, $suffix=false)
Get the path of an archived file's thumbs, or a particular thumb if $suffix is specified.
Definition File.php:1612
getHeight( $page=1)
Return the height of the image.
Definition File.php:478
getThumbnailSource( $params)
Returns the most appropriate source image for the thumbnail, given a target thumbnail size.
Definition File.php:1257
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:1584
getUser( $type='text')
Returns ID or name of user who uploaded the file STUB.
Definition File.php:533
makeTransformTmpFile( $thumbPath)
Creates a temp FS file with the same extension and the thumbnail.
Definition File.php:1344
getBitDepth()
Return the bit depth of the file Overridden by LocalFile STUB.
Definition File.php:701
publish( $src, $flags=0, array $options=[])
Move or copy a file to its public location.
Definition File.php:1827
isOld()
Returns true if the image is an old version STUB.
Definition File.php:1876
getContentHeaders()
Definition File.php:2167
getTitle()
Return the associated title object.
Definition File.php:327
getDescriptionShortUrl()
Get short description URL for a files based on the page ID.
Definition File.php:365
const DELETED_RESTRICTED
Definition File.php:57
canRender()
Checks if the output of transform() for this file is likely to be valid.
Definition File.php:749
getAvailableLanguages()
Gives a (possibly empty) list of languages to render the file in.
Definition File.php:576
getCommonMetaArray()
Like getMetadata but returns a handler independent array of common values.
Definition File.php:664
getOriginalTitle()
Return the title used to find this file.
Definition File.php:336
getRepoName()
Returns the name of the repository.
Definition File.php:1857
getDefaultRenderLanguage()
In files that support multiple language, what is the default language to use if none specified.
Definition File.php:611
readOnlyError()
Definition File.php:1781
migrateThumbFile( $thumbName)
Hook into transform() to allow migration of thumbnail files STUB Overridden by LocalFile.
Definition File.php:1370
static compare(File $a, File $b)
Callback for usort() to do file sorts by name.
Definition File.php:289
getCanonicalUrl()
Definition File.php:383
isMultipage()
Returns 'true' if this file is a type which supports multiple pages, e.g.
Definition File.php:1971
isSafeFile()
Determines if this media file is in a format that is unlikely to contain viruses or malicious content...
Definition File.php:801
getThumbnails()
Get all thumbnail names previously generated for this file STUB Overridden by LocalFile.
Definition File.php:1424
createThumb( $width, $height=-1)
Create a thumbnail of the image having the specified width/height.
Definition File.php:1007
string $name
The name of a file from its title object.
Definition File.php:124
const RAW
Definition File.php:72
getTranscodedPath( $suffix=false)
Get the path of the transcoded directory, or a particular file if $suffix is specified.
Definition File.php:1637
load( $flags=0)
Load any lazy-loaded file object fields from source.
Definition File.php:882
getExtension()
Get the file extension, e.g.
Definition File.php:312
isHashed()
Definition File.php:1772
FileRepo LocalRepo ForeignAPIRepo bool $repo
Some member variables can be lazy-initialised using __get().
Definition File.php:97
transform( $params, $flags=0)
Transform a media file.
Definition File.php:1049
getImageSize( $filePath)
Get an image size array like that returned by getImageSize(), or false if it can't be determined.
Definition File.php:2021
nextHistoryLine()
Return the history of this file, line by line.
Definition File.php:1493
purgeEverything()
Purge metadata and all affected pages when the file is created, deleted, or majorly updated.
Definition File.php:1455
const DELETED_FILE
Definition File.php:54
getRedirected()
Definition File.php:2225
string $path
The storage path corresponding to one of the zones.
Definition File.php:127
static normalizeExtension( $extension)
Normalize a file extension to the common form, making it lowercase and checking some synonyms,...
Definition File.php:225
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:274
getUrl()
Return the URL of the file.
Definition File.php:349
Title string bool $title
Definition File.php:100
wasDeleted()
Was this file ever deleted from the wiki?
Definition File.php:1905
string $transformScript
URL of transformscript (for example thumb.php)
Definition File.php:138
string $repoClass
Required Repository class type.
Definition File.php:152
thumbName( $params, $flags=0)
Return the file name of a thumbnail with the specified parameters.
Definition File.php:953
const DELETED_USER
Definition File.php:56
getArchiveUrl( $suffix=false)
Get the URL of the archive directory, or a particular file if $suffix is specified.
Definition File.php:1649
getSha1()
Get the SHA-1 base 36 hash of the file.
Definition File.php:2129
getViewURL()
Definition File.php:390
formatMetadata( $context=false)
Definition File.php:1835
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:2159
const THUMB_FULL_NAME
Definition File.php:75
Title $redirectTitle
Definition File.php:141
isTransformedLocally()
Whether the thumbnails created on the same server as this code is running.
Definition File.php:2301
getLongDesc()
Definition File.php:2189
getHandler()
Get a MediaHandler instance for this file.
Definition File.php:1379
getDescriptionUrl()
Get the URL of the image description page.
Definition File.php:2035
string $hashPath
Relative path including trailing slash.
Definition File.php:130
getBucketThumbPath( $bucket)
Returns the repo path of the thumb for a given bucket.
Definition File.php:1325
purgeCache( $options=[])
Purge shared caches such as thumbnails and DB data caching STUB Overridden by LocalFile.
Definition File.php:1435
getThumbnailBucket( $desiredWidth, $page=1)
Return the smallest bucket from $wgThumbnailBuckets which is at least $wgThumbnailMinimumBucketDistan...
Definition File.php:491
getUnscaledThumb( $handlerParams=[])
Get a ThumbnailImage which is the same size as the source.
Definition File.php:930
getArchiveRel( $suffix=false)
Get the path of an archived file relative to the public zone root.
Definition File.php:1539
getUrlRel()
Get urlencoded path of the file relative to the public zone root.
Definition File.php:1572
getThumbDisposition( $thumbName, $dispositionType='inline')
Definition File.php:1354
const FOR_THIS_USER
Definition File.php:71
move( $target)
Move file to the new title.
Definition File.php:1923
generateBucketsIfNeeded( $params, $flags=0)
Generates chained bucketed thumbnails if needed.
Definition File.php:1200
getRedirectedTitle()
Definition File.php:2232
__get( $name)
Definition File.php:206
static scaleHeight( $srcWidth, $srcHeight, $dstWidth)
Calculate the height of a thumbnail using the source and destination width.
Definition File.php:2002
isDeleted( $field)
Is this file a "deleted" file in a private archive? STUB.
Definition File.php:1887
getArchiveThumbUrl( $archiveName, $suffix=false)
Get the URL of the archived file's thumbs, or a particular thumb if $suffix is specified.
Definition File.php:1669
getDescription( $audience=self::FOR_PUBLIC, User $user=null)
Get description of file revision STUB.
Definition File.php:2098
getMetadata()
Get handler-specific metadata Overridden by LocalFile, UnregisteredLocalFile STUB.
Definition File.php:654
generateThumbName( $name, $params)
Generate a thumbnail file name from a name and specified parameters.
Definition File.php:968
bool $canRender
Whether the output of transform() for this file is likely to be valid.
Definition File.php:144
getFullUrl()
Return a fully-qualified URL to the file.
Definition File.php:376
const RENDER_FORCE
Force rendering even if thumbnail already exist and using RENDER_NOW I.e.
Definition File.php:65
static checkExtensionCompatibility(File $old, $new)
Checks if file extensions are compatible.
Definition File.php:250
getHashPath()
Get the filename hash component of the directory including trailing slash, e.g.
Definition File.php:1513
string $lastError
Text of last error.
Definition File.php:103
A foreign repository with a remote MediaWiki with an API thingy.
Class to invalidate the HTML cache of all the pages linking to a given title.
static get( $url, array $options=[], $caller=__METHOD__)
Simple wrapper for Http::request( 'GET' )
Definition Http.php:98
Internationalisation code.
Definition Language.php:36
A repository that stores files in the local filesystem and registers them in the wiki's own database.
Definition LocalRepo.php:36
MediaWiki exception.
Base media handler class.
normaliseParams( $image, &$params)
Changes the parameter array as necessary, ready for transformation.
canAnimateThumbnail( $file)
If the material is animated, we can animate the thumbnail.
supportsBucketing()
Returns whether or not this handler supports the chained generation of thumbnails according to bucket...
static getGeneralLongDesc( $file)
Used instead of getLongDesc if there is no handler registered for file.
getDefaultRenderLanguage(File $file)
On file types that support renderings in multiple languages, which language is used by default if uns...
getLength( $file)
If its an audio file, return the length of the file.
getTransform( $image, $dstPath, $dstUrl, $params)
Get a MediaTransformOutput object representing the transformed output.
getDimensionsString( $file)
Shown in file history box on image description page.
static getHandler( $type)
Get a MediaHandler for a given MIME type from the instance cache.
getCommonMetaArray(File $file)
Get an array of standard (FormatMetadata type) metadata values.
doTransform( $image, $dstPath, $dstUrl, $params, $flags=0)
Get a MediaTransformOutput object representing the transformed output.
isAnimatedImage( $file)
The material is an image, and is animated.
isVectorized( $file)
The material is vectorized and thus scaling is lossless.
convertMetadataVersion( $metadata, $version=1)
Convert metadata version.
static getGeneralShortDesc( $file)
Used instead of getShortDesc if there is no handler registered for file.
getLongDesc( $file)
Long description.
getScriptedTransform( $image, $script, $params)
Get a MediaTransformOutput object representing an alternate of the transformed output which will call...
isExpensiveToThumbnail( $file)
True if creating thumbnails from the file is large or otherwise resource-intensive.
getAvailableLanguages(File $file)
Get list of languages file can be viewed in.
getShortDesc( $file)
Short description.
getContentHeaders( $metadata)
Get useful response headers for GET/HEAD requests for a file with the given metadata.
getMatchedLanguage( $userPreferredLanguage, array $availableLanguages)
When overridden in a descendant class, returns a language code most suiting.
Basic media transform error class.
MediaWikiServices is the service locator for the application scope of MediaWiki.
Convenience class for dealing with PoolCounters using callbacks.
execute( $skipcache=false)
Get the result of the work (whatever it is), or the result of the error() function.
static factory( $prefix, $extension='', $tmpDirectory=null)
Make a new temporary file on the file system.
Media transform output for images.
Represents a title within MediaWiki.
Definition Title.php:40
purgeSquid()
Purge all applicable CDN URLs.
Definition Title.php:3362
isDeletedQuick()
Is there a version of this page in the deletion archive?
Definition Title.php:2928
invalidateCache( $purgeTime=null)
Updates page_touched for this page; called from LinksUpdate.php.
Definition Title.php:4202
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:48
$res
Definition database.txt:21
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
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
const PROTO_CANONICAL
Definition Defines.php:232
const NS_FILE
Definition Defines.php:79
const NS_MEDIA
Definition Defines.php:61
const PROTO_RELATIVE
Definition Defines.php:230
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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:921
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action, or null $user:User who performed the tagging when the tagging is subsequent to the action, or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, 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. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy:boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'ContentSecurityPolicyDefaultSource':Modify the allowed CSP load sources. This affects all directives except for the script directive. If you want to add a script source, see ContentSecurityPolicyScriptSource hook. & $defaultSrc:Array of Content-Security-Policy allowed sources $policyConfig:Current configuration for the Content-Security-Policy header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyDirectives':Modify the content security policy directives. Use this only if ContentSecurityPolicyDefaultSource and ContentSecurityPolicyScriptSource do not meet your needs. & $directives:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyScriptSource':Modify the allowed CSP script sources. Note that you also have to use ContentSecurityPolicyDefaultSource if you want non-script sources to be loaded from whatever you add. & $scriptSrc:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DeleteUnknownPreferences':Called by the cleanupPreferences.php maintenance script to build a WHERE clause with which to delete preferences that are not known about. This hook is used by extensions that have dynamically-named preferences that should not be deleted in the usual cleanup process. For example, the Gadgets extension creates preferences prefixed with 'gadget-', and so anything with that prefix is excluded from the deletion. &where:An array that will be passed as the $cond parameter to IDatabase::select() to determine what will be deleted from the user_properties table. $db:The IDatabase object, useful for accessing $db->buildLike() etc. 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
Definition hooks.txt:1266
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 & $options
Definition hooks.txt:1999
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition hooks.txt:2848
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition hooks.txt:783
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:2003
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 use $formDescriptor instead 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;div ...>$1&lt;/div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response 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:2312
and how to run hooks for an and one after Each event has a name
Definition hooks.txt:12
return true to allow those checks to and false if checking is done & $user
Definition hooks.txt:1510
see documentation in includes Linker php for Linker::makeImageLink & $handlerParams
Definition hooks.txt:1800
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:37
Interface for database access objects.
$cache
Definition mcc.php:33
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
const MEDIATYPE_UNKNOWN
Definition defines.php:26
$source
title
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 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:30
if(!is_readable( $file)) $ext
Definition router.php:48
$params
if(!isset( $args[0])) $lang