MediaWiki  1.23.6
ForeignAPIRepo.php
Go to the documentation of this file.
1 <?php
39 class ForeignAPIRepo extends FileRepo {
40  /* This version string is used in the user agent for requests and will help
41  * server maintainers in identify ForeignAPI usage.
42  * Update the version every time you make breaking or significant changes. */
43  const VERSION = "2.1";
44 
49  protected static $imageInfoProps = array(
50  'url',
51  'thumbnail',
52  'timestamp',
53  );
54 
55  protected $fileFactory = array( 'ForeignAPIFile', 'newFromTitle' );
57  protected $apiThumbCacheExpiry = 86400;
58 
60  protected $fileCacheExpiry = 2592000;
61 
63  protected $mFileExists = array();
64 
66  private $mQueryCache = array();
67 
71  function __construct( $info ) {
72  global $wgLocalFileRepo;
73  parent::__construct( $info );
74 
75  // http://commons.wikimedia.org/w/api.php
76  $this->mApiBase = isset( $info['apibase'] ) ? $info['apibase'] : null;
77 
78  if ( isset( $info['apiThumbCacheExpiry'] ) ) {
79  $this->apiThumbCacheExpiry = $info['apiThumbCacheExpiry'];
80  }
81  if ( isset( $info['fileCacheExpiry'] ) ) {
82  $this->fileCacheExpiry = $info['fileCacheExpiry'];
83  }
84  if ( !$this->scriptDirUrl ) {
85  // hack for description fetches
86  $this->scriptDirUrl = dirname( $this->mApiBase );
87  }
88  // If we can cache thumbs we can guess sane defaults for these
89  if ( $this->canCacheThumbs() && !$this->url ) {
90  $this->url = $wgLocalFileRepo['url'];
91  }
92  if ( $this->canCacheThumbs() && !$this->thumbUrl ) {
93  $this->thumbUrl = $this->url . '/thumb';
94  }
95  }
96 
101  function getApiUrl() {
102  return $this->mApiBase;
103  }
104 
113  function newFile( $title, $time = false ) {
114  if ( $time ) {
115  return false;
116  }
117 
118  return parent::newFile( $title, $time );
119  }
120 
125  function fileExistsBatch( array $files ) {
126  $results = array();
127  foreach ( $files as $k => $f ) {
128  if ( isset( $this->mFileExists[$f] ) ) {
129  $results[$k] = $this->mFileExists[$f];
130  unset( $files[$k] );
131  } elseif ( self::isVirtualUrl( $f ) ) {
132  # @todo FIXME: We need to be able to handle virtual
133  # URLs better, at least when we know they refer to the
134  # same repo.
135  $results[$k] = false;
136  unset( $files[$k] );
137  } elseif ( FileBackend::isStoragePath( $f ) ) {
138  $results[$k] = false;
139  unset( $files[$k] );
140  wfWarn( "Got mwstore:// path '$f'." );
141  }
142  }
143 
144  $data = $this->fetchImageQuery( array(
145  'titles' => implode( $files, '|' ),
146  'prop' => 'imageinfo' )
147  );
148 
149  if ( isset( $data['query']['pages'] ) ) {
150  # First, get results from the query. Note we only care whether the image exists,
151  # not whether it has a description page.
152  foreach ( $data['query']['pages'] as $p ) {
153  $this->mFileExists[$p['title']] = ( $p['imagerepository'] !== '' );
154  }
155  # Second, copy the results to any redirects that were queried
156  if ( isset( $data['query']['redirects'] ) ) {
157  foreach ( $data['query']['redirects'] as $r ) {
158  $this->mFileExists[$r['from']] = $this->mFileExists[$r['to']];
159  }
160  }
161  # Third, copy the results to any non-normalized titles that were queried
162  if ( isset( $data['query']['normalized'] ) ) {
163  foreach ( $data['query']['normalized'] as $n ) {
164  $this->mFileExists[$n['from']] = $this->mFileExists[$n['to']];
165  }
166  }
167  # Finally, copy the results to the output
168  foreach ( $files as $key => $file ) {
169  $results[$key] = $this->mFileExists[$file];
170  }
171  }
172 
173  return $results;
174  }
175 
180  function getFileProps( $virtualUrl ) {
181  return false;
182  }
183 
188  function fetchImageQuery( $query ) {
189  global $wgLanguageCode;
190 
191  $query = array_merge( $query,
192  array(
193  'format' => 'json',
194  'action' => 'query',
195  'redirects' => 'true'
196  ) );
197 
198  if ( !isset( $query['uselang'] ) ) { // uselang is unset or null
199  $query['uselang'] = $wgLanguageCode;
200  }
201 
202  $data = $this->httpGetCached( 'Metadata', $query );
203 
204  if ( $data ) {
205  return FormatJson::decode( $data, true );
206  } else {
207  return null;
208  }
209  }
210 
215  function getImageInfo( $data ) {
216  if ( $data && isset( $data['query']['pages'] ) ) {
217  foreach ( $data['query']['pages'] as $info ) {
218  if ( isset( $info['imageinfo'][0] ) ) {
219  return $info['imageinfo'][0];
220  }
221  }
222  }
223 
224  return false;
225  }
226 
231  function findBySha1( $hash ) {
232  $results = $this->fetchImageQuery( array(
233  'aisha1base36' => $hash,
234  'aiprop' => ForeignAPIFile::getProps(),
235  'list' => 'allimages',
236  ) );
237  $ret = array();
238  if ( isset( $results['query']['allimages'] ) ) {
239  foreach ( $results['query']['allimages'] as $img ) {
240  // 1.14 was broken, doesn't return name attribute
241  if ( !isset( $img['name'] ) ) {
242  continue;
243  }
244  $ret[] = new ForeignAPIFile( Title::makeTitle( NS_FILE, $img['name'] ), $this, $img );
245  }
246  }
247 
248  return $ret;
249  }
250 
260  function getThumbUrl( $name, $width = -1, $height = -1, &$result = null, $otherParams = '' ) {
261  $data = $this->fetchImageQuery( array(
262  'titles' => 'File:' . $name,
263  'iiprop' => self::getIIProps(),
264  'iiurlwidth' => $width,
265  'iiurlheight' => $height,
266  'iiurlparam' => $otherParams,
267  'prop' => 'imageinfo' ) );
268  $info = $this->getImageInfo( $data );
269 
270  if ( $data && $info && isset( $info['thumburl'] ) ) {
271  wfDebug( __METHOD__ . " got remote thumb " . $info['thumburl'] . "\n" );
272  $result = $info;
273 
274  return $info['thumburl'];
275  } else {
276  return false;
277  }
278  }
279 
289  function getThumbError( $name, $width = -1, $height = -1, $otherParams = '', $lang = null ) {
290  $data = $this->fetchImageQuery( array(
291  'titles' => 'File:' . $name,
292  'iiprop' => self::getIIProps(),
293  'iiurlwidth' => $width,
294  'iiurlheight' => $height,
295  'iiurlparam' => $otherParams,
296  'prop' => 'imageinfo',
297  'uselang' => $lang,
298  ) );
299  $info = $this->getImageInfo( $data );
300 
301  if ( $data && $info && isset( $info['thumberror'] ) ) {
302  wfDebug( __METHOD__ . " got remote thumb error " . $info['thumberror'] . "\n" );
303 
304  return new MediaTransformError(
305  'thumbnail_error_remote',
306  $width,
307  $height,
308  $this->getDisplayName(),
309  $info['thumberror'] // already parsed message from foreign repo
310  );
311  } else {
312  return false;
313  }
314  }
315 
329  function getThumbUrlFromCache( $name, $width, $height, $params = "" ) {
330  global $wgMemc;
331  // We can't check the local cache using FileRepo functions because
332  // we override fileExistsBatch(). We have to use the FileBackend directly.
333  $backend = $this->getBackend(); // convenience
334 
335  if ( !$this->canCacheThumbs() ) {
336  $result = null; // can't pass "null" by reference, but it's ok as default value
337  return $this->getThumbUrl( $name, $width, $height, $result, $params );
338  }
339  $key = $this->getLocalCacheKey( 'ForeignAPIRepo', 'ThumbUrl', $name );
340  $sizekey = "$width:$height:$params";
341 
342  /* Get the array of urls that we already know */
343  $knownThumbUrls = $wgMemc->get( $key );
344  if ( !$knownThumbUrls ) {
345  /* No knownThumbUrls for this file */
346  $knownThumbUrls = array();
347  } else {
348  if ( isset( $knownThumbUrls[$sizekey] ) ) {
349  wfDebug( __METHOD__ . ': Got thumburl from local cache: ' .
350  "{$knownThumbUrls[$sizekey]} \n" );
351 
352  return $knownThumbUrls[$sizekey];
353  }
354  /* This size is not yet known */
355  }
356 
357  $metadata = null;
358  $foreignUrl = $this->getThumbUrl( $name, $width, $height, $metadata, $params );
359 
360  if ( !$foreignUrl ) {
361  wfDebug( __METHOD__ . " Could not find thumburl\n" );
362 
363  return false;
364  }
365 
366  // We need the same filename as the remote one :)
367  $fileName = rawurldecode( pathinfo( $foreignUrl, PATHINFO_BASENAME ) );
368  if ( !$this->validateFilename( $fileName ) ) {
369  wfDebug( __METHOD__ . " The deduced filename $fileName is not safe\n" );
370 
371  return false;
372  }
373  $localPath = $this->getZonePath( 'thumb' ) . "/" . $this->getHashPath( $name ) . $name;
374  $localFilename = $localPath . "/" . $fileName;
375  $localUrl = $this->getZoneUrl( 'thumb' ) . "/" . $this->getHashPath( $name ) .
376  rawurlencode( $name ) . "/" . rawurlencode( $fileName );
377 
378  if ( $backend->fileExists( array( 'src' => $localFilename ) )
379  && isset( $metadata['timestamp'] )
380  ) {
381  wfDebug( __METHOD__ . " Thumbnail was already downloaded before\n" );
382  $modified = $backend->getFileTimestamp( array( 'src' => $localFilename ) );
383  $remoteModified = strtotime( $metadata['timestamp'] );
384  $current = time();
385  $diff = abs( $modified - $current );
386  if ( $remoteModified < $modified && $diff < $this->fileCacheExpiry ) {
387  /* Use our current and already downloaded thumbnail */
388  $knownThumbUrls[$sizekey] = $localUrl;
389  $wgMemc->set( $key, $knownThumbUrls, $this->apiThumbCacheExpiry );
390 
391  return $localUrl;
392  }
393  /* There is a new Commons file, or existing thumbnail older than a month */
394  }
395  $thumb = self::httpGet( $foreignUrl );
396  if ( !$thumb ) {
397  wfDebug( __METHOD__ . " Could not download thumb\n" );
398 
399  return false;
400  }
401 
402  # @todo FIXME: Delete old thumbs that aren't being used. Maintenance script?
403  $backend->prepare( array( 'dir' => dirname( $localFilename ) ) );
404  $params = array( 'dst' => $localFilename, 'content' => $thumb );
405  if ( !$backend->quickCreate( $params )->isOK() ) {
406  wfDebug( __METHOD__ . " could not write to thumb path '$localFilename'\n" );
407 
408  return $foreignUrl;
409  }
410  $knownThumbUrls[$sizekey] = $localUrl;
411  $wgMemc->set( $key, $knownThumbUrls, $this->apiThumbCacheExpiry );
412  wfDebug( __METHOD__ . " got local thumb $localUrl, saving to cache \n" );
413 
414  return $localUrl;
415  }
416 
423  function getZoneUrl( $zone, $ext = null ) {
424  switch ( $zone ) {
425  case 'public':
426  return $this->url;
427  case 'thumb':
428  return $this->thumbUrl;
429  default:
430  return parent::getZoneUrl( $zone, $ext );
431  }
432  }
433 
439  function getZonePath( $zone ) {
440  $supported = array( 'public', 'thumb' );
441  if ( in_array( $zone, $supported ) ) {
442  return parent::getZonePath( $zone );
443  }
444 
445  return false;
446  }
447 
452  public function canCacheThumbs() {
453  return ( $this->apiThumbCacheExpiry > 0 );
454  }
455 
460  public static function getUserAgent() {
461  return Http::userAgent() . " ForeignAPIRepo/" . self::VERSION;
462  }
463 
470  function getInfo() {
471  $info = parent::getInfo();
472  $info['apiurl'] = $this->getApiUrl();
473 
474  $query = array(
475  'format' => 'json',
476  'action' => 'query',
477  'meta' => 'siteinfo',
478  'siprop' => 'general',
479  );
480 
481  $data = $this->httpGetCached( 'SiteInfo', $query, 7200 );
482 
483  if ( $data ) {
484  $siteInfo = FormatJson::decode( $data, true );
485  $general = $siteInfo['query']['general'];
486 
487  $info['articlepath'] = $general['articlepath'];
488  $info['server'] = $general['server'];
489 
490  if ( isset( $general['favicon'] ) ) {
491  $info['favicon'] = $general['favicon'];
492  }
493  }
494 
495  return $info;
496  }
497 
506  public static function httpGet( $url, $timeout = 'default', $options = array() ) {
507  $options['timeout'] = $timeout;
508  /* Http::get */
510  wfDebug( "ForeignAPIRepo: HTTP GET: $url\n" );
511  $options['method'] = "GET";
512 
513  if ( !isset( $options['timeout'] ) ) {
514  $options['timeout'] = 'default';
515  }
516 
518  $req->setUserAgent( ForeignAPIRepo::getUserAgent() );
519  $status = $req->execute();
520 
521  if ( $status->isOK() ) {
522  return $req->getContent();
523  } else {
524  return false;
525  }
526  }
527 
532  protected static function getIIProps() {
533  return join( '|', self::$imageInfoProps );
534  }
535 
543  public function httpGetCached( $target, $query, $cacheTTL = 3600 ) {
544  if ( $this->mApiBase ) {
545  $url = wfAppendQuery( $this->mApiBase, $query );
546  } else {
547  $url = $this->makeUrl( $query, 'api' );
548  }
549 
550  if ( !isset( $this->mQueryCache[$url] ) ) {
551  global $wgMemc;
552 
553  $key = $this->getLocalCacheKey( get_class( $this ), $target, md5( $url ) );
554  $data = $wgMemc->get( $key );
555 
556  if ( !$data ) {
557  $data = self::httpGet( $url );
558 
559  if ( !$data ) {
560  return null;
561  }
562 
563  $wgMemc->set( $key, $data, $cacheTTL );
564  }
565 
566  if ( count( $this->mQueryCache ) > 100 ) {
567  // Keep the cache from growing infinitely
568  $this->mQueryCache = array();
569  }
570 
571  $this->mQueryCache[$url] = $data;
572  }
573 
574  return $this->mQueryCache[$url];
575  }
576 
581  function enumFiles( $callback ) {
582  throw new MWException( 'enumFiles is not supported by ' . get_class( $this ) );
583  }
584 
588  protected function assertWritableRepo() {
589  throw new MWException( get_class( $this ) . ': write operations are not supported.' );
590  }
591 }
ForeignAPIRepo\getApiUrl
getApiUrl()
Definition: ForeignAPIRepo.php:97
ForeignAPIRepo\findBySha1
findBySha1( $hash)
Definition: ForeignAPIRepo.php:227
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:56
$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
$time
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition: hooks.txt:1358
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:456
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:58
ForeignAPIRepo\$fileFactory
$fileFactory
Definition: ForeignAPIRepo.php:55
$f
$f
Definition: UtfNormalTest2.php:38
Http\userAgent
static userAgent()
A standard user-agent we can use for external requests.
Definition: HttpFunctions.php:155
$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
NS_FILE
const NS_FILE
Definition: Defines.php:85
$params
$params
Definition: styleTest.css.php:40
ForeignAPIRepo\__construct
__construct( $info)
Definition: ForeignAPIRepo.php:67
ForeignAPIRepo\getThumbUrlFromCache
getThumbUrlFromCache( $name, $width, $height, $params="")
Return the imageurl from cache if possible.
Definition: ForeignAPIRepo.php:325
FileRepo\$backend
FileBackend $backend
Definition: FileRepo.php:50
ForeignAPIRepo\assertWritableRepo
assertWritableRepo()
Definition: ForeignAPIRepo.php:584
ForeignAPIRepo\getImageInfo
getImageInfo( $data)
Definition: ForeignAPIRepo.php:211
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:459
FormatJson\decode
static decode( $value, $assoc=false)
Decodes a JSON string.
Definition: FormatJson.php:126
MWException
MediaWiki exception.
Definition: MWException.php:26
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:60
ForeignAPIRepo\getFileProps
getFileProps( $virtualUrl)
Definition: ForeignAPIRepo.php:176
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:933
$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:256
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:121
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:49
$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:2697
$file
if(PHP_SAPI !='cli') $file
Definition: UtfNormalTest2.php:30
ForeignAPIRepo\getIIProps
static getIIProps()
Definition: ForeignAPIRepo.php:528
ForeignAPIRepo\getZoneUrl
getZoneUrl( $zone, $ext=null)
Definition: ForeignAPIRepo.php:419
FileRepo\getHashPath
getHashPath( $name)
Get a relative path including trailing slash, e.g.
Definition: FileRepo.php:652
ForeignAPIRepo\enumFiles
enumFiles( $callback)
Definition: ForeignAPIRepo.php:577
ForeignAPIRepo\VERSION
const VERSION
Definition: ForeignAPIRepo.php:43
ForeignAPIRepo
A foreign repository with a remote MediaWiki with an API thingy.
Definition: ForeignAPIRepo.php:39
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:109
ForeignAPIRepo\httpGetCached
httpGetCached( $target, $query, $cacheTTL=3600)
HTTP GET request to a mediawiki API (with caching)
Definition: ForeignAPIRepo.php:539
$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:435
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:1141
ForeignAPIRepo\httpGet
static httpGet( $url, $timeout='default', $options=array())
Like a Http:get request, but with custom User-Agent.
Definition: ForeignAPIRepo.php:502
$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:285
MWHttpRequest\factory
static factory( $url, $options=null)
Generate a new request object.
Definition: HttpFunctions.php:284
ForeignAPIRepo\getInfo
getInfo()
Get information about the repo - overrides/extends the parent class's information.
Definition: ForeignAPIRepo.php:466
ForeignAPIRepo\canCacheThumbs
canCacheThumbs()
Are we locally caching the thumbnails?
Definition: ForeignAPIRepo.php:448
ForeignAPIRepo\fetchImageQuery
fetchImageQuery( $query)
Definition: ForeignAPIRepo.php:184
wfExpandUrl
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Definition: GlobalFunctions.php:497
ForeignAPIRepo\$mQueryCache
array $mQueryCache
Definition: ForeignAPIRepo.php:62