62 if ( self::$instance ) {
77 self::$instance =
null;
133 if ( !$this->reposInitialised ) {
143 $dbkey = $title->getDBkey();
145 if ( empty(
$options[
'ignoreRedirect'] )
149 if ( $this->
cache->hasField( $dbkey, $timeKey, 60 ) ) {
150 return $this->
cache->getField( $dbkey, $timeKey );
157 # Check the local repo
160 # Check the foreign repos
162 foreach ( $this->foreignRepos as $repo ) {
171 # Cache file existence or non-existence
172 if ( $useCache && ( !
$image ||
$image->isCacheable() ) ) {
173 $this->
cache->setField( $dbkey, $timeKey,
$image );
197 if ( !$this->reposInitialised ) {
202 foreach ( $inputItems as $item ) {
204 $item = [
'title' =>
$item ];
207 if ( $item[
'title'] ) {
208 $items[$item[
'title']->getDBkey()] =
$item;
212 $images = $this->localRepo->findFiles( $items, $flags );
214 foreach ( $this->foreignRepos as $repo ) {
216 foreach ( $images as $name =>
$image ) {
217 unset( $items[$name] );
220 $images =
array_merge( $images, $repo->findFiles( $items, $flags ) );
232 if ( !$this->reposInitialised ) {
236 $redir = $this->localRepo->checkRedirect( $title );
241 foreach ( $this->foreignRepos as $repo ) {
242 $redir = $repo->checkRedirect( $title );
260 if ( !$this->reposInitialised ) {
264 $file = $this->localRepo->findFileFromKey( $hash,
$options );
266 foreach ( $this->foreignRepos as $repo ) {
267 $file = $repo->findFileFromKey( $hash,
$options );
284 if ( !$this->reposInitialised ) {
288 $result = $this->localRepo->findBySha1( $hash );
289 foreach ( $this->foreignRepos as $repo ) {
290 $result =
array_merge( $result, $repo->findBySha1( $hash ) );
292 usort( $result,
'File::compare' );
304 if ( !$this->reposInitialised ) {
308 $result = $this->localRepo->findBySha1s(
$hashes );
309 foreach ( $this->foreignRepos as $repo ) {
313 foreach ( $result as $hash => $files ) {
314 usort( $result[$hash],
'File::compare' );
326 if ( !$this->reposInitialised ) {
329 if ( $index ===
'local' ) {
332 return $this->foreignRepos[$index] ??
false;
341 if ( !$this->reposInitialised ) {
344 foreach ( $this->foreignRepos as $repo ) {
345 if ( $repo->name == $name ) {
361 $repo = $this->
getRepo(
'local' );
375 if ( !$this->reposInitialised ) {
378 foreach ( $this->foreignRepos as $repo ) {
379 if ( $callback( $repo, ...
$params ) ) {
392 if ( !$this->reposInitialised ) {
402 if ( $this->reposInitialised ) {
405 $this->reposInitialised =
true;
407 $this->localRepo = $this->
newRepo( $this->localInfo );
408 $this->foreignRepos = [];
409 foreach ( $this->foreignInfo as $key => $info ) {
410 $this->foreignRepos[$key] = $this->
newRepo( $info );
420 $class = $info[
'class'];
422 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
423 $info[
'wanCache'] =
$cache;
425 return new $class( $info );
435 if (
substr( $url, 0, 9 ) !=
'mwrepo://' ) {
436 throw new MWException( __METHOD__ .
': unknown protocol' );
439 $bits = explode(
'/',
substr( $url, 9 ), 3 );
440 if ( count( $bits ) != 3 ) {
441 throw new MWException( __METHOD__ .
": invalid mwrepo URL: $url" );
454 if ( $repoName ===
'' ) {
457 $repo = $this->
getRepo( $repoName );
459 return $repo->getFileProps( $fileName );
463 return $mwProps->getPropsFromPath( $fileName,
true );
472 if ( $title ==
null ) {
473 $this->
cache->clear();
475 $this->
cache->clear( $title->getDBkey() );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
$wgLocalFileRepo
File repository structures.
$wgForeignFileRepos
Enable the use of files from one or more other wikis.
Base class for file repositories.
static isVirtualUrl( $url)
Determine if a string is an mwrepo:// URL.
Implements some public methods and some protected utility functions which are required by multiple ch...
static normalizeTitle( $title, $exception=false)
Given a string or Title object return either a valid Title object with namespace NS_FILE or null.
A repository that stores files in the local filesystem and registers them in the wiki's own database.
MimeMagic helper wrapper.
Handles a simple LRU key/value map with a maximum number of entries.
Class for process caching individual properties of expiring items.
Prioritized list of file repositories.
initialiseRepos()
Initialise the $repos array.
getRepoByName( $name)
Get the repo instance by its name.
splitVirtualUrl( $url)
Split a virtual URL into repo, zone and rel parts.
const MAX_CACHE_SIZE
Maximum number of cache items.
hasForeignRepos()
Does the installation have any foreign repos set up?
findFileFromKey( $hash, $options=[])
Find an instance of the file with this key, created at the specified time Returns false if the file d...
__construct( $localInfo, $foreignInfo)
Construct a group of file repositories.
findFile( $title, $options=[])
Search repositories for an image.
getLocalRepo()
Get the local repository, i.e.
findBySha1s(array $hashes)
Find all instances of files with this keys.
checkRedirect(Title $title)
Interface for FileRepo::checkRedirect()
static RepoGroup $instance
getRepo( $index)
Get the repo instance with a given key.
clearCache(Title $title=null)
Clear RepoGroup process cache used for finding a file.
static singleton()
Get a RepoGroup instance.
findBySha1( $hash)
Find all instances of files with this key.
findFiles(array $inputItems, $flags=0)
Search repositories for many files at once.
static setSingleton( $instance)
Set the singleton instance to a given object Used by extensions which hook into the Repo chain.
newRepo( $info)
Create a repo class based on an info structure.
static destroySingleton()
Destroy the singleton instance, so that a new one will be created next time singleton() is called.
forEachForeignRepo( $callback, $params=[])
Call a function for each foreign repo, with the repo object as the first parameter.
Represents a title within MediaWiki.
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
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 $image
namespace being checked & $result
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
processing should stop and the error should be shown to the user * false
you have access to all of the normal MediaWiki so you can get a DB use the cache
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))
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file