MediaWiki  1.23.12
ForeignAPIRepo.php
Go to the documentation of this file.
1 <?php
25 
41 class ForeignAPIRepo extends FileRepo {
42  /* This version string is used in the user agent for requests and will help
43  * server maintainers in identify ForeignAPI usage.
44  * Update the version every time you make breaking or significant changes. */
45  const VERSION = "2.1";
46 
51  protected static $imageInfoProps = array(
52  'url',
53  'thumbnail',
54  'timestamp',
55  );
56 
57  protected $fileFactory = array( 'ForeignAPIFile', 'newFromTitle' );
59  protected $apiThumbCacheExpiry = 86400;
60 
62  protected $fileCacheExpiry = 2592000;
63 
65  protected $mFileExists = array();
66 
68  private $mQueryCache = array();
69 
73  function __construct( $info ) {
74  global $wgLocalFileRepo;
75  parent::__construct( $info );
76 
77  // http://commons.wikimedia.org/w/api.php
78  $this->mApiBase = isset( $info['apibase'] ) ? $info['apibase'] : null;
79 
80  if ( isset( $info['apiThumbCacheExpiry'] ) ) {
81  $this->apiThumbCacheExpiry = $info['apiThumbCacheExpiry'];
82  }
83  if ( isset( $info['fileCacheExpiry'] ) ) {
84  $this->fileCacheExpiry = $info['fileCacheExpiry'];
85  }
86  if ( !$this->scriptDirUrl ) {
87  // hack for description fetches
88  $this->scriptDirUrl = dirname( $this->mApiBase );
89  }
90  // If we can cache thumbs we can guess sane defaults for these
91  if ( $this->canCacheThumbs() && !$this->url ) {
92  $this->url = $wgLocalFileRepo['url'];
93  }
94  if ( $this->canCacheThumbs() && !$this->thumbUrl ) {
95  $this->thumbUrl = $this->url . '/thumb';
96  }
97  }
98 
103  function getApiUrl() {
104  return $this->mApiBase;
105  }
106 
115  function newFile( $title, $time = false ) {
116  if ( $time ) {
117  return false;
118  }
119 
120  return parent::newFile( $title, $time );
121  }
122 
127  function fileExistsBatch( array $files ) {
128  $results = array();
129  foreach ( $files as $k => $f ) {
130  if ( isset( $this->mFileExists[$f] ) ) {
131  $results[$k] = $this->mFileExists[$f];
132  unset( $files[$k] );
133  } elseif ( self::isVirtualUrl( $f ) ) {
134  # @todo FIXME: We need to be able to handle virtual
135  # URLs better, at least when we know they refer to the
136  # same repo.
137  $results[$k] = false;
138  unset( $files[$k] );
139  } elseif ( FileBackend::isStoragePath( $f ) ) {
140  $results[$k] = false;
141  unset( $files[$k] );
142  wfWarn( "Got mwstore:// path '$f'." );
143  }
144  }
145 
146  $data = $this->fetchImageQuery( array(
147  'titles' => implode( $files, '|' ),
148  'prop' => 'imageinfo' )
149  );
150 
151  if ( isset( $data['query']['pages'] ) ) {
152  # First, get results from the query. Note we only care whether the image exists,
153  # not whether it has a description page.
154  foreach ( $data['query']['pages'] as $p ) {
155  $this->mFileExists[$p['title']] = ( $p['imagerepository'] !== '' );
156  }
157  # Second, copy the results to any redirects that were queried
158  if ( isset( $data['query']['redirects'] ) ) {
159  foreach ( $data['query']['redirects'] as $r ) {
160  $this->mFileExists[$r['from']] = $this->mFileExists[$r['to']];
161  }
162  }
163  # Third, copy the results to any non-normalized titles that were queried
164  if ( isset( $data['query']['normalized'] ) ) {
165  foreach ( $data['query']['normalized'] as $n ) {
166  $this->mFileExists[$n['from']] = $this->mFileExists[$n['to']];
167  }
168  }
169  # Finally, copy the results to the output
170  foreach ( $files as $key => $file ) {
171  $results[$key] = $this->mFileExists[$file];
172  }
173  }
174 
175  return $results;
176  }
177 
182  function getFileProps( $virtualUrl ) {
183  return false;
184  }
185 
190  function fetchImageQuery( $query ) {
191  global $wgLanguageCode;
192 
193  $query = array_merge( $query,
194  array(
195  'format' => 'json',
196  'action' => 'query',
197  'redirects' => 'true'
198  ) );
199 
200  if ( !isset( $query['uselang'] ) ) { // uselang is unset or null
201  $query['uselang'] = $wgLanguageCode;
202  }
203 
204  $data = $this->httpGetCached( 'Metadata', $query );
205 
206  if ( $data ) {
207  return FormatJson::decode( $data, true );
208  } else {
209  return null;
210  }
211  }
212 
217  function getImageInfo( $data ) {
218  if ( $data && isset( $data['query']['pages'] ) ) {
219  foreach ( $data['query']['pages'] as $info ) {
220  if ( isset( $info['imageinfo'][0] ) ) {
221  return $info['imageinfo'][0];
222  }
223  }
224  }
225 
226  return false;
227  }
228 
233  function findBySha1( $hash ) {
234  $results = $this->fetchImageQuery( array(
235  'aisha1base36' => $hash,
236  'aiprop' => ForeignAPIFile::getProps(),
237  'list' => 'allimages',
238  ) );
239  $ret = array();
240  if ( isset( $results['query']['allimages'] ) ) {
241  foreach ( $results['query']['allimages'] as $img ) {
242  // 1.14 was broken, doesn't return name attribute
243  if ( !isset( $img['name'] ) ) {
244  continue;
245  }
246  $ret[] = new ForeignAPIFile( Title::makeTitle( NS_FILE, $img['name'] ), $this, $img );
247  }
248  }
249 
250  return $ret;
251  }
252 
262  function getThumbUrl( $name, $width = -1, $height = -1, &$result = null, $otherParams = '' ) {
263  $data = $this->fetchImageQuery( array(
264  'titles' => 'File:' . $name,
265  'iiprop' => self::getIIProps(),
266  'iiurlwidth' => $width,
267  'iiurlheight' => $height,
268  'iiurlparam' => $otherParams,
269  'prop' => 'imageinfo' ) );
270  $info = $this->getImageInfo( $data );
271 
272  if ( $data && $info && isset( $info['thumburl'] ) ) {
273  wfDebug( __METHOD__ . " got remote thumb " . $info['thumburl'] . "\n" );
274  $result = $info;
275 
276  return $info['thumburl'];
277  } else {
278  return false;
279  }
280  }
281 
291  function getThumbError( $name, $width = -1, $height = -1, $otherParams = '', $lang = null ) {
292  $data = $this->fetchImageQuery( array(
293  'titles' => 'File:' . $name,
294  'iiprop' => self::getIIProps(),
295  'iiurlwidth' => $width,
296  'iiurlheight' => $height,
297  'iiurlparam' => $otherParams,
298  'prop' => 'imageinfo',
299  'uselang' => $lang,
300  ) );
301  $info = $this->getImageInfo( $data );
302 
303  if ( $data && $info && isset( $info['thumberror'] ) ) {
304  wfDebug( __METHOD__ . " got remote thumb error " . $info['thumberror'] . "\n" );
305 
306  return new MediaTransformError(
307  'thumbnail_error_remote',
308  $width,
309  $height,
310  $this->getDisplayName(),
311  $info['thumberror'] // already parsed message from foreign repo
312  );
313  } else {
314  return false;
315  }
316  }
317 
331  function getThumbUrlFromCache( $name, $width, $height, $params = "" ) {
332  global $wgMemc;
333  // We can't check the local cache using FileRepo functions because
334  // we override fileExistsBatch(). We have to use the FileBackend directly.
335  $backend = $this->getBackend(); // convenience
336 
337  if ( !$this->canCacheThumbs() ) {
338  $result = null; // can't pass "null" by reference, but it's ok as default value
339  return $this->getThumbUrl( $name, $width, $height, $result, $params );
340  }
341  $key = $this->getLocalCacheKey( 'ForeignAPIRepo', 'ThumbUrl', $name );
342  $sizekey = "$width:$height:$params";
343 
344  /* Get the array of urls that we already know */
345  $knownThumbUrls = $wgMemc->get( $key );
346  if ( !$knownThumbUrls ) {
347  /* No knownThumbUrls for this file */
348  $knownThumbUrls = array();
349  } else {
350  if ( isset( $knownThumbUrls[$sizekey] ) ) {
351  wfDebug( __METHOD__ . ': Got thumburl from local cache: ' .
352  "{$knownThumbUrls[$sizekey]} \n" );
353 
354  return $knownThumbUrls[$sizekey];
355  }
356  /* This size is not yet known */
357  }
358 
359  $metadata = null;
360  $foreignUrl = $this->getThumbUrl( $name, $width, $height, $metadata, $params );
361 
362  if ( !$foreignUrl ) {
363  wfDebug( __METHOD__ . " Could not find thumburl\n" );
364 
365  return false;
366  }
367 
368  // We need the same filename as the remote one :)
369  $fileName = rawurldecode( pathinfo( $foreignUrl, PATHINFO_BASENAME ) );
370  if ( !$this->validateFilename( $fileName ) ) {
371  wfDebug( __METHOD__ . " The deduced filename $fileName is not safe\n" );
372 
373  return false;
374  }
375  $localPath = $this->getZonePath( 'thumb' ) . "/" . $this->getHashPath( $name ) . $name;
376  $localFilename = $localPath . "/" . $fileName;
377  $localUrl = $this->getZoneUrl( 'thumb' ) . "/" . $this->getHashPath( $name ) .
378  rawurlencode( $name ) . "/" . rawurlencode( $fileName );
379 
380  if ( $backend->fileExists( array( 'src' => $localFilename ) )
381  && isset( $metadata['timestamp'] )
382  ) {
383  wfDebug( __METHOD__ . " Thumbnail was already downloaded before\n" );
384  $modified = $backend->getFileTimestamp( array( 'src' => $localFilename ) );
385  $remoteModified = strtotime( $metadata['timestamp'] );
386  $current = time();
387  $diff = abs( $modified - $current );
388  if ( $remoteModified < $modified && $diff < $this->fileCacheExpiry ) {
389  /* Use our current and already downloaded thumbnail */
390  $knownThumbUrls[$sizekey] = $localUrl;
391  $wgMemc->set( $key, $knownThumbUrls, $this->apiThumbCacheExpiry );
392 
393  return $localUrl;
394  }
395  /* There is a new Commons file, or existing thumbnail older than a month */
396  }
397  $thumb = self::httpGet( $foreignUrl );
398  if ( !$thumb ) {
399  wfDebug( __METHOD__ . " Could not download thumb\n" );
400 
401  return false;
402  }
403 
404  # @todo FIXME: Delete old thumbs that aren't being used. Maintenance script?
405  $backend->prepare( array( 'dir' => dirname( $localFilename ) ) );
406  $params = array( 'dst' => $localFilename, 'content' => $thumb );
407  if ( !$backend->quickCreate( $params )->isOK() ) {
408  wfDebug( __METHOD__ . " could not write to thumb path '$localFilename'\n" );
409 
410  return $foreignUrl;
411  }
412  $knownThumbUrls[$sizekey] = $localUrl;
413  $wgMemc->set( $key, $knownThumbUrls, $this->apiThumbCacheExpiry );
414  wfDebug( __METHOD__ . " got local thumb $localUrl, saving to cache \n" );
415 
416  return $localUrl;
417  }
418 
425  function getZoneUrl( $zone, $ext = null ) {
426  switch ( $zone ) {
427  case 'public':
428  return $this->url;
429  case 'thumb':
430  return $this->thumbUrl;
431  default:
432  return parent::getZoneUrl( $zone, $ext );
433  }
434  }
435 
441  function getZonePath( $zone ) {
442  $supported = array( 'public', 'thumb' );
443  if ( in_array( $zone, $supported ) ) {
444  return parent::getZonePath( $zone );
445  }
446 
447  return false;
448  }
449 
454  public function canCacheThumbs() {
455  return ( $this->apiThumbCacheExpiry > 0 );
456  }
457 
462  public static function getUserAgent() {
463  return Http::userAgent() . " ForeignAPIRepo/" . self::VERSION;
464  }
465 
472  function getInfo() {
473  $info = parent::getInfo();
474  $info['apiurl'] = $this->getApiUrl();
475 
476  $query = array(
477  'format' => 'json',
478  'action' => 'query',
479  'meta' => 'siteinfo',
480  'siprop' => 'general',
481  );
482 
483  $data = $this->httpGetCached( 'SiteInfo', $query, 7200 );
484 
485  if ( $data ) {
486  $siteInfo = FormatJson::decode( $data, true );
487  $general = $siteInfo['query']['general'];
488 
489  $info['articlepath'] = $general['articlepath'];
490  $info['server'] = $general['server'];
491 
492  if ( isset( $general['favicon'] ) ) {
493  $info['favicon'] = $general['favicon'];
494  }
495  }
496 
497  return $info;
498  }
499 
508  public static function httpGet( $url, $timeout = 'default', $options = array() ) {
509  $options['timeout'] = $timeout;
510  /* Http::get */
512  wfDebug( "ForeignAPIRepo: HTTP GET: $url\n" );
513  $options['method'] = "GET";
514 
515  if ( !isset( $options['timeout'] ) ) {
516  $options['timeout'] = 'default';
517  }
518 
520  $req->setUserAgent( ForeignAPIRepo::getUserAgent() );
521  $status = $req->execute();
522 
523  if ( $status->isOK() ) {
524  return $req->getContent();
525  } else {
526  $logger = LoggerFactory::getInstance( 'http' );
527  $logger->warning( $status->getWikiText(), array( 'caller' => 'ForeignAPIRepo::httpGet' ) );
528  return false;
529  }
530  }
531 
536  protected static function getIIProps() {
537  return join( '|', self::$imageInfoProps );
538  }
539 
547  public function httpGetCached( $target, $query, $cacheTTL = 3600 ) {
548  if ( $this->mApiBase ) {
549  $url = wfAppendQuery( $this->mApiBase, $query );
550  } else {
551  $url = $this->makeUrl( $query, 'api' );
552  }
553 
554  if ( !isset( $this->mQueryCache[$url] ) ) {
555  global $wgMemc;
556 
557  $key = $this->getLocalCacheKey( get_class( $this ), $target, md5( $url ) );
558  $data = $wgMemc->get( $key );
559 
560  if ( !$data ) {
561  $data = self::httpGet( $url );
562 
563  if ( !$data ) {
564  return null;
565  }
566 
567  $wgMemc->set( $key, $data, $cacheTTL );
568  }
569 
570  if ( count( $this->mQueryCache ) > 100 ) {
571  // Keep the cache from growing infinitely
572  $this->mQueryCache = array();
573  }
574 
575  $this->mQueryCache[$url] = $data;
576  }
577 
578  return $this->mQueryCache[$url];
579  }
580 
585  function enumFiles( $callback ) {
586  throw new MWException( 'enumFiles is not supported by ' . get_class( $this ) );
587  }
588 
592  protected function assertWritableRepo() {
593  throw new MWException( get_class( $this ) . ': write operations are not supported.' );
594  }
595 }
ForeignAPIRepo\getApiUrl
getApiUrl()
Definition: ForeignAPIRepo.php:99
ForeignAPIRepo\findBySha1
findBySha1( $hash)
Definition: ForeignAPIRepo.php:229
Title\makeTitle
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:398
MediaTransformError
Basic media transform error class.
Definition: MediaTransformOutput.php:409
ForeignAPIRepo\$apiThumbCacheExpiry
int $apiThumbCacheExpiry
Check back with Commons after a day (24*60*60) *.
Definition: ForeignAPIRepo.php:58
$result
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1528
FileRepo\$thumbUrl
$thumbUrl
Definition: FileRepo.php:90
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
$files
$files
Definition: importImages.php:67
ForeignAPIRepo\getUserAgent
static getUserAgent()
The user agent the ForeignAPIRepo will use.
Definition: ForeignAPIRepo.php:458
FileRepo\validateFilename
validateFilename( $filename)
Determine if a relative path is valid, i.e.
Definition: FileRepo.php:1627
FileRepo\makeUrl
makeUrl( $query='', $entry='index')
Make an url to this repo.
Definition: FileRepo.php:713
$wgMemc
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest to get request data $wgMemc
Definition: globals.txt:25
ForeignAPIRepo\$fileCacheExpiry
int $fileCacheExpiry
Redownload thumbnail files after a month (86400*30) *.
Definition: ForeignAPIRepo.php:60
ForeignAPIRepo\$fileFactory
$fileFactory
Definition: ForeignAPIRepo.php:57
$f
$f
Definition: UtfNormalTest2.php:38
Http\userAgent
static userAgent()
A standard user-agent we can use for external requests.
Definition: HttpFunctions.php:161
$n
$n
Definition: RandomTest.php:76
$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:1530
$time
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition: hooks.txt:1358
NS_FILE
const NS_FILE
Definition: Defines.php:85
$params
$params
Definition: styleTest.css.php:40
ForeignAPIRepo\__construct
__construct( $info)
Definition: ForeignAPIRepo.php:69
ForeignAPIRepo\getThumbUrlFromCache
getThumbUrlFromCache( $name, $width, $height, $params="")
Return the imageurl from cache if possible.
Definition: ForeignAPIRepo.php:327
FileRepo\$backend
FileBackend $backend
Definition: FileRepo.php:50
ForeignAPIRepo\assertWritableRepo
assertWritableRepo()
Definition: ForeignAPIRepo.php:588
ForeignAPIRepo\getImageInfo
getImageInfo( $data)
Definition: ForeignAPIRepo.php:213
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:506
FormatJson\decode
static decode( $value, $assoc=false)
Decodes a JSON string.
Definition: FormatJson.php:126
MWException
MediaWiki exception.
Definition: MWException.php:26
MediaWiki\Logger\LoggerFactory
Backwards compatible PSR-3 logger instance factory.
Definition: LoggerFactory.php:36
FileBackend\getFileTimestamp
getFileTimestamp(array $params)
Get the last-modified timestamp of the file at a storage path.
FileBackend\isStoragePath
static isStoragePath( $path)
Check if a given path is a "mwstore://" path.
Definition: FileBackend.php:1330
ForeignAPIRepo\$mFileExists
array $mFileExists
Definition: ForeignAPIRepo.php:62
ForeignAPIRepo\getFileProps
getFileProps( $virtualUrl)
Definition: ForeignAPIRepo.php:178
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
$options
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:1530
FileBackend\quickCreate
quickCreate(array $params)
Performs a single quick create operation.
Definition: FileBackend.php:648
wfDebug
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:980
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
FileRepo\getDisplayName
getDisplayName()
Get the human-readable name of the repo.
Definition: FileRepo.php:1722
ForeignAPIRepo\getThumbUrl
getThumbUrl( $name, $width=-1, $height=-1, &$result=null, $otherParams='')
Definition: ForeignAPIRepo.php:258
FileBackend\fileExists
fileExists(array $params)
Check if a file exists at a storage path in the backend.
PROTO_HTTP
const PROTO_HTTP
Definition: Defines.php:267
ForeignAPIRepo\fileExistsBatch
fileExistsBatch(array $files)
Definition: ForeignAPIRepo.php:123
FileBackend\prepare
prepare(array $params)
Prepare a storage directory for usage.
Definition: FileBackend.php:754
FileRepo\getBackend
getBackend()
Get the file backend instance.
Definition: FileRepo.php:190
FileRepo\getLocalCacheKey
getLocalCacheKey()
Get a key for this repo in the local cache domain.
Definition: FileRepo.php:1776
ForeignAPIRepo\$imageInfoProps
static $imageInfoProps
List of iiprop values for the thumbnail fetch queries.
Definition: ForeignAPIRepo.php:51
$hash
return false to override stock group addition can be modified try getUserPermissionsErrors userCan checks are continued by internal code can override on output return false to not delete it return false to override the default password checks & $hash
Definition: hooks.txt:2702
$file
if(PHP_SAPI !='cli') $file
Definition: UtfNormalTest2.php:30
ForeignAPIRepo\getIIProps
static getIIProps()
Definition: ForeignAPIRepo.php:532
ForeignAPIRepo\getZoneUrl
getZoneUrl( $zone, $ext=null)
Definition: ForeignAPIRepo.php:421
FileRepo\getHashPath
getHashPath( $name)
Get a relative path including trailing slash, e.g.
Definition: FileRepo.php:652
ForeignAPIRepo\enumFiles
enumFiles( $callback)
Definition: ForeignAPIRepo.php:581
ForeignAPIRepo\VERSION
const VERSION
Definition: ForeignAPIRepo.php:45
ForeignAPIRepo
A foreign repository with a remote MediaWiki with an API thingy.
Definition: ForeignAPIRepo.php:41
ForeignAPIRepo\newFile
newFile( $title, $time=false)
Per docs in FileRepo, this needs to return false if we don't support versioned files.
Definition: ForeignAPIRepo.php:111
ForeignAPIRepo\httpGetCached
httpGetCached( $target, $query, $cacheTTL=3600)
HTTP GET request to a mediawiki API (with caching)
Definition: ForeignAPIRepo.php:543
$ext
$ext
Definition: NoLocalSettings.php:34
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
ForeignAPIRepo\getZonePath
getZonePath( $zone)
Get the local directory corresponding to one of the basic zones.
Definition: ForeignAPIRepo.php:437
FileRepo\$url
bool $url
Public zone URL.
Definition: FileRepo.php:87
ForeignAPIFile\getProps
static getProps()
Get the property string for iiprop and aiprop.
Definition: ForeignAPIFile.php:92
wfWarn
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
Definition: GlobalFunctions.php:1188
ForeignAPIRepo\httpGet
static httpGet( $url, $timeout='default', $options=array())
Like a Http:get request, but with custom User-Agent.
Definition: ForeignAPIRepo.php:504
$query
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1105
ForeignAPIFile
Foreign file accessible through api.php requests.
Definition: ForeignAPIFile.php:30
ForeignAPIRepo\getThumbError
getThumbError( $name, $width=-1, $height=-1, $otherParams='', $lang=null)
Definition: ForeignAPIRepo.php:287
MWHttpRequest\factory
static factory( $url, $options=null)
Generate a new request object.
Definition: HttpFunctions.php:290
ForeignAPIRepo\getInfo
getInfo()
Get information about the repo - overrides/extends the parent class's information.
Definition: ForeignAPIRepo.php:468
ForeignAPIRepo\canCacheThumbs
canCacheThumbs()
Are we locally caching the thumbnails?
Definition: ForeignAPIRepo.php:450
ForeignAPIRepo\fetchImageQuery
fetchImageQuery( $query)
Definition: ForeignAPIRepo.php:186
wfExpandUrl
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Definition: GlobalFunctions.php:544
ForeignAPIRepo\$mQueryCache
array $mQueryCache
Definition: ForeignAPIRepo.php:64