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 
51  public function __construct( array $info = null ) {
52  parent::__construct( $info );
53 
54  $this->hasSha1Storage = isset( $info['storageLayout'] )
55  && $info['storageLayout'] === 'sha1';
56 
57  if ( $this->hasSha1Storage() ) {
58  $this->backend = new FileBackendDBRepoWrapper( [
59  'backend' => $this->backend,
60  'repoName' => $this->name,
61  'dbHandleFactory' => $this->getDBFactory()
62  ] );
63  }
64  }
65 
71  public function newFileFromRow( $row ) {
72  if ( isset( $row->img_name ) ) {
73  return call_user_func( $this->fileFromRowFactory, $row, $this );
74  } elseif ( isset( $row->oi_name ) ) {
75  return call_user_func( $this->oldFileFromRowFactory, $row, $this );
76  } else {
77  throw new MWException( __METHOD__ . ': invalid row' );
78  }
79  }
80 
86  public function newFromArchiveName( $title, $archiveName ) {
87  return OldLocalFile::newFromArchiveName( $title, $this, $archiveName );
88  }
89 
100  public function cleanupDeletedBatch( array $storageKeys ) {
101  if ( $this->hasSha1Storage() ) {
102  wfDebug( __METHOD__ . ": skipped because storage uses sha1 paths" );
103  return Status::newGood();
104  }
105 
106  $backend = $this->backend; // convenience
107  $root = $this->getZonePath( 'deleted' );
108  $dbw = $this->getMasterDB();
109  $status = $this->newGood();
110  $storageKeys = array_unique( $storageKeys );
111  foreach ( $storageKeys as $key ) {
112  $hashPath = $this->getDeletedHashPath( $key );
113  $path = "$root/$hashPath$key";
114  $dbw->startAtomic( __METHOD__ );
115  // Check for usage in deleted/hidden files and preemptively
116  // lock the key to avoid any future use until we are finished.
117  $deleted = $this->deletedFileHasKey( $key, 'lock' );
118  $hidden = $this->hiddenFileHasKey( $key, 'lock' );
119  if ( !$deleted && !$hidden ) { // not in use now
120  wfDebug( __METHOD__ . ": deleting $key" );
121  $op = [ 'op' => 'delete', 'src' => $path ];
122  if ( !$backend->doOperation( $op )->isOK() ) {
123  $status->error( 'undelete-cleanup-error', $path );
124  $status->failCount++;
125  }
126  } else {
127  wfDebug( __METHOD__ . ": $key still in use" );
128  $status->successCount++;
129  }
130  $dbw->endAtomic( __METHOD__ );
131  }
132 
133  return $status;
134  }
135 
143  protected function deletedFileHasKey( $key, $lock = null ) {
144  $options = ( $lock === 'lock' ) ? [ 'FOR UPDATE' ] : [];
145 
146  $dbw = $this->getMasterDB();
147 
148  return (bool)$dbw->selectField( 'filearchive', '1',
149  [ 'fa_storage_group' => 'deleted', 'fa_storage_key' => $key ],
150  __METHOD__, $options
151  );
152  }
153 
161  protected function hiddenFileHasKey( $key, $lock = null ) {
162  $options = ( $lock === 'lock' ) ? [ 'FOR UPDATE' ] : [];
163 
164  $sha1 = self::getHashFromKey( $key );
165  $ext = File::normalizeExtension( substr( $key, strcspn( $key, '.' ) + 1 ) );
166 
167  $dbw = $this->getMasterDB();
168 
169  return (bool)$dbw->selectField( 'oldimage', '1',
170  [ 'oi_sha1' => $sha1,
171  'oi_archive_name ' . $dbw->buildLike( $dbw->anyString(), ".$ext" ),
172  $dbw->bitAnd( 'oi_deleted', File::DELETED_FILE ) => File::DELETED_FILE ],
173  __METHOD__, $options
174  );
175  }
176 
183  public static function getHashFromKey( $key ) {
184  $sha1 = strtok( $key, '.' );
185  if ( is_string( $sha1 ) && strlen( $sha1 ) === 32 && $sha1[0] === '0' ) {
186  $sha1 = substr( $sha1, 1 );
187  }
188  return $sha1;
189  }
190 
197  public function checkRedirect( Title $title ) {
198  $title = File::normalizeTitle( $title, 'exception' );
199 
200  $memcKey = $this->getSharedCacheKey( 'file_redirect', md5( $title->getDBkey() ) );
201  if ( $memcKey === false ) {
202  $memcKey = $this->getLocalCacheKey( 'file_redirect', md5( $title->getDBkey() ) );
203  $expiry = 300; // no invalidation, 5 minutes
204  } else {
205  $expiry = 86400; // has invalidation, 1 day
206  }
207 
208  $method = __METHOD__;
209  $redirDbKey = $this->wanCache->getWithSetCallback(
210  $memcKey,
211  $expiry,
212  function ( $oldValue, &$ttl, array &$setOpts ) use ( $method, $title ) {
213  $dbr = $this->getReplicaDB(); // possibly remote DB
214 
215  $setOpts += Database::getCacheSetOptions( $dbr );
216 
217  $row = $dbr->selectRow(
218  [ 'page', 'redirect' ],
219  [ 'rd_namespace', 'rd_title' ],
220  [
221  'page_namespace' => $title->getNamespace(),
222  'page_title' => $title->getDBkey(),
223  'rd_from = page_id'
224  ],
225  $method
226  );
227 
228  return ( $row && $row->rd_namespace == NS_FILE )
229  ? Title::makeTitle( $row->rd_namespace, $row->rd_title )->getDBkey()
230  : ''; // negative cache
231  },
232  [ 'pcTTL' => WANObjectCache::TTL_PROC_LONG ]
233  );
234 
235  // @note: also checks " " for b/c
236  if ( $redirDbKey !== ' ' && strval( $redirDbKey ) !== '' ) {
237  // Page is a redirect to another file
238  return Title::newFromText( $redirDbKey, NS_FILE );
239  }
240 
241  return false; // no redirect
242  }
243 
244  public function findFiles( array $items, $flags = 0 ) {
245  $finalFiles = []; // map of (DB key => corresponding File) for matches
246 
247  $searchSet = []; // map of (normalized DB key => search params)
248  foreach ( $items as $item ) {
249  if ( is_array( $item ) ) {
250  $title = File::normalizeTitle( $item['title'] );
251  if ( $title ) {
252  $searchSet[$title->getDBkey()] = $item;
253  }
254  } else {
255  $title = File::normalizeTitle( $item );
256  if ( $title ) {
257  $searchSet[$title->getDBkey()] = [];
258  }
259  }
260  }
261 
262  $fileMatchesSearch = function ( File $file, array $search ) {
263  // Note: file name comparison done elsewhere (to handle redirects)
264 
265  // Fallback to RequestContext::getMain should be replaced with a better
266  // way of setting the user that should be used; currently it needs to be
267  // set for each file individually. See T263033#6477586
268  $contextUser = RequestContext::getMain()->getUser();
269  $user = ( !empty( $search['private'] ) && $search['private'] instanceof User )
270  ? $search['private']
271  : $contextUser;
272 
273  return (
274  $file->exists() &&
275  (
276  ( empty( $search['time'] ) && !$file->isOld() ) ||
277  ( !empty( $search['time'] ) && $search['time'] === $file->getTimestamp() )
278  ) &&
279  ( !empty( $search['private'] ) || !$file->isDeleted( File::DELETED_FILE ) ) &&
280  $file->userCan( File::DELETED_FILE, $user )
281  );
282  };
283 
284  $applyMatchingFiles = function ( IResultWrapper $res, &$searchSet, &$finalFiles )
285  use ( $fileMatchesSearch, $flags )
286  {
287  $contLang = MediaWikiServices::getInstance()->getContentLanguage();
288  $info = $this->getInfo();
289  foreach ( $res as $row ) {
290  $file = $this->newFileFromRow( $row );
291  // There must have been a search for this DB key, but this has to handle the
292  // cases were title capitalization is different on the client and repo wikis.
293  $dbKeysLook = [ strtr( $file->getName(), ' ', '_' ) ];
294  if ( !empty( $info['initialCapital'] ) ) {
295  // Search keys for "hi.png" and "Hi.png" should use the "Hi.png file"
296  $dbKeysLook[] = $contLang->lcfirst( $file->getName() );
297  }
298  foreach ( $dbKeysLook as $dbKey ) {
299  if ( isset( $searchSet[$dbKey] )
300  && $fileMatchesSearch( $file, $searchSet[$dbKey] )
301  ) {
302  $finalFiles[$dbKey] = ( $flags & FileRepo::NAME_AND_TIME_ONLY )
303  ? [ 'title' => $dbKey, 'timestamp' => $file->getTimestamp() ]
304  : $file;
305  unset( $searchSet[$dbKey] );
306  }
307  }
308  }
309  };
310 
311  $dbr = $this->getReplicaDB();
312 
313  // Query image table
314  $imgNames = [];
315  foreach ( array_keys( $searchSet ) as $dbKey ) {
316  $imgNames[] = $this->getNameFromTitle( File::normalizeTitle( $dbKey ) );
317  }
318 
319  if ( count( $imgNames ) ) {
320  $fileQuery = LocalFile::getQueryInfo();
321  $res = $dbr->select( $fileQuery['tables'], $fileQuery['fields'], [ 'img_name' => $imgNames ],
322  __METHOD__, [], $fileQuery['joins'] );
323  $applyMatchingFiles( $res, $searchSet, $finalFiles );
324  }
325 
326  // Query old image table
327  $oiConds = []; // WHERE clause array for each file
328  foreach ( $searchSet as $dbKey => $search ) {
329  if ( isset( $search['time'] ) ) {
330  $oiConds[] = $dbr->makeList(
331  [
332  'oi_name' => $this->getNameFromTitle( File::normalizeTitle( $dbKey ) ),
333  'oi_timestamp' => $dbr->timestamp( $search['time'] )
334  ],
335  LIST_AND
336  );
337  }
338  }
339 
340  if ( count( $oiConds ) ) {
341  $fileQuery = OldLocalFile::getQueryInfo();
342  $res = $dbr->select( $fileQuery['tables'], $fileQuery['fields'],
343  $dbr->makeList( $oiConds, LIST_OR ),
344  __METHOD__, [], $fileQuery['joins'] );
345  $applyMatchingFiles( $res, $searchSet, $finalFiles );
346  }
347 
348  // Check for redirects...
349  foreach ( $searchSet as $dbKey => $search ) {
350  if ( !empty( $search['ignoreRedirect'] ) ) {
351  continue;
352  }
353 
354  $title = File::normalizeTitle( $dbKey );
355  $redir = $this->checkRedirect( $title ); // hopefully hits memcached
356 
357  if ( $redir && $redir->getNamespace() === NS_FILE ) {
358  $file = $this->newFile( $redir );
359  if ( $file && $fileMatchesSearch( $file, $search ) ) {
360  $file->redirectedFrom( $title->getDBkey() );
361  if ( $flags & FileRepo::NAME_AND_TIME_ONLY ) {
362  $finalFiles[$dbKey] = [
363  'title' => $file->getTitle()->getDBkey(),
364  'timestamp' => $file->getTimestamp()
365  ];
366  } else {
367  $finalFiles[$dbKey] = $file;
368  }
369  }
370  }
371  }
372 
373  return $finalFiles;
374  }
375 
383  public function findBySha1( $hash ) {
384  $dbr = $this->getReplicaDB();
385  $fileQuery = LocalFile::getQueryInfo();
386  $res = $dbr->select(
387  $fileQuery['tables'],
388  $fileQuery['fields'],
389  [ 'img_sha1' => $hash ],
390  __METHOD__,
391  [ 'ORDER BY' => 'img_name' ],
392  $fileQuery['joins']
393  );
394 
395  $result = [];
396  foreach ( $res as $row ) {
397  $result[] = $this->newFileFromRow( $row );
398  }
399  $res->free();
400 
401  return $result;
402  }
403 
413  public function findBySha1s( array $hashes ) {
414  if ( $hashes === [] ) {
415  return []; // empty parameter
416  }
417 
418  $dbr = $this->getReplicaDB();
419  $fileQuery = LocalFile::getQueryInfo();
420  $res = $dbr->select(
421  $fileQuery['tables'],
422  $fileQuery['fields'],
423  [ 'img_sha1' => $hashes ],
424  __METHOD__,
425  [ 'ORDER BY' => 'img_name' ],
426  $fileQuery['joins']
427  );
428 
429  $result = [];
430  foreach ( $res as $row ) {
431  $file = $this->newFileFromRow( $row );
432  $result[$file->getSha1()][] = $file;
433  }
434  $res->free();
435 
436  return $result;
437  }
438 
446  public function findFilesByPrefix( $prefix, $limit ) {
447  $selectOptions = [ 'ORDER BY' => 'img_name', 'LIMIT' => intval( $limit ) ];
448 
449  // Query database
450  $dbr = $this->getReplicaDB();
451  $fileQuery = LocalFile::getQueryInfo();
452  $res = $dbr->select(
453  $fileQuery['tables'],
454  $fileQuery['fields'],
455  'img_name ' . $dbr->buildLike( $prefix, $dbr->anyString() ),
456  __METHOD__,
457  $selectOptions,
458  $fileQuery['joins']
459  );
460 
461  // Build file objects
462  $files = [];
463  foreach ( $res as $row ) {
464  $files[] = $this->newFileFromRow( $row );
465  }
466 
467  return $files;
468  }
469 
474  public function getReplicaDB() {
475  return wfGetDB( DB_REPLICA );
476  }
477 
482  public function getMasterDB() {
483  return wfGetDB( DB_MASTER );
484  }
485 
490  protected function getDBFactory() {
491  return function ( $index ) {
492  return wfGetDB( $index );
493  };
494  }
495 
504  public function getSharedCacheKey( ...$args ) {
505  return $this->wanCache->makeGlobalKey(
507  ...$args
508  );
509  }
510 
517  public function invalidateImageRedirect( Title $title ) {
518  $key = $this->getSharedCacheKey( 'file_redirect', md5( $title->getDBkey() ) );
519  if ( $key ) {
520  $this->getMasterDB()->onTransactionPreCommitOrIdle(
521  function () use ( $key ) {
522  $this->wanCache->delete( $key );
523  },
524  __METHOD__
525  );
526  }
527  }
528 
535  public function getInfo() {
536  global $wgFavicon;
537 
538  return array_merge( parent::getInfo(), [
539  'favicon' => wfExpandUrl( $wgFavicon ),
540  ] );
541  }
542 
543  public function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) {
544  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
545  }
546 
547  public function storeBatch( array $triplets, $flags = 0 ) {
548  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
549  }
550 
551  public function cleanupBatch( array $files, $flags = 0 ) {
552  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
553  }
554 
555  public function publish(
556  $src,
557  $dstRel,
558  $archiveRel,
559  $flags = 0,
560  array $options = []
561  ) {
562  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
563  }
564 
565  public function publishBatch( array $ntuples, $flags = 0 ) {
566  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
567  }
568 
569  public function delete( $srcRel, $archiveRel ) {
570  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
571  }
572 
573  public function deleteBatch( array $sourceDestPairs ) {
574  return $this->skipWriteOperationIfSha1( __FUNCTION__, func_get_args() );
575  }
576 
584  protected function skipWriteOperationIfSha1( $function, array $args ) {
585  $this->assertWritableRepo(); // fail out if read-only
586 
587  if ( $this->hasSha1Storage() ) {
588  wfDebug( __METHOD__ . ": skipped because storage uses sha1 paths" );
589  return Status::newGood();
590  } else {
591  return parent::$function( ...$args );
592  }
593  }
594 }
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:328
LocalRepo\getInfo
getInfo()
Return information about the repository.
Definition: LocalRepo.php:535
WikiMap\getCurrentWikiDbDomain
static getCurrentWikiDbDomain()
Definition: WikiMap.php:293
LocalRepo\newFileFromRow
newFileFromRow( $row)
Definition: LocalRepo.php:71
LocalRepo\getSharedCacheKey
getSharedCacheKey(... $args)
Get a key on the primary cache for this repository.
Definition: LocalRepo.php:504
FileRepo\newGood
newGood( $value=null)
Create a new good result.
Definition: FileRepo.php:1807
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:160
LocalRepo\getMasterDB
getMasterDB()
Get a connection to the master DB.
Definition: LocalRepo.php:482
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:474
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:555
LocalRepo\deletedFileHasKey
deletedFileHasKey( $key, $lock=null)
Check if a deleted (filearchive) file has this sha1 key.
Definition: LocalRepo.php:143
LocalRepo\$oldFileFactoryKey
callable $oldFileFactoryKey
Definition: LocalRepo.php:49
NS_FILE
const NS_FILE
Definition: Defines.php:75
$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:161
LocalRepo\getHashFromKey
static getHashFromKey( $key)
Gets the SHA1 hash from a storage key.
Definition: LocalRepo.php:183
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
LIST_AND
const LIST_AND
Definition: Defines.php:48
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:1992
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
LIST_OR
const LIST_OR
Definition: Defines.php:51
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
FileRepo\getLocalCacheKey
getLocalCacheKey(... $args)
Get a key for this repo in the local cache domain.
Definition: FileRepo.php:1898
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:2475
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:543
LocalRepo\getDBFactory
getDBFactory()
Get a callback to get a DB handle given an index (DB_REPLICA/DB_MASTER)
Definition: LocalRepo.php:490
LocalRepo\invalidateImageRedirect
invalidateImageRedirect(Title $title)
Invalidates image redirect cache related to that image.
Definition: LocalRepo.php:517
LocalRepo\storeBatch
storeBatch(array $triplets, $flags=0)
Store a batch of files.
Definition: LocalRepo.php:547
$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:591
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:910
LocalRepo\cleanupBatch
cleanupBatch(array $files, $flags=0)
Deletes a batch of files.
Definition: LocalRepo.php:551
LocalRepo\findFiles
findFiles(array $items, $flags=0)
Find many files at once.
Definition: LocalRepo.php:244
FileRepo\getNameFromTitle
getNameFromTitle(Title $title)
Get the name of a file from its title object.
Definition: FileRepo.php:699
LocalRepo\newFromArchiveName
newFromArchiveName( $title, $archiveName)
Definition: LocalRepo.php:86
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:82
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:413
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:364
LocalRepo\findFilesByPrefix
findFilesByPrefix( $prefix, $limit)
Return an array of files where the name starts with $prefix.
Definition: LocalRepo.php:446
LocalRepo\checkRedirect
checkRedirect(Title $title)
Checks if there is a redirect named as $title.
Definition: LocalRepo.php:197
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:41
LocalRepo\cleanupDeletedBatch
cleanupDeletedBatch(array $storageKeys)
Delete files in the deleted directory if they are not referenced in the filearchive table.
Definition: LocalRepo.php:100
$path
$path
Definition: NoLocalSettings.php:25
LocalRepo\deleteBatch
deleteBatch(array $sourceDestPairs)
Move a group of files to the deletion archive.
Definition: LocalRepo.php:573
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:383
$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:584
LocalRepo\__construct
__construct(array $info=null)
Definition: LocalRepo.php:51
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:56
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:565
FileRepo\getDeletedHashPath
getDeletedHashPath( $key)
Get a relative path for a deletion archive key, e.g.
Definition: FileRepo.php:1556
FileRepo\assertWritableRepo
assertWritableRepo()
Throw an exception if this repo is read-only by design.
Definition: FileRepo.php:1958
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:490
LocalRepo\$fileFromRowFactory
callable $fileFromRowFactory
Definition: LocalRepo.php:43