MediaWiki  master
LocalRepo.php
Go to the documentation of this file.
1 <?php
29 
37 class LocalRepo extends FileRepo {
39  protected $fileFactory = [ LocalFile::class, 'newFromTitle' ];
41  protected $fileFactoryKey = [ LocalFile::class, 'newFromKey' ];
43  protected $fileFromRowFactory = [ LocalFile::class, 'newFromRow' ];
45  protected $oldFileFromRowFactory = [ OldLocalFile::class, 'newFromRow' ];
47  protected $oldFileFactory = [ OldLocalFile::class, 'newFromTitle' ];
49  protected $oldFileFactoryKey = [ OldLocalFile::class, 'newFromKey' ];
50 
52  protected $dbDomain;
55 
56  public function __construct( array $info = null ) {
57  parent::__construct( $info );
58 
59  $this->dbDomain = WikiMap::getCurrentWikiDbDomain();
60  $this->hasAccessibleSharedCache = true;
61 
62  $this->hasSha1Storage = ( $info['storageLayout'] ?? null ) === 'sha1';
63 
64  if ( $this->hasSha1Storage() ) {
65  $this->backend = new FileBackendDBRepoWrapper( [
66  'backend' => $this->backend,
67  'repoName' => $this->name,
68  'dbHandleFactory' => $this->getDBFactory()
69  ] );
70  }
71  }
72 
78  public function newFileFromRow( $row ) {
79  if ( isset( $row->img_name ) ) {
80  return call_user_func( $this->fileFromRowFactory, $row, $this );
81  } elseif ( isset( $row->oi_name ) ) {
82  return call_user_func( $this->oldFileFromRowFactory, $row, $this );
83  } else {
84  throw new MWException( __METHOD__ . ': invalid row' );
85  }
86  }
87 
93  public function newFromArchiveName( $title, $archiveName ) {
94  return OldLocalFile::newFromArchiveName( $title, $this, $archiveName );
95  }
96 
107  public function cleanupDeletedBatch( array $storageKeys ) {
108  if ( $this->hasSha1Storage() ) {
109  wfDebug( __METHOD__ . ": skipped because storage uses sha1 paths" );
110  return Status::newGood();
111  }
112 
113  $backend = $this->backend; // convenience
114  $root = $this->getZonePath( 'deleted' );
115  $dbw = $this->getMasterDB();
116  $status = $this->newGood();
117  $storageKeys = array_unique( $storageKeys );
118  foreach ( $storageKeys as $key ) {
119  $hashPath = $this->getDeletedHashPath( $key );
120  $path = "$root/$hashPath$key";
121  $dbw->startAtomic( __METHOD__ );
122  // Check for usage in deleted/hidden files and preemptively
123  // lock the key to avoid any future use until we are finished.
124  $deleted = $this->deletedFileHasKey( $key, 'lock' );
125  $hidden = $this->hiddenFileHasKey( $key, 'lock' );
126  if ( !$deleted && !$hidden ) { // not in use now
127  wfDebug( __METHOD__ . ": deleting $key" );
128  $op = [ 'op' => 'delete', 'src' => $path ];
129  if ( !$backend->doOperation( $op )->isOK() ) {
130  $status->error( 'undelete-cleanup-error', $path );
131  $status->failCount++;
132  }
133  } else {
134  wfDebug( __METHOD__ . ": $key still in use" );
135  $status->successCount++;
136  }
137  $dbw->endAtomic( __METHOD__ );
138  }
139 
140  return $status;
141  }
142 
150  protected function deletedFileHasKey( $key, $lock = null ) {
151  $options = ( $lock === 'lock' ) ? [ 'FOR UPDATE' ] : [];
152 
153  $dbw = $this->getMasterDB();
154 
155  return (bool)$dbw->selectField( 'filearchive', '1',
156  [ 'fa_storage_group' => 'deleted', 'fa_storage_key' => $key ],
157  __METHOD__, $options
158  );
159  }
160 
168  protected function hiddenFileHasKey( $key, $lock = null ) {
169  $options = ( $lock === 'lock' ) ? [ 'FOR UPDATE' ] : [];
170 
171  $sha1 = self::getHashFromKey( $key );
172  $ext = File::normalizeExtension( substr( $key, strcspn( $key, '.' ) + 1 ) );
173 
174  $dbw = $this->getMasterDB();
175 
176  return (bool)$dbw->selectField( 'oldimage', '1',
177  [ 'oi_sha1' => $sha1,
178  'oi_archive_name ' . $dbw->buildLike( $dbw->anyString(), ".$ext" ),
179  $dbw->bitAnd( 'oi_deleted', File::DELETED_FILE ) => File::DELETED_FILE ],
180  __METHOD__, $options
181  );
182  }
183 
190  public static function getHashFromKey( $key ) {
191  $sha1 = strtok( $key, '.' );
192  if ( is_string( $sha1 ) && strlen( $sha1 ) === 32 && $sha1[0] === '0' ) {
193  $sha1 = substr( $sha1, 1 );
194  }
195  return $sha1;
196  }
197 
204  public function checkRedirect( Title $title ) {
205  $title = File::normalizeTitle( $title, 'exception' );
206 
207  $memcKey = $this->getSharedCacheKey( 'file-redirect', md5( $title->getDBkey() ) );
208  if ( $memcKey === false ) {
209  $memcKey = $this->getLocalCacheKey( 'file-redirect', md5( $title->getDBkey() ) );
210  $expiry = 300; // no invalidation, 5 minutes
211  } else {
212  $expiry = 86400; // has invalidation, 1 day
213  }
214 
215  $method = __METHOD__;
216  $redirDbKey = $this->wanCache->getWithSetCallback(
217  $memcKey,
218  $expiry,
219  function ( $oldValue, &$ttl, array &$setOpts ) use ( $method, $title ) {
220  $dbr = $this->getReplicaDB(); // possibly remote DB
221 
222  $setOpts += Database::getCacheSetOptions( $dbr );
223 
224  $row = $dbr->selectRow(
225  [ 'page', 'redirect' ],
226  [ 'rd_namespace', 'rd_title' ],
227  [
228  'page_namespace' => $title->getNamespace(),
229  'page_title' => $title->getDBkey(),
230  'rd_from = page_id'
231  ],
232  $method
233  );
234 
235  return ( $row && $row->rd_namespace == NS_FILE )
236  ? Title::makeTitle( $row->rd_namespace, $row->rd_title )->getDBkey()
237  : ''; // negative cache
238  },
239  [ 'pcTTL' => WANObjectCache::TTL_PROC_LONG ]
240  );
241 
242  // @note: also checks " " for b/c
243  if ( $redirDbKey !== ' ' && strval( $redirDbKey ) !== '' ) {
244  // Page is a redirect to another file
245  return Title::newFromText( $redirDbKey, NS_FILE );
246  }
247 
248  return false; // no redirect
249  }
250 
251  public function findFiles( array $items, $flags = 0 ) {
252  $finalFiles = []; // map of (DB key => corresponding File) for matches
253 
254  $searchSet = []; // map of (normalized DB key => search params)
255  foreach ( $items as $item ) {
256  if ( is_array( $item ) ) {
257  $title = File::normalizeTitle( $item['title'] );
258  if ( $title ) {
259  $searchSet[$title->getDBkey()] = $item;
260  }
261  } else {
262  $title = File::normalizeTitle( $item );
263  if ( $title ) {
264  $searchSet[$title->getDBkey()] = [];
265  }
266  }
267  }
268 
269  $fileMatchesSearch = function ( File $file, array $search ) {
270  // Note: file name comparison done elsewhere (to handle redirects)
271 
272  // Fallback to RequestContext::getMain should be replaced with a better
273  // way of setting the user that should be used; currently it needs to be
274  // set for each file individually. See T263033#6477586
275  $contextUser = RequestContext::getMain()->getUser();
276  $user = ( !empty( $search['private'] ) && $search['private'] instanceof User )
277  ? $search['private']
278  : $contextUser;
279 
280  return (
281  $file->exists() &&
282  (
283  ( empty( $search['time'] ) && !$file->isOld() ) ||
284  ( !empty( $search['time'] ) && $search['time'] === $file->getTimestamp() )
285  ) &&
286  ( !empty( $search['private'] ) || !$file->isDeleted( File::DELETED_FILE ) ) &&
287  $file->userCan( File::DELETED_FILE, $user )
288  );
289  };
290 
291  $applyMatchingFiles = function ( IResultWrapper $res, &$searchSet, &$finalFiles )
292  use ( $fileMatchesSearch, $flags )
293  {
294  $contLang = MediaWikiServices::getInstance()->getContentLanguage();
295  $info = $this->getInfo();
296  foreach ( $res as $row ) {
297  $file = $this->newFileFromRow( $row );
298  // There must have been a search for this DB key, but this has to handle the
299  // cases were title capitalization is different on the client and repo wikis.
300  $dbKeysLook = [ strtr( $file->getName(), ' ', '_' ) ];
301  if ( !empty( $info['initialCapital'] ) ) {
302  // Search keys for "hi.png" and "Hi.png" should use the "Hi.png file"
303  $dbKeysLook[] = $contLang->lcfirst( $file->getName() );
304  }
305  foreach ( $dbKeysLook as $dbKey ) {
306  if ( isset( $searchSet[$dbKey] )
307  && $fileMatchesSearch( $file, $searchSet[$dbKey] )
308  ) {
309  $finalFiles[$dbKey] = ( $flags & FileRepo::NAME_AND_TIME_ONLY )
310  ? [ 'title' => $dbKey, 'timestamp' => $file->getTimestamp() ]
311  : $file;
312  unset( $searchSet[$dbKey] );
313  }
314  }
315  }
316  };
317 
318  $dbr = $this->getReplicaDB();
319 
320  // Query image table
321  $imgNames = [];
322  foreach ( array_keys( $searchSet ) as $dbKey ) {
323  $imgNames[] = $this->getNameFromTitle( File::normalizeTitle( $dbKey ) );
324  }
325 
326  if ( count( $imgNames ) ) {
327  $fileQuery = LocalFile::getQueryInfo();
328  $res = $dbr->select( $fileQuery['tables'], $fileQuery['fields'], [ 'img_name' => $imgNames ],
329  __METHOD__, [], $fileQuery['joins'] );
330  $applyMatchingFiles( $res, $searchSet, $finalFiles );
331  }
332 
333  // Query old image table
334  $oiConds = []; // WHERE clause array for each file
335  foreach ( $searchSet as $dbKey => $search ) {
336  if ( isset( $search['time'] ) ) {
337  $oiConds[] = $dbr->makeList(
338  [
339  'oi_name' => $this->getNameFromTitle( File::normalizeTitle( $dbKey ) ),
340  'oi_timestamp' => $dbr->timestamp( $search['time'] )
341  ],
342  LIST_AND
343  );
344  }
345  }
346 
347  if ( count( $oiConds ) ) {
348  $fileQuery = OldLocalFile::getQueryInfo();
349  $res = $dbr->select( $fileQuery['tables'], $fileQuery['fields'],
350  $dbr->makeList( $oiConds, LIST_OR ),
351  __METHOD__, [], $fileQuery['joins'] );
352  $applyMatchingFiles( $res, $searchSet, $finalFiles );
353  }
354 
355  // Check for redirects...
356  foreach ( $searchSet as $dbKey => $search ) {
357  if ( !empty( $search['ignoreRedirect'] ) ) {
358  continue;
359  }
360 
361  $title = File::normalizeTitle( $dbKey );
362  $redir = $this->checkRedirect( $title ); // hopefully hits memcached
363 
364  if ( $redir && $redir->getNamespace() === NS_FILE ) {
365  $file = $this->newFile( $redir );
366  if ( $file && $fileMatchesSearch( $file, $search ) ) {
367  $file->redirectedFrom( $title->getDBkey() );
368  if ( $flags & FileRepo::NAME_AND_TIME_ONLY ) {
369  $finalFiles[$dbKey] = [
370  'title' => $file->getTitle()->getDBkey(),
371  'timestamp' => $file->getTimestamp()
372  ];
373  } else {
374  $finalFiles[$dbKey] = $file;
375  }
376  }
377  }
378  }
379 
380  return $finalFiles;
381  }
382 
390  public function findBySha1( $hash ) {
391  $dbr = $this->getReplicaDB();
392  $fileQuery = LocalFile::getQueryInfo();
393  $res = $dbr->select(
394  $fileQuery['tables'],
395  $fileQuery['fields'],
396  [ 'img_sha1' => $hash ],
397  __METHOD__,
398  [ 'ORDER BY' => 'img_name' ],
399  $fileQuery['joins']
400  );
401 
402  $result = [];
403  foreach ( $res as $row ) {
404  $result[] = $this->newFileFromRow( $row );
405  }
406  $res->free();
407 
408  return $result;
409  }
410 
420  public function findBySha1s( array $hashes ) {
421  if ( $hashes === [] ) {
422  return []; // empty parameter
423  }
424 
425  $dbr = $this->getReplicaDB();
426  $fileQuery = LocalFile::getQueryInfo();
427  $res = $dbr->select(
428  $fileQuery['tables'],
429  $fileQuery['fields'],
430  [ 'img_sha1' => $hashes ],
431  __METHOD__,
432  [ 'ORDER BY' => 'img_name' ],
433  $fileQuery['joins']
434  );
435 
436  $result = [];
437  foreach ( $res as $row ) {
438  $file = $this->newFileFromRow( $row );
439  $result[$file->getSha1()][] = $file;
440  }
441  $res->free();
442 
443  return $result;
444  }
445 
453  public function findFilesByPrefix( $prefix, $limit ) {
454  $selectOptions = [ 'ORDER BY' => 'img_name', 'LIMIT' => intval( $limit ) ];
455 
456  // Query database
457  $dbr = $this->getReplicaDB();
458  $fileQuery = LocalFile::getQueryInfo();
459  $res = $dbr->select(
460  $fileQuery['tables'],
461  $fileQuery['fields'],
462  'img_name ' . $dbr->buildLike( $prefix, $dbr->anyString() ),
463  __METHOD__,
464  $selectOptions,
465  $fileQuery['joins']
466  );
467 
468  // Build file objects
469  $files = [];
470  foreach ( $res as $row ) {
471  $files[] = $this->newFileFromRow( $row );
472  }
473 
474  return $files;
475  }
476 
481  public function getReplicaDB() {
482  return wfGetDB( DB_REPLICA );
483  }
484 
489  public function getMasterDB() {
490  return wfGetDB( DB_MASTER );
491  }
492 
497  protected function getDBFactory() {
498  return function ( $index ) {
499  return wfGetDB( $index );
500  };
501  }
502 
509  protected function hasAcessibleSharedCache() {
511  }
512 
513  public function getSharedCacheKey( $kClassSuffix, ...$components ) {
514  // T267668: do not include the repo name in the key
515  return $this->hasAcessibleSharedCache()
516  ? $this->wanCache->makeGlobalKey(
517  'filerepo-' . $kClassSuffix,
518  $this->dbDomain,
519  ...$components
520  )
521  : false;
522  }
523 
530  public function invalidateImageRedirect( Title $title ) {
531  $key = $this->getSharedCacheKey( 'file-redirect', md5( $title->getDBkey() ) );
532  if ( $key ) {
533  $this->getMasterDB()->onTransactionPreCommitOrIdle(
534  function () use ( $key ) {
535  $this->wanCache->delete( $key );
536  },
537  __METHOD__
538  );
539  }
540  }
541 
548  public function getInfo() {
549  global $wgFavicon;
550 
551  return array_merge( parent::getInfo(), [
552  'favicon' => wfExpandUrl( $wgFavicon ),
553  ] );
554  }
555 
556  public function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) {
557  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
558  }
559 
560  public function storeBatch( array $triplets, $flags = 0 ) {
561  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
562  }
563 
564  public function cleanupBatch( array $files, $flags = 0 ) {
565  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
566  }
567 
568  public function publish(
569  $src,
570  $dstRel,
571  $archiveRel,
572  $flags = 0,
573  array $options = []
574  ) {
575  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
576  }
577 
578  public function publishBatch( array $ntuples, $flags = 0 ) {
579  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
580  }
581 
582  public function delete( $srcRel, $archiveRel ) {
583  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
584  }
585 
586  public function deleteBatch( array $sourceDestPairs ) {
587  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
588  }
589 
597  protected function skipWriteOperationIfSha1( $function, array $args ) {
598  $this->assertWritableRepo(); // fail out if read-only
599 
600  if ( $this->hasSha1Storage() ) {
601  wfDebug( __METHOD__ . ": skipped because storage uses sha1 paths" );
602  return Status::newGood();
603  } else {
604  return parent::$function( ...$args );
605  }
606  }
607 }
LIST_OR
const LIST_OR
Definition: Defines.php:45
Wikimedia\Rdbms\Database
Relational database abstraction object.
Definition: Database.php:50
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:361
LocalRepo\getInfo
getInfo()
Return information about the repository.
Definition: LocalRepo.php:548
WikiMap\getCurrentWikiDbDomain
static getCurrentWikiDbDomain()
Definition: WikiMap.php:293
LocalRepo\newFileFromRow
newFileFromRow( $row)
Definition: LocalRepo.php:78
FileRepo\newGood
newGood( $value=null)
Create a new good result.
Definition: FileRepo.php:1806
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:166
LocalRepo\getMasterDB
getMasterDB()
Get a connection to the master DB.
Definition: LocalRepo.php:489
OldLocalFile\getQueryInfo
static getQueryInfo(array $options=[])
Return the tables, fields, and join conditions to be selected to create a new oldlocalfile object.
Definition: OldLocalFile.php:130
LocalRepo\getReplicaDB
getReplicaDB()
Get a connection to the replica DB.
Definition: LocalRepo.php:481
LocalRepo\publish
publish( $src, $dstRel, $archiveRel, $flags=0, array $options=[])
Copy or move a file either from a storage path, virtual URL, or file system path, into this repositor...
Definition: LocalRepo.php:568
LIST_AND
const LIST_AND
Definition: Defines.php:42
LocalRepo\deletedFileHasKey
deletedFileHasKey( $key, $lock=null)
Check if a deleted (filearchive) file has this sha1 key.
Definition: LocalRepo.php:150
LocalRepo\getSharedCacheKey
getSharedCacheKey( $kClassSuffix,... $components)
Get a global, repository-qualified, WAN cache key.
Definition: LocalRepo.php:513
LocalRepo\$oldFileFactoryKey
callable $oldFileFactoryKey
Definition: LocalRepo.php:49
$file
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition: router.php:42
LocalRepo\$oldFileFactory
callable $oldFileFactory
Definition: LocalRepo.php:47
FileRepo\getZonePath
getZonePath( $zone)
Get the storage path corresponding to one of the zones.
Definition: FileRepo.php:392
FileRepo\$backend
FileBackend $backend
Definition: FileRepo.php:64
$res
$res
Definition: testCompression.php:57
LocalRepo\hiddenFileHasKey
hiddenFileHasKey( $key, $lock=null)
Check if a hidden (revision delete) file has this sha1 key.
Definition: LocalRepo.php:168
LocalRepo\getHashFromKey
static getHashFromKey( $key)
Gets the SHA1 hash from a storage key.
Definition: LocalRepo.php:190
File\normalizeTitle
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:199
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
$dbr
$dbr
Definition: testCompression.php:54
FileRepo
Base class for file repositories.
Definition: FileRepo.php:41
FileRepo\hasSha1Storage
hasSha1Storage()
Returns whether or not storage is SHA-1 based.
Definition: FileRepo.php:1998
File
Implements some public methods and some protected utility functions which are required by multiple ch...
Definition: File.php:63
LocalRepo\$oldFileFromRowFactory
callable $oldFileFromRowFactory
Definition: LocalRepo.php:45
FileRepo\newFile
newFile( $title, $time=false)
Create a new File object from the local repository.
Definition: FileRepo.php:416
MWException
MediaWiki exception.
Definition: MWException.php:29
FileBackend\doOperation
doOperation(array $op, array $opts=[])
Same as doOperations() except it takes a single operation.
Definition: FileBackend.php:506
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2466
File\normalizeExtension
static normalizeExtension( $extension)
Normalize a file extension to the common form, making it lowercase and checking some synonyms,...
Definition: File.php:239
LocalRepo\store
store( $srcPath, $dstZone, $dstRel, $flags=0)
Store a file to a given destination.
Definition: LocalRepo.php:556
LocalRepo\getDBFactory
getDBFactory()
Get a callback to get a DB handle given an index (DB_REPLICA/DB_MASTER)
Definition: LocalRepo.php:497
LocalRepo\invalidateImageRedirect
invalidateImageRedirect(Title $title)
Invalidates image redirect cache related to that image.
Definition: LocalRepo.php:530
LocalRepo\storeBatch
storeBatch(array $triplets, $flags=0)
Store a batch of files.
Definition: LocalRepo.php:560
$args
if( $line===false) $args
Definition: mcc.php:124
$title
$title
Definition: testCompression.php:38
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:624
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
DB_MASTER
const DB_MASTER
Definition: defines.php:26
wfDebug
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:914
LocalRepo\cleanupBatch
cleanupBatch(array $files, $flags=0)
Deletes a batch of files.
Definition: LocalRepo.php:564
LocalRepo\findFiles
findFiles(array $items, $flags=0)
Find many files at once.
Definition: LocalRepo.php:251
FileRepo\getNameFromTitle
getNameFromTitle(Title $title)
Get the name of a file from its title object.
Definition: FileRepo.php:699
FileRepo\getLocalCacheKey
getLocalCacheKey( $kClassSuffix,... $components)
Get a site-local, repository-qualified, WAN cache key.
Definition: FileRepo.php:1902
LocalRepo\newFromArchiveName
newFromArchiveName( $title, $archiveName)
Definition: LocalRepo.php:93
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:82
LocalRepo\$hasAccessibleSharedCache
bool $hasAccessibleSharedCache
Whether shared cache keys are exposed/accessible.
Definition: LocalRepo.php:54
LocalRepo\$fileFactory
callable $fileFactory
Definition: LocalRepo.php:39
LocalRepo\$fileFactoryKey
callable $fileFactoryKey
Definition: LocalRepo.php:41
LocalRepo\findBySha1s
findBySha1s(array $hashes)
Get an array of arrays or iterators of file objects for files that have the given SHA-1 content hashe...
Definition: LocalRepo.php:420
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:454
$wgFavicon
$wgFavicon
The URL path of the shortcut icon.
Definition: DefaultSettings.php:369
LocalRepo\findFilesByPrefix
findFilesByPrefix( $prefix, $limit)
Return an array of files where the name starts with $prefix.
Definition: LocalRepo.php:453
LocalRepo\checkRedirect
checkRedirect(Title $title)
Checks if there is a redirect named as $title.
Definition: LocalRepo.php:204
LocalFile\getQueryInfo
static getQueryInfo(array $options=[])
Return the tables, fields, and join conditions to be selected to create a new localfile object.
Definition: LocalFile.php:227
Title
Represents a title within MediaWiki.
Definition: Title.php:46
LocalRepo\cleanupDeletedBatch
cleanupDeletedBatch(array $storageKeys)
Delete files in the deleted directory if they are not referenced in the filearchive table.
Definition: LocalRepo.php:107
$path
$path
Definition: NoLocalSettings.php:25
LocalRepo\deleteBatch
deleteBatch(array $sourceDestPairs)
Move a group of files to the deletion archive.
Definition: LocalRepo.php:586
LocalRepo\findBySha1
findBySha1( $hash)
Get an array or iterator of file objects for files that have a given SHA-1 content hash.
Definition: LocalRepo.php:390
$ext
if(!is_readable( $file)) $ext
Definition: router.php:48
$hashes
$hashes
Definition: testCompression.php:71
File\DELETED_FILE
const DELETED_FILE
Definition: File.php:67
LocalRepo\skipWriteOperationIfSha1
skipWriteOperationIfSha1( $function, array $args)
Skips the write operation if storage is sha1-based, executes it normally otherwise.
Definition: LocalRepo.php:597
NS_FILE
const NS_FILE
Definition: Defines.php:69
LocalRepo\__construct
__construct(array $info=null)
Definition: LocalRepo.php:56
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:56
LocalRepo\hasAcessibleSharedCache
hasAcessibleSharedCache()
Check whether the repo has a shared cache, accessible from the current site context.
Definition: LocalRepo.php:509
OldLocalFile\newFromArchiveName
static newFromArchiveName( $title, $repo, $archiveName)
Stable to override.
Definition: OldLocalFile.php:67
LocalRepo\publishBatch
publishBatch(array $ntuples, $flags=0)
Publish a batch of files.
Definition: LocalRepo.php:578
FileRepo\getDeletedHashPath
getDeletedHashPath( $key)
Get a relative path for a deletion archive key, e.g.
Definition: FileRepo.php:1555
FileRepo\assertWritableRepo
assertWritableRepo()
Throw an exception if this repo is read-only by design.
Definition: FileRepo.php:1964
FileRepo\NAME_AND_TIME_ONLY
const NAME_AND_TIME_ONLY
Definition: FileRepo.php:47
FileBackendDBRepoWrapper
Proxy backend that manages file layout rewriting for FileRepo.
Definition: FileBackendDBRepoWrapper.php:41
LocalRepo
A repository that stores files in the local filesystem and registers them in the wiki's own database.
Definition: LocalRepo.php:37
wfExpandUrl
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Definition: GlobalFunctions.php:494
LocalRepo\$dbDomain
string $dbDomain
DB domain of the repo wiki.
Definition: LocalRepo.php:52
LocalRepo\$fileFromRowFactory
callable $fileFromRowFactory
Definition: LocalRepo.php:43