50 $this->mExists = $exists;
61 $data =
$repo->fetchImageQuery( [
63 'iiprop' => self::getProps(),
64 'prop' =>
'imageinfo',
68 'iiextmetadatamultilang' => 1,
71 $info =
$repo->getImageInfo( $data );
74 $lastRedirect = isset( $data[
'query'][
'redirects'] )
75 ? count( $data[
'query'][
'redirects'] ) - 1
77 if ( $lastRedirect >= 0 ) {
78 $newtitle = Title::newFromText( $data[
'query'][
'redirects'][$lastRedirect][
'to'] );
79 $img =
new self( $newtitle,
$repo, $info,
true );
98 return 'timestamp|user|comment|url|size|sha1|metadata|mime|mediatype|extmetadata';
125 return parent::transform(
$params, $flags );
131 $width =
$params[
'width'] ?? -1;
132 $height =
$params[
'height'] ?? -1;
134 $thumbUrl = $this->repo->getThumbUrlFromCache(
140 if ( $thumbUrl ===
false ) {
143 return $this->repo->getThumbError(
152 return $this->
handler->getTransform( $this,
'bogus', $thumbUrl,
$params );
162 return isset( $this->mInfo[
'width'] ) ? intval( $this->mInfo[
'width'] ) : 0;
170 return isset( $this->mInfo[
'height'] ) ? intval( $this->mInfo[
'height'] ) : 0;
177 if ( isset( $this->mInfo[
'metadata'] ) ) {
178 return serialize( self::parseMetadata( $this->mInfo[
'metadata'] ) );
189 if ( isset( $this->mInfo[
'extmetadata'] ) ) {
190 return $this->mInfo[
'extmetadata'];
201 if ( !is_array( $metadata ) ) {
205 foreach ( $metadata
as $meta ) {
216 return isset( $this->mInfo[
'size'] ) ? intval( $this->mInfo[
'size'] ) :
null;
223 return isset( $this->mInfo[
'url'] ) ? strval( $this->mInfo[
'url'] ) :
null;
234 if ( isset( $this->mInfo[
'descriptionshorturl'] ) ) {
235 return $this->mInfo[
'descriptionshorturl'];
236 } elseif ( isset( $this->mInfo[
'pageid'] ) ) {
237 $url = $this->repo->makeUrl( [
'curid' => $this->mInfo[
'pageid'] ] );
238 if (
$url !==
false ) {
250 if (
$type ==
'text' ) {
251 return isset( $this->mInfo[
'user'] ) ? strval( $this->mInfo[
'user'] ) :
null;
263 return isset( $this->mInfo[
'comment'] ) ? strval( $this->mInfo[
'comment'] ) :
null;
270 return isset( $this->mInfo[
'sha1'] )
271 ? Wikimedia\base_convert( strval( $this->mInfo[
'sha1'] ), 16, 36, 31 )
280 isset( $this->mInfo[
'timestamp'] )
281 ? strval( $this->mInfo[
'timestamp'] )
290 if ( !isset( $this->mInfo[
'mime'] ) ) {
291 $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
292 $this->mInfo[
'mime'] = $magic->guessTypesForExtension( $this->
getExtension() );
295 return $this->mInfo[
'mime'];
302 if ( isset( $this->mInfo[
'mediatype'] ) ) {
303 return $this->mInfo[
'mediatype'];
305 $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
307 return $magic->getMediaType(
null, $this->
getMimeType() );
314 return $this->mInfo[
'descriptionurl'] ??
false;
323 if ( $this->repo->canCacheThumbs() ) {
340 $iter = $this->repo->getBackend()->getFileList( [
'dir' => $dir ] );
344 foreach ( $iter
as $file ) {
358 $services = MediaWikiServices::getInstance();
359 $url = $this->repo->getDescriptionRenderUrl(
361 $key = $this->repo->getLocalCacheKey(
'RemoteFileDescription',
'url', md5(
$url ) );
363 $services->getMainWANObjectCache()->delete( $key );
370 $key = $this->repo->getLocalCacheKey(
'ForeignAPIRepo',
'ThumbUrl', $this->
getName() );
371 MediaWikiServices::getInstance()->getMainWANObjectCache()->delete( $key );
382 foreach ( $files
as $file ) {
383 $purgeList[] =
"{$dir}{$file}";
386 # Delete the thumbnails
387 $this->repo->quickPurgeBatch( $purgeList );
388 # Clear out the thumbnail directory if empty
389 $this->repo->quickCleanDir( $dir );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Implements some public methods and some protected utility functions which are required by multiple ch...
string $url
The URL corresponding to one of the four basic zones.
assertRepoDefined()
Assert that $this->repo is set to a valid FileRepo instance.
getName()
Return the name of this file.
canRender()
Checks if the output of transform() for this file is likely to be valid.
getExtension()
Get the file extension, e.g.
FileRepo LocalRepo ForeignAPIRepo bool $repo
Some member variables can be lazy-initialised using __get().
string $path
The storage path corresponding to one of the zones.
getHandler()
Get a MediaHandler instance for this file.
getHashPath()
Get the filename hash component of the directory including trailing slash, e.g.
Foreign file accessible through api.php requests.
getThumbPath( $suffix='')
Only useful if we're locally caching thumbs anyway...
__construct( $title, $repo, $info, $exists=false)
purgeCache( $options=[])
Purge shared caches such as thumbnails and DB data caching STUB Overridden by LocalFile.
isTransformedLocally()
The thumbnail is created on the foreign server and fetched over internet.
static parseMetadata( $metadata)
static newFromTitle(Title $title, $repo)
purgeThumbnails( $options=[])
getDescription( $audience=self::FOR_PUBLIC, User $user=null)
transform( $params, $flags=0)
getDescriptionShortUrl()
Get short description URL for a file based on the foreign API response, or if unavailable,...
static getProps()
Get the property string for iiprop and aiprop.
Represents a title within MediaWiki.
getDBkey()
Get the main part with underscores.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
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
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
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
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 just before the function returns a value If you return true
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 $services
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
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
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))