MediaWiki  master
LocalRepo.php
Go to the documentation of this file.
1 <?php
31 
41 class LocalRepo extends FileRepo {
43  protected $fileFactory = [ LocalFile::class, 'newFromTitle' ];
45  protected $fileFactoryKey = [ LocalFile::class, 'newFromKey' ];
47  protected $fileFromRowFactory = [ LocalFile::class, 'newFromRow' ];
49  protected $oldFileFromRowFactory = [ OldLocalFile::class, 'newFromRow' ];
51  protected $oldFileFactory = [ OldLocalFile::class, 'newFromTitle' ];
53  protected $oldFileFactoryKey = [ OldLocalFile::class, 'newFromKey' ];
54 
56  protected $dbDomain;
59 
61  protected $blobStore;
62 
64  protected $useJsonMetadata = true;
65 
67  protected $useSplitMetadata = false;
68 
70  protected $splitMetadataThreshold = 1000;
71 
73  protected $updateCompatibleMetadata = false;
74 
76  protected $reserializeMetadata = false;
77 
78  public function __construct( array $info = null ) {
79  parent::__construct( $info );
80 
81  $this->dbDomain = WikiMap::getCurrentWikiDbDomain();
82  $this->hasAccessibleSharedCache = true;
83 
84  $this->hasSha1Storage = ( $info['storageLayout'] ?? null ) === 'sha1';
85 
86  if ( $this->hasSha1Storage() ) {
87  $this->backend = new FileBackendDBRepoWrapper( [
88  'backend' => $this->backend,
89  'repoName' => $this->name,
90  'dbHandleFactory' => $this->getDBFactory()
91  ] );
92  }
93 
94  foreach (
95  [
96  'useJsonMetadata',
97  'useSplitMetadata',
98  'splitMetadataThreshold',
99  'updateCompatibleMetadata',
100  'reserializeMetadata',
101  ] as $option
102  ) {
103  if ( isset( $info[$option] ) ) {
104  $this->$option = $info[$option];
105  }
106  }
107  }
108 
114  public function newFileFromRow( $row ) {
115  if ( isset( $row->img_name ) ) {
116  return call_user_func( $this->fileFromRowFactory, $row, $this );
117  } elseif ( isset( $row->oi_name ) ) {
118  return call_user_func( $this->oldFileFromRowFactory, $row, $this );
119  } else {
120  throw new MWException( __METHOD__ . ': invalid row' );
121  }
122  }
123 
129  public function newFromArchiveName( $title, $archiveName ) {
131  return OldLocalFile::newFromArchiveName( $title, $this, $archiveName );
132  }
133 
144  public function cleanupDeletedBatch( array $storageKeys ) {
145  if ( $this->hasSha1Storage() ) {
146  wfDebug( __METHOD__ . ": skipped because storage uses sha1 paths" );
147  return Status::newGood();
148  }
149 
150  $backend = $this->backend; // convenience
151  $root = $this->getZonePath( 'deleted' );
152  $dbw = $this->getPrimaryDB();
153  $status = $this->newGood();
154  $storageKeys = array_unique( $storageKeys );
155  foreach ( $storageKeys as $key ) {
156  $hashPath = $this->getDeletedHashPath( $key );
157  $path = "$root/$hashPath$key";
158  $dbw->startAtomic( __METHOD__ );
159  // Check for usage in deleted/hidden files and preemptively
160  // lock the key to avoid any future use until we are finished.
161  $deleted = $this->deletedFileHasKey( $key, 'lock' );
162  $hidden = $this->hiddenFileHasKey( $key, 'lock' );
163  if ( !$deleted && !$hidden ) { // not in use now
164  wfDebug( __METHOD__ . ": deleting $key" );
165  $op = [ 'op' => 'delete', 'src' => $path ];
166  if ( !$backend->doOperation( $op )->isOK() ) {
167  $status->error( 'undelete-cleanup-error', $path );
168  $status->failCount++;
169  }
170  } else {
171  wfDebug( __METHOD__ . ": $key still in use" );
172  $status->successCount++;
173  }
174  $dbw->endAtomic( __METHOD__ );
175  }
176 
177  return $status;
178  }
179 
187  protected function deletedFileHasKey( $key, $lock = null ) {
188  $dbw = $this->getPrimaryDB();
189  return (bool)$dbw->selectField( 'filearchive', '1',
190  [ 'fa_storage_group' => 'deleted', 'fa_storage_key' => $key ],
191  __METHOD__,
192  $lock === 'lock' ? [ 'FOR UPDATE' ] : []
193  );
194  }
195 
203  protected function hiddenFileHasKey( $key, $lock = null ) {
204  $sha1 = self::getHashFromKey( $key );
205  $ext = File::normalizeExtension( substr( $key, strcspn( $key, '.' ) + 1 ) );
206 
207  $dbw = $this->getPrimaryDB();
208  return (bool)$dbw->selectField( 'oldimage', '1',
209  [
210  'oi_sha1' => $sha1,
211  'oi_archive_name ' . $dbw->buildLike( $dbw->anyString(), ".$ext" ),
212  $dbw->bitAnd( 'oi_deleted', File::DELETED_FILE ) => File::DELETED_FILE,
213  ],
214  __METHOD__,
215  $lock === 'lock' ? [ 'FOR UPDATE' ] : []
216  );
217  }
218 
225  public static function getHashFromKey( $key ) {
226  $sha1 = strtok( $key, '.' );
227  if ( is_string( $sha1 ) && strlen( $sha1 ) === 32 && $sha1[0] === '0' ) {
228  $sha1 = substr( $sha1, 1 );
229  }
230  return $sha1;
231  }
232 
239  public function checkRedirect( $title ) {
240  $title = File::normalizeTitle( $title, 'exception' );
241 
242  $memcKey = $this->getSharedCacheKey( 'file-redirect', md5( $title->getDBkey() ) );
243  if ( $memcKey === false ) {
244  $memcKey = $this->getLocalCacheKey( 'file-redirect', md5( $title->getDBkey() ) );
245  $expiry = 300; // no invalidation, 5 minutes
246  } else {
247  $expiry = 86400; // has invalidation, 1 day
248  }
249 
250  $method = __METHOD__;
251  $redirDbKey = $this->wanCache->getWithSetCallback(
252  $memcKey,
253  $expiry,
254  function ( $oldValue, &$ttl, array &$setOpts ) use ( $method, $title ) {
255  $dbr = $this->getReplicaDB(); // possibly remote DB
256 
257  $setOpts += Database::getCacheSetOptions( $dbr );
258 
259  $row = $dbr->selectRow(
260  [ 'page', 'redirect' ],
261  [ 'rd_namespace', 'rd_title' ],
262  [
263  'page_namespace' => $title->getNamespace(),
264  'page_title' => $title->getDBkey(),
265  'rd_from = page_id'
266  ],
267  $method
268  );
269 
270  return ( $row && $row->rd_namespace == NS_FILE )
271  ? Title::makeTitle( $row->rd_namespace, $row->rd_title )->getDBkey()
272  : ''; // negative cache
273  },
274  [ 'pcTTL' => WANObjectCache::TTL_PROC_LONG ]
275  );
276 
277  // @note: also checks " " for b/c
278  if ( $redirDbKey !== ' ' && strval( $redirDbKey ) !== '' ) {
279  // Page is a redirect to another file
280  return Title::newFromText( $redirDbKey, NS_FILE );
281  }
282 
283  return false; // no redirect
284  }
285 
286  public function findFiles( array $items, $flags = 0 ) {
287  $finalFiles = []; // map of (DB key => corresponding File) for matches
288 
289  $searchSet = []; // map of (normalized DB key => search params)
290  foreach ( $items as $item ) {
291  if ( is_array( $item ) ) {
292  $title = File::normalizeTitle( $item['title'] );
293  if ( $title ) {
294  $searchSet[$title->getDBkey()] = $item;
295  }
296  } else {
297  $title = File::normalizeTitle( $item );
298  if ( $title ) {
299  $searchSet[$title->getDBkey()] = [];
300  }
301  }
302  }
303 
304  $fileMatchesSearch = static function ( File $file, array $search ) {
305  // Note: file name comparison done elsewhere (to handle redirects)
306 
307  // Fallback to RequestContext::getMain should be replaced with a better
308  // way of setting the user that should be used; currently it needs to be
309  // set for each file individually. See T263033#6477586
310  $contextPerformer = RequestContext::getMain()->getAuthority();
311  $performer = ( !empty( $search['private'] ) && $search['private'] instanceof Authority )
312  ? $search['private']
313  : $contextPerformer;
314 
315  return (
316  $file->exists() &&
317  (
318  ( empty( $search['time'] ) && !$file->isOld() ) ||
319  ( !empty( $search['time'] ) && $search['time'] === $file->getTimestamp() )
320  ) &&
321  ( !empty( $search['private'] ) || !$file->isDeleted( File::DELETED_FILE ) ) &&
322  $file->userCan( File::DELETED_FILE, $performer )
323  );
324  };
325 
326  $applyMatchingFiles = function ( IResultWrapper $res, &$searchSet, &$finalFiles )
327  use ( $fileMatchesSearch, $flags )
328  {
329  $contLang = MediaWikiServices::getInstance()->getContentLanguage();
330  $info = $this->getInfo();
331  foreach ( $res as $row ) {
332  $file = $this->newFileFromRow( $row );
333  // There must have been a search for this DB key, but this has to handle the
334  // cases were title capitalization is different on the client and repo wikis.
335  $dbKeysLook = [ strtr( $file->getName(), ' ', '_' ) ];
336  if ( !empty( $info['initialCapital'] ) ) {
337  // Search keys for "hi.png" and "Hi.png" should use the "Hi.png file"
338  $dbKeysLook[] = $contLang->lcfirst( $file->getName() );
339  }
340  foreach ( $dbKeysLook as $dbKey ) {
341  if ( isset( $searchSet[$dbKey] )
342  && $fileMatchesSearch( $file, $searchSet[$dbKey] )
343  ) {
344  $finalFiles[$dbKey] = ( $flags & FileRepo::NAME_AND_TIME_ONLY )
345  ? [ 'title' => $dbKey, 'timestamp' => $file->getTimestamp() ]
346  : $file;
347  unset( $searchSet[$dbKey] );
348  }
349  }
350  }
351  };
352 
353  $dbr = $this->getReplicaDB();
354 
355  // Query image table
356  $imgNames = [];
357  foreach ( array_keys( $searchSet ) as $dbKey ) {
358  $imgNames[] = $this->getNameFromTitle( File::normalizeTitle( $dbKey ) );
359  }
360 
361  if ( count( $imgNames ) ) {
362  $fileQuery = LocalFile::getQueryInfo();
363  $res = $dbr->select( $fileQuery['tables'], $fileQuery['fields'], [ 'img_name' => $imgNames ],
364  __METHOD__, [], $fileQuery['joins'] );
365  $applyMatchingFiles( $res, $searchSet, $finalFiles );
366  }
367 
368  // Query old image table
369  $oiConds = []; // WHERE clause array for each file
370  foreach ( $searchSet as $dbKey => $search ) {
371  if ( isset( $search['time'] ) ) {
372  $oiConds[] = $dbr->makeList(
373  [
374  'oi_name' => $this->getNameFromTitle( File::normalizeTitle( $dbKey ) ),
375  'oi_timestamp' => $dbr->timestamp( $search['time'] )
376  ],
377  LIST_AND
378  );
379  }
380  }
381 
382  if ( count( $oiConds ) ) {
383  $fileQuery = OldLocalFile::getQueryInfo();
384  $res = $dbr->select( $fileQuery['tables'], $fileQuery['fields'],
385  $dbr->makeList( $oiConds, LIST_OR ),
386  __METHOD__, [], $fileQuery['joins'] );
387  $applyMatchingFiles( $res, $searchSet, $finalFiles );
388  }
389 
390  // Check for redirects...
391  foreach ( $searchSet as $dbKey => $search ) {
392  if ( !empty( $search['ignoreRedirect'] ) ) {
393  continue;
394  }
395 
396  $title = File::normalizeTitle( $dbKey );
397  $redir = $this->checkRedirect( $title ); // hopefully hits memcached
398 
399  if ( $redir && $redir->getNamespace() === NS_FILE ) {
400  $file = $this->newFile( $redir );
401  if ( $file && $fileMatchesSearch( $file, $search ) ) {
402  $file->redirectedFrom( $title->getDBkey() );
403  if ( $flags & FileRepo::NAME_AND_TIME_ONLY ) {
404  $finalFiles[$dbKey] = [
405  'title' => $file->getTitle()->getDBkey(),
406  'timestamp' => $file->getTimestamp()
407  ];
408  } else {
409  $finalFiles[$dbKey] = $file;
410  }
411  }
412  }
413  }
414 
415  return $finalFiles;
416  }
417 
425  public function findBySha1( $hash ) {
426  $dbr = $this->getReplicaDB();
427  $fileQuery = LocalFile::getQueryInfo();
428  $res = $dbr->select(
429  $fileQuery['tables'],
430  $fileQuery['fields'],
431  [ 'img_sha1' => $hash ],
432  __METHOD__,
433  [ 'ORDER BY' => 'img_name' ],
434  $fileQuery['joins']
435  );
436 
437  $result = [];
438  foreach ( $res as $row ) {
439  $result[] = $this->newFileFromRow( $row );
440  }
441  $res->free();
442 
443  return $result;
444  }
445 
455  public function findBySha1s( array $hashes ) {
456  if ( $hashes === [] ) {
457  return []; // empty parameter
458  }
459 
460  $dbr = $this->getReplicaDB();
461  $fileQuery = LocalFile::getQueryInfo();
462  $res = $dbr->select(
463  $fileQuery['tables'],
464  $fileQuery['fields'],
465  [ 'img_sha1' => $hashes ],
466  __METHOD__,
467  [ 'ORDER BY' => 'img_name' ],
468  $fileQuery['joins']
469  );
470 
471  $result = [];
472  foreach ( $res as $row ) {
473  $file = $this->newFileFromRow( $row );
474  $result[$file->getSha1()][] = $file;
475  }
476  $res->free();
477 
478  return $result;
479  }
480 
488  public function findFilesByPrefix( $prefix, $limit ) {
489  $selectOptions = [ 'ORDER BY' => 'img_name', 'LIMIT' => intval( $limit ) ];
490 
491  // Query database
492  $dbr = $this->getReplicaDB();
493  $fileQuery = LocalFile::getQueryInfo();
494  $res = $dbr->select(
495  $fileQuery['tables'],
496  $fileQuery['fields'],
497  'img_name ' . $dbr->buildLike( $prefix, $dbr->anyString() ),
498  __METHOD__,
499  $selectOptions,
500  $fileQuery['joins']
501  );
502 
503  // Build file objects
504  $files = [];
505  foreach ( $res as $row ) {
506  $files[] = $this->newFileFromRow( $row );
507  }
508 
509  return $files;
510  }
511 
516  public function getReplicaDB() {
517  return wfGetDB( DB_REPLICA );
518  }
519 
525  public function getPrimaryDB() {
526  return wfGetDB( DB_PRIMARY );
527  }
528 
533  protected function getDBFactory() {
534  return static function ( $index ) {
535  return wfGetDB( $index );
536  };
537  }
538 
545  protected function hasAcessibleSharedCache() {
547  }
548 
549  public function getSharedCacheKey( $kClassSuffix, ...$components ) {
550  // T267668: do not include the repo name in the key
551  return $this->hasAcessibleSharedCache()
552  ? $this->wanCache->makeGlobalKey(
553  'filerepo-' . $kClassSuffix,
554  $this->dbDomain,
555  ...$components
556  )
557  : false;
558  }
559 
566  public function invalidateImageRedirect( $title ) {
567  $key = $this->getSharedCacheKey( 'file-redirect', md5( $title->getDBkey() ) );
568  if ( $key ) {
569  $this->getPrimaryDB()->onTransactionPreCommitOrIdle(
570  function () use ( $key ) {
571  $this->wanCache->delete( $key );
572  },
573  __METHOD__
574  );
575  }
576  }
577 
578  public function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) {
579  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
580  }
581 
582  public function storeBatch( array $triplets, $flags = 0 ) {
583  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
584  }
585 
586  public function cleanupBatch( array $files, $flags = 0 ) {
587  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
588  }
589 
590  public function publish(
591  $src,
592  $dstRel,
593  $archiveRel,
594  $flags = 0,
595  array $options = []
596  ) {
597  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
598  }
599 
600  public function publishBatch( array $ntuples, $flags = 0 ) {
601  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
602  }
603 
604  public function delete( $srcRel, $archiveRel ) {
605  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
606  }
607 
608  public function deleteBatch( array $sourceDestPairs ) {
609  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
610  }
611 
619  protected function skipWriteOperationIfSha1( $function, array $args ) {
620  $this->assertWritableRepo(); // fail out if read-only
621 
622  if ( $this->hasSha1Storage() ) {
623  wfDebug( __METHOD__ . ": skipped because storage uses sha1 paths" );
624  return Status::newGood();
625  } else {
626  return parent::$function( ...$args );
627  }
628  }
629 
639  public function isJsonMetadataEnabled() {
640  return $this->useJsonMetadata;
641  }
642 
649  public function isSplitMetadataEnabled() {
651  }
652 
659  public function getSplitMetadataThreshold() {
661  }
662 
663  public function isMetadataUpdateEnabled() {
665  }
666 
667  public function isMetadataReserializeEnabled() {
669  }
670 
677  public function getBlobStore(): ?BlobStore {
678  if ( !$this->blobStore ) {
679  $this->blobStore = MediaWikiServices::getInstance()->getBlobStoreFactory()
680  ->newBlobStore( $this->dbDomain );
681  }
682  return $this->blobStore;
683  }
684 }
const NS_FILE
Definition: Defines.php:70
const LIST_OR
Definition: Defines.php:46
const LIST_AND
Definition: Defines.php:43
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
if(!defined('MW_SETUP_CALLBACK'))
Definition: WebStart.php:88
Proxy backend that manages file layout rewriting for FileRepo.
doOperation(array $op, array $opts=[])
Same as doOperations() except it takes a single operation.
Base class for file repositories.
Definition: FileRepo.php:48
assertWritableRepo()
Throw an exception if this repo is read-only by design.
Definition: FileRepo.php:1964
newGood( $value=null)
Create a new good result.
Definition: FileRepo.php:1807
const NAME_AND_TIME_ONLY
Definition: FileRepo.php:54
getLocalCacheKey( $kClassSuffix,... $components)
Get a site-local, repository-qualified, WAN cache key.
Definition: FileRepo.php:1903
hasSha1Storage()
Returns whether or not storage is SHA-1 based.
Definition: FileRepo.php:2009
FileBackend $backend
Definition: FileRepo.php:71
getZonePath( $zone)
Get the storage path corresponding to one of the zones.
Definition: FileRepo.php:396
getDeletedHashPath( $key)
Get a relative path for a deletion archive key, e.g.
Definition: FileRepo.php:1557
getNameFromTitle( $title)
Get the name of a file from its title.
Definition: FileRepo.php:714
newFile( $title, $time=false)
Create a new File object from the local repository.
Definition: FileRepo.php:420
getInfo()
Return information about the repository.
Definition: FileRepo.php:1973
Implements some public methods and some protected utility functions which are required by multiple ch...
Definition: File.php:68
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:207
const DELETED_FILE
Definition: File.php:72
static normalizeExtension( $extension)
Normalize a file extension to the common form, making it lowercase and checking some synonyms,...
Definition: File.php:256
static getQueryInfo(array $options=[])
Return the tables, fields, and join conditions to be selected to create a new localfile object.
Definition: LocalFile.php:272
Local repository that stores files in the local filesystem and registers them in the wiki's own datab...
Definition: LocalRepo.php:41
skipWriteOperationIfSha1( $function, array $args)
Skips the write operation if storage is sha1-based, executes it normally otherwise.
Definition: LocalRepo.php:619
int null $splitMetadataThreshold
Definition: LocalRepo.php:70
getDBFactory()
Get a callback to get a DB handle given an index (DB_REPLICA/DB_PRIMARY)
Definition: LocalRepo.php:533
getSharedCacheKey( $kClassSuffix,... $components)
Get a global, repository-qualified, WAN cache key.
Definition: LocalRepo.php:549
isMetadataUpdateEnabled()
Definition: LocalRepo.php:663
newFileFromRow( $row)
Definition: LocalRepo.php:114
isSplitMetadataEnabled()
Returns true if files should split up large metadata, storing parts of it in the BlobStore.
Definition: LocalRepo.php:649
deletedFileHasKey( $key, $lock=null)
Check if a deleted (filearchive) file has this sha1 key.
Definition: LocalRepo.php:187
callable $oldFileFactoryKey
Definition: LocalRepo.php:53
callable $oldFileFactory
Definition: LocalRepo.php:51
isJsonMetadataEnabled()
Returns true if files should store metadata in JSON format.
Definition: LocalRepo.php:639
cleanupBatch(array $files, $flags=0)
Deletes a batch of files.
Definition: LocalRepo.php:586
publishBatch(array $ntuples, $flags=0)
Publish a batch of files.
Definition: LocalRepo.php:600
findFiles(array $items, $flags=0)
Find many files at once.
Definition: LocalRepo.php:286
findFilesByPrefix( $prefix, $limit)
Return an array of files where the name starts with $prefix.
Definition: LocalRepo.php:488
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:455
getBlobStore()
Get a BlobStore for storing and retrieving large metadata, or null if that can't be done.
Definition: LocalRepo.php:677
callable $oldFileFromRowFactory
Definition: LocalRepo.php:49
string $dbDomain
DB domain of the repo wiki.
Definition: LocalRepo.php:56
BlobStore $blobStore
Definition: LocalRepo.php:61
bool $useJsonMetadata
Definition: LocalRepo.php:64
invalidateImageRedirect( $title)
Invalidates image redirect cache related to that image.
Definition: LocalRepo.php:566
cleanupDeletedBatch(array $storageKeys)
Delete files in the deleted directory if they are not referenced in the filearchive table.
Definition: LocalRepo.php:144
bool $updateCompatibleMetadata
Definition: LocalRepo.php:73
getPrimaryDB()
Get a connection to the primary DB.
Definition: LocalRepo.php:525
checkRedirect( $title)
Checks if there is a redirect named as $title.
Definition: LocalRepo.php:239
hasAcessibleSharedCache()
Check whether the repo has a shared cache, accessible from the current site context.
Definition: LocalRepo.php:545
bool $hasAccessibleSharedCache
Whether shared cache keys are exposed/accessible.
Definition: LocalRepo.php:58
callable $fileFactoryKey
Definition: LocalRepo.php:45
getReplicaDB()
Get a connection to the replica DB.
Definition: LocalRepo.php:516
store( $srcPath, $dstZone, $dstRel, $flags=0)
Store a file to a given destination.
Definition: LocalRepo.php:578
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:590
storeBatch(array $triplets, $flags=0)
Store a batch of files.
Definition: LocalRepo.php:582
getSplitMetadataThreshold()
Get the threshold above which metadata items should be split into separate storage,...
Definition: LocalRepo.php:659
callable $fileFromRowFactory
Definition: LocalRepo.php:47
__construct(array $info=null)
Definition: LocalRepo.php:78
deleteBatch(array $sourceDestPairs)
Move a group of files to the deletion archive.
Definition: LocalRepo.php:608
hiddenFileHasKey( $key, $lock=null)
Check if a hidden (revision delete) file has this sha1 key.
Definition: LocalRepo.php:203
static getHashFromKey( $key)
Gets the SHA1 hash from a storage key.
Definition: LocalRepo.php:225
newFromArchiveName( $title, $archiveName)
Definition: LocalRepo.php:129
bool $reserializeMetadata
Definition: LocalRepo.php:76
isMetadataReserializeEnabled()
Definition: LocalRepo.php:667
callable $fileFactory
Definition: LocalRepo.php:43
bool $useSplitMetadata
Definition: LocalRepo.php:67
findBySha1( $hash)
Get an array or iterator of file objects for files that have a given SHA-1 content hash.
Definition: LocalRepo.php:425
MediaWiki exception.
Definition: MWException.php:32
Service locator for MediaWiki core services.
Represents a title within MediaWiki.
Definition: Title.php:82
Helper tools for dealing with other locally-hosted wikis.
Definition: WikiMap.php:33
static newFromArchiveName( $title, $repo, $archiveName)
static getQueryInfo(array $options=[])
Return the tables, fields, and join conditions to be selected to create a new oldlocalfile object.
static getMain()
Get the RequestContext object associated with the main request.
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:85
Interface for objects (potentially) representing an editable wiki page.
This interface represents the authority associated the current execution context, such as a web reque...
Definition: Authority.php:37
Service for loading and storing data blobs.
Definition: BlobStore.php:33
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:36
Result wrapper for grabbing data queried from an IDatabase object.
const DB_REPLICA
Definition: defines.php:26
const DB_PRIMARY
Definition: defines.php:28
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition: router.php:42
if(!is_readable( $file)) $ext
Definition: router.php:48