Replace some uses of deprecated wfFindFile() and wfLocalFile()
These global functions were deprecated in 1.34 and services made available to replace them. See services below; * wfFindFile() - MediaWikiServices::getInstance()->getRepoGroup()->findFile() * wfLocalFind() - MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()->newFile() NOTES: * wfFindFile() and wfLocalFind() usages in tests have been ignored in this change per @Timo's comments about state of objects. * includes/upload/UploadBase.php also maintained for now as it causes some failures I don't fully understand, will investigate and handle it in a follow up patch. * Also, includes/MovePage.php Change-Id: I9437494de003f40fbe591321da7b42d16bb732d6
This commit is contained in:
parent
a6dce8b8cd
commit
21e2d71560
39 changed files with 140 additions and 62 deletions
|
|
@ -2591,7 +2591,7 @@ ERROR;
|
|||
}
|
||||
} elseif ( $namespace == NS_FILE ) {
|
||||
# Show a hint to shared repo
|
||||
$file = wfFindFile( $this->mTitle );
|
||||
$file = MediaWikiServices::getInstance()->getRepoGroup()->findFile( $this->mTitle );
|
||||
if ( $file && !$file->isLocal() ) {
|
||||
$descUrl = $file->getDescriptionUrl();
|
||||
# there must be a description url to show a hint to shared repo
|
||||
|
|
|
|||
|
|
@ -2984,7 +2984,7 @@ function wfUnpack( $format, $data, $length = false ) {
|
|||
function wfIsBadImage( $name, $contextTitle = false, $blacklist = null ) {
|
||||
# Handle redirects; callers almost always hit wfFindFile() anyway,
|
||||
# so just use that method because it has a fast process cache.
|
||||
$file = wfFindFile( $name ); // get the final name
|
||||
$file = MediaWikiServices::getInstance()->getRepoGroup()->findFile( $name ); // get the final name
|
||||
$name = $file ? $file->getTitle()->getDBkey() : $name;
|
||||
|
||||
# Run the extension hook
|
||||
|
|
|
|||
|
|
@ -555,7 +555,8 @@ class Linker {
|
|||
# Use manually specified thumbnail
|
||||
$manual_title = Title::makeTitleSafe( NS_FILE, $frameParams['manualthumb'] );
|
||||
if ( $manual_title ) {
|
||||
$manual_img = wfFindFile( $manual_title );
|
||||
$manual_img = MediaWikiServices::getInstance()->getRepoGroup()
|
||||
->findFile( $manual_title );
|
||||
if ( $manual_img ) {
|
||||
$thumb = $manual_img->getUnscaledThumb( $handlerParams );
|
||||
$manualthumb = true;
|
||||
|
|
@ -693,7 +694,8 @@ class Linker {
|
|||
$label = $title->getPrefixedText();
|
||||
}
|
||||
$encLabel = htmlspecialchars( $label );
|
||||
$currentExists = $time ? ( wfFindFile( $title ) != false ) : false;
|
||||
$file = MediaWikiServices::getInstance()->getRepoGroup()->findFile( $title );
|
||||
$currentExists = $time ? ( $file != false ) : false;
|
||||
|
||||
if ( ( $wgUploadMissingFileUrl || $wgUploadNavigationUrl || $wgEnableUploads )
|
||||
&& !$currentExists
|
||||
|
|
@ -756,11 +758,13 @@ class Linker {
|
|||
* @since 1.16.3
|
||||
* @param LinkTarget $title
|
||||
* @param string $html Pre-sanitized HTML
|
||||
* @param string $time MW timestamp of file creation time
|
||||
* @param string|false $time MW timestamp of file creation time
|
||||
* @return string HTML
|
||||
*/
|
||||
public static function makeMediaLinkObj( $title, $html = '', $time = false ) {
|
||||
$img = wfFindFile( $title, [ 'time' => $time ] );
|
||||
$img = MediaWikiServices::getInstance()->getRepoGroup()->findFile(
|
||||
$title, [ 'time' => $time ]
|
||||
);
|
||||
return self::makeMediaLinkFile( $title, $img, $html );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3584,7 +3584,8 @@ class Title implements LinkTarget, IDBAccessObject {
|
|||
|
||||
# Is it an existing file?
|
||||
if ( $nt->getNamespace() == NS_FILE ) {
|
||||
$file = wfLocalFile( $nt );
|
||||
$file = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
|
||||
->newFile( $nt );
|
||||
$file->load( File::READ_LATEST );
|
||||
if ( $file->exists() ) {
|
||||
wfDebug( __METHOD__ . ": file exists\n" );
|
||||
|
|
@ -4056,15 +4057,15 @@ class Title implements LinkTarget, IDBAccessObject {
|
|||
return true; // any interwiki link might be viewable, for all we know
|
||||
}
|
||||
|
||||
$services = MediaWikiServices::getInstance();
|
||||
switch ( $this->mNamespace ) {
|
||||
case NS_MEDIA:
|
||||
case NS_FILE:
|
||||
// file exists, possibly in a foreign repo
|
||||
return (bool)wfFindFile( $this );
|
||||
return (bool)$services->getRepoGroup()->findFile( $this );
|
||||
case NS_SPECIAL:
|
||||
// valid special page
|
||||
return MediaWikiServices::getInstance()->getSpecialPageFactory()->
|
||||
exists( $this->mDbkeyform );
|
||||
return $services->getSpecialPageFactory()->exists( $this->mDbkeyform );
|
||||
case NS_MAIN:
|
||||
// selflink, possibly with fragment
|
||||
return $this->mDbkeyform == '';
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ class InfoAction extends FormlessAction {
|
|||
|
||||
// Display image SHA-1 value
|
||||
if ( $title->inNamespace( NS_FILE ) ) {
|
||||
$fileObj = wfFindFile( $title );
|
||||
$fileObj = $services->getRepoGroup()->findFile( $title );
|
||||
if ( $fileObj !== false ) {
|
||||
// Convert the base-36 sha1 value obtained from database to base-16
|
||||
$output = Wikimedia\base_convert( $fileObj->getSha1(), 36, 16, 40 );
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -56,7 +59,9 @@ class ApiImageRotate extends ApiBase {
|
|||
}
|
||||
}
|
||||
|
||||
$file = wfFindFile( $title, [ 'latest' => true ] );
|
||||
$file = MediaWikiServices::getInstance()->getRepoGroup()->findFile(
|
||||
$title, [ 'latest' => true ]
|
||||
);
|
||||
if ( !$file ) {
|
||||
$r['result'] = 'Failure';
|
||||
$r['errors'] = $this->getErrorFormatter()->arrayFromStatus(
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
* @file
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* API Module to move pages
|
||||
* @ingroup API
|
||||
|
|
@ -59,7 +61,7 @@ class ApiMove extends ApiBase {
|
|||
|
||||
if ( $toTitle->getNamespace() == NS_FILE
|
||||
&& !RepoGroup::singleton()->getLocalRepo()->findFile( $toTitle )
|
||||
&& wfFindFile( $toTitle )
|
||||
&& MediaWikiServices::getInstance()->getRepoGroup()->findFile( $toTitle )
|
||||
) {
|
||||
if ( !$params['ignorewarnings'] && $user->isAllowed( 'reupload-shared' ) ) {
|
||||
$this->dieWithError( 'apierror-fileexists-sharedrepo-perm' );
|
||||
|
|
|
|||
|
|
@ -110,7 +110,8 @@ class ApiQueryImageInfo extends ApiQueryBase {
|
|||
if ( !isset( $images[$title] ) ) {
|
||||
if ( isset( $prop['uploadwarning'] ) || isset( $prop['badfile'] ) ) {
|
||||
// uploadwarning and badfile need info about non-existing files
|
||||
$images[$title] = wfLocalFile( $title );
|
||||
$images[$title] = MediaWikiServices::getInstance()->getRepoGroup()
|
||||
->getLocalRepo()->newFile( $title );
|
||||
// Doesn't exist, so set an empty image repository
|
||||
$info['imagerepository'] = '';
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* Content handler for File: files
|
||||
* TODO: this handler s not used directly now,
|
||||
|
|
@ -41,7 +43,8 @@ class FileContentHandler extends WikitextContentHandler {
|
|||
if ( NS_FILE != $title->getNamespace() ) {
|
||||
return [];
|
||||
}
|
||||
$file = wfLocalFile( $title );
|
||||
$file = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
|
||||
->newFile( $title );
|
||||
if ( !$file || !$file->exists() ) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,7 +114,8 @@ class WANCacheReapUpdate implements DeferrableUpdate {
|
|||
}
|
||||
|
||||
if ( $t->inNamespace( NS_FILE ) ) {
|
||||
$entities[] = wfLocalFile( $t->getText() );
|
||||
$entities[] = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
|
||||
->newFile( $t->getText() );
|
||||
}
|
||||
if ( $t->inNamespace( NS_USER ) ) {
|
||||
$entities[] = User::newFromName( $t->getText(), false );
|
||||
|
|
|
|||
|
|
@ -462,7 +462,8 @@ class XmlDumpWriter {
|
|||
*/
|
||||
function writeUploads( $row, $dumpContents = false ) {
|
||||
if ( $row->page_namespace == NS_FILE ) {
|
||||
$img = wfLocalFile( $row->page_title );
|
||||
$img = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
|
||||
->newFile( $row->page_title );
|
||||
if ( $img && $img->exists() ) {
|
||||
$out = '';
|
||||
foreach ( array_reverse( $img->getHistory() ) as $ver ) {
|
||||
|
|
|
|||
|
|
@ -45,8 +45,16 @@ use MediaWiki\MediaWikiServices;
|
|||
*
|
||||
* RepoGroup::singleton()->getLocalRepo()->newFile( $title );
|
||||
*
|
||||
* The convenience functions wfLocalFile() and wfFindFile() should be sufficient
|
||||
* in most cases.
|
||||
* Consider the services container below;
|
||||
*
|
||||
* $services = MediaWikiServices::getInstance();
|
||||
*
|
||||
* The convenience services $services->getRepoGroup()->getLocalRepo()->newFile()
|
||||
* and $services->getRepoGroup()->findFile() should be sufficient in most cases.
|
||||
*
|
||||
* @TODO: DI - Instead of using MediaWikiServices::getInstance(), a service should
|
||||
* ideally accept a RepoGroup in its constructor and then, use $this->repoGroup->findFile()
|
||||
* and $this->repoGroup->getLocalRepo()->newFile().
|
||||
*
|
||||
* @ingroup FileAbstraction
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -39,8 +39,16 @@ use MediaWiki\MediaWikiServices;
|
|||
*
|
||||
* RepoGroup::singleton()->getLocalRepo()->newFile( $title );
|
||||
*
|
||||
* The convenience functions wfLocalFile() and wfFindFile() should be sufficient
|
||||
* in most cases.
|
||||
* Consider the services container below;
|
||||
*
|
||||
* $services = MediaWikiServices::getInstance();
|
||||
*
|
||||
* The convenience services $services->getRepoGroup()->getLocalRepo()->newFile()
|
||||
* and $services->getRepoGroup()->findFile() should be sufficient in most cases.
|
||||
*
|
||||
* @TODO: DI - Instead of using MediaWikiServices::getInstance(), a service should
|
||||
* ideally accept a RepoGroup in its constructor and then, use $this->repoGroup->findFile()
|
||||
* and $this->repoGroup->getLocalRepo()->newFile().
|
||||
*
|
||||
* @ingroup FileAbstraction
|
||||
*/
|
||||
|
|
@ -1898,6 +1906,7 @@ class LocalFile extends File {
|
|||
* @return Status
|
||||
*/
|
||||
function move( $target ) {
|
||||
$localRepo = MediaWikiServices::getInstance()->getRepoGroup();
|
||||
if ( $this->getRepo()->getReadOnlyReason() !== false ) {
|
||||
return $this->readOnlyFatalStatus();
|
||||
}
|
||||
|
|
@ -1914,8 +1923,8 @@ class LocalFile extends File {
|
|||
wfDebugLog( 'imagemove', "Finished moving {$this->name}" );
|
||||
|
||||
// Purge the source and target files...
|
||||
$oldTitleFile = wfLocalFile( $this->title );
|
||||
$newTitleFile = wfLocalFile( $target );
|
||||
$oldTitleFile = $localRepo->findFile( $this->title );
|
||||
$newTitleFile = $localRepo->findFile( $target );
|
||||
// To avoid slow purges in the transaction, move them outside...
|
||||
DeferredUpdates::addUpdate(
|
||||
new AutoCommitUpdate(
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
* @ingroup FileAbstraction
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\Rdbms\IDatabase;
|
||||
|
||||
/**
|
||||
|
|
@ -125,7 +126,8 @@ class LocalFileMoveBatch {
|
|||
public function execute() {
|
||||
$repo = $this->file->repo;
|
||||
$status = $repo->newGood();
|
||||
$destFile = wfLocalFile( $this->target );
|
||||
$destFile = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
|
||||
->newFile( $this->target );
|
||||
|
||||
$this->file->lock();
|
||||
$destFile->lock(); // quickly fail if destination is not available
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* Image gallery.
|
||||
*
|
||||
|
|
@ -87,7 +90,7 @@ class TraditionalImageGallery extends ImageGalleryBase {
|
|||
# Fetch and register the file (file title may be different via hooks)
|
||||
list( $img, $nt ) = $this->mParser->fetchFileAndTitle( $nt, $options );
|
||||
} else {
|
||||
$img = wfFindFile( $nt );
|
||||
$img = MediaWikiServices::getInstance()->getRepoGroup()->findFile( $nt );
|
||||
}
|
||||
} else {
|
||||
$img = false;
|
||||
|
|
|
|||
|
|
@ -62,7 +62,8 @@ class ImportableUploadRevisionImporter implements UploadRevisionImporter {
|
|||
$file = OldLocalFile::newFromArchiveName( $importableRevision->getTitle(),
|
||||
RepoGroup::singleton()->getLocalRepo(), $archiveName );
|
||||
} else {
|
||||
$file = wfLocalFile( $importableRevision->getTitle() );
|
||||
$file = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
|
||||
->newFile( $importableRevision->getTitle() );
|
||||
$file->load( File::READ_LATEST );
|
||||
$this->logger->debug( __METHOD__ . 'Importing new file as ' . $file->getName() . "\n" );
|
||||
if ( $file->exists() && $file->getTimestamp() > $importableRevision->getTimestamp() ) {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
* @ingroup JobQueue
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* Job for asynchronous rendering of thumbnails.
|
||||
*
|
||||
|
|
@ -36,7 +38,8 @@ class ThumbnailRenderJob extends Job {
|
|||
|
||||
$transformParams = $this->params['transformParams'];
|
||||
|
||||
$file = wfLocalFile( $this->title );
|
||||
$file = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
|
||||
->newFile( $this->title );
|
||||
$file->load( File::READ_LATEST );
|
||||
|
||||
if ( $file && $file->exists() ) {
|
||||
|
|
|
|||
|
|
@ -75,9 +75,10 @@ class ImagePage extends Article {
|
|||
|
||||
Hooks::run( 'ImagePageFindFile', [ $this, &$img, &$this->displayImg ] );
|
||||
if ( !$img ) { // not set by hook?
|
||||
$img = wfFindFile( $this->getTitle() );
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$img = $services->getRepoGroup()->findFile( $this->getTitle() );
|
||||
if ( !$img ) {
|
||||
$img = wfLocalFile( $this->getTitle() );
|
||||
$img = $services->getRepoGroup()->getLocalRepo()->newFile( $this->getTitle() );
|
||||
}
|
||||
}
|
||||
$this->mPage->setFile( $img );
|
||||
|
|
|
|||
|
|
@ -420,7 +420,9 @@ class PageArchive {
|
|||
$restoreFiles = $restoreAll || !empty( $fileVersions );
|
||||
|
||||
if ( $restoreFiles && $this->title->getNamespace() == NS_FILE ) {
|
||||
$img = wfLocalFile( $this->title );
|
||||
/** @var LocalFile $img */
|
||||
$img = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
|
||||
->newFile( $this->title );
|
||||
$img->load( File::READ_LATEST );
|
||||
$this->fileStatus = $img->restore( $fileVersions, $unsuppress );
|
||||
if ( !$this->fileStatus->isOK() ) {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
* @file
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\Rdbms\FakeResultWrapper;
|
||||
|
||||
/**
|
||||
|
|
@ -55,14 +56,16 @@ class WikiFilePage extends WikiPage {
|
|||
* @return bool
|
||||
*/
|
||||
protected function loadFile() {
|
||||
$services = MediaWikiServices::getInstance();
|
||||
if ( $this->mFileLoaded ) {
|
||||
return true;
|
||||
}
|
||||
$this->mFileLoaded = true;
|
||||
|
||||
$this->mFile = wfFindFile( $this->mTitle );
|
||||
$this->mFile = $services->getRepoGroup()->findFile( $this->mTitle );
|
||||
if ( !$this->mFile ) {
|
||||
$this->mFile = wfLocalFile( $this->mTitle ); // always a File
|
||||
$this->mFile = $services->getRepoGroup()->getLocalRepo()
|
||||
->newFile( $this->mTitle ); // always a File
|
||||
}
|
||||
$this->mRepo = $this->mFile->getRepo();
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1030,7 +1030,7 @@ class CoreParserFunctions {
|
|||
* @return array|string
|
||||
*/
|
||||
public static function filepath( $parser, $name = '', $argA = '', $argB = '' ) {
|
||||
$file = wfFindFile( $name );
|
||||
$file = MediaWikiServices::getInstance()->getRepoGroup()->findFile( $name );
|
||||
|
||||
if ( $argA == 'nowiki' ) {
|
||||
// {{filepath: | option [| size] }}
|
||||
|
|
|
|||
|
|
@ -3898,7 +3898,7 @@ class Parser {
|
|||
} elseif ( isset( $options['sha1'] ) ) { // get by (sha1,timestamp)
|
||||
$file = RepoGroup::singleton()->findFileFromKey( $options['sha1'], $options );
|
||||
} else { // get by (name,timestamp)
|
||||
$file = wfFindFile( $title, $options );
|
||||
$file = MediaWikiServices::getInstance()->getRepoGroup()->findFile( $title, $options );
|
||||
}
|
||||
return $file;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
* @ingroup RevisionDelete
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\Rdbms\IDatabase;
|
||||
|
||||
/**
|
||||
|
|
@ -109,7 +110,8 @@ class RevDelFileList extends RevDelList {
|
|||
}
|
||||
|
||||
public function doPostCommitUpdates( array $visibilityChangeMap ) {
|
||||
$file = wfLocalFile( $this->title );
|
||||
$file = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
|
||||
->newFile( $this->title );
|
||||
$file->purgeCache();
|
||||
$file->purgeDescription();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* Implementation of near match title search.
|
||||
* TODO: split into service/implementation.
|
||||
|
|
@ -150,7 +152,7 @@ class SearchNearMatcher {
|
|||
# There may have been a funny upload, or it may be on a shared
|
||||
# file repository such as Wikimedia Commons.
|
||||
if ( $title->getNamespace() == NS_FILE ) {
|
||||
$image = wfFindFile( $title );
|
||||
$image = MediaWikiServices::getInstance()->getRepoGroup()->findFile( $title );
|
||||
if ( $image ) {
|
||||
return $title;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,16 +86,17 @@ class SearchResult {
|
|||
*/
|
||||
protected function initFromTitle( $title ) {
|
||||
$this->mTitle = $title;
|
||||
$services = MediaWikiServices::getInstance();
|
||||
if ( !is_null( $this->mTitle ) ) {
|
||||
$id = false;
|
||||
Hooks::run( 'SearchResultInitFromTitle', [ $title, &$id ] );
|
||||
$this->mRevision = Revision::newFromTitle(
|
||||
$this->mTitle, $id, Revision::READ_NORMAL );
|
||||
if ( $this->mTitle->getNamespace() === NS_FILE ) {
|
||||
$this->mImage = wfFindFile( $this->mTitle );
|
||||
$this->mImage = $services->getRepoGroup()->findFile( $this->mTitle );
|
||||
}
|
||||
}
|
||||
$this->searchEngine = MediaWikiServices::getInstance()->newSearchEngine();
|
||||
$this->searchEngine = $services->newSearchEngine();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ class FileDuplicateSearchPage extends QueryPage {
|
|||
$this->hash = '';
|
||||
$title = Title::newFromText( $this->filename, NS_FILE );
|
||||
if ( $title && $title->getText() != '' ) {
|
||||
$this->file = wfFindFile( $title );
|
||||
$this->file = MediaWikiServices::getInstance()->getRepoGroup()->findFile( $title );
|
||||
}
|
||||
|
||||
$out = $this->getOutput();
|
||||
|
|
|
|||
|
|
@ -537,7 +537,7 @@ class MovePageForm extends UnlistedSpecialPage {
|
|||
if ( $nt->getNamespace() == NS_FILE
|
||||
&& !( $this->moveOverShared && $user->isAllowed( 'reupload-shared' ) )
|
||||
&& !RepoGroup::singleton()->getLocalRepo()->findFile( $nt )
|
||||
&& wfFindFile( $nt )
|
||||
&& MediaWikiServices::getInstance()->getRepoGroup()->findFile( $nt )
|
||||
) {
|
||||
$this->showForm( [ [ 'file-exists-sharedrepo' ] ] );
|
||||
|
||||
|
|
@ -567,7 +567,8 @@ class MovePageForm extends UnlistedSpecialPage {
|
|||
|
||||
// Delete an associated image if there is
|
||||
if ( $nt->getNamespace() == NS_FILE ) {
|
||||
$file = wfLocalFile( $nt );
|
||||
$file = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
|
||||
->newFile( $nt );
|
||||
$file->load( File::READ_LATEST );
|
||||
if ( $file->exists() ) {
|
||||
$file->delete( $reason, false, $user );
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
* @ingroup SpecialPage
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* A special page that redirects to: the user for a numeric user id,
|
||||
* the file for a given filename, or the page for a given revision id.
|
||||
|
|
@ -101,7 +103,7 @@ class SpecialRedirect extends FormSpecialPage {
|
|||
} catch ( MalformedTitleException $e ) {
|
||||
return Status::newFatal( $e->getMessageObject() );
|
||||
}
|
||||
$file = wfFindFile( $title );
|
||||
$file = MediaWikiServices::getInstance()->getRepoGroup()->findFile( $title );
|
||||
|
||||
if ( !$file || !$file->exists() ) {
|
||||
// Message: redirect-not-exists
|
||||
|
|
|
|||
|
|
@ -669,7 +669,8 @@ class SpecialUpload extends SpecialPage {
|
|||
return true;
|
||||
}
|
||||
|
||||
$local = wfLocalFile( $this->mDesiredDestName );
|
||||
$local = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
|
||||
->newFile( $this->mDesiredDestName );
|
||||
if ( $local && $local->exists() ) {
|
||||
// We're uploading a new version of an existing file.
|
||||
// No creation, so don't watch it if we're not already.
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@
|
|||
* @author Soxred93 <soxred93@gmail.com>
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* Querypage that lists the most wanted files
|
||||
*
|
||||
|
|
@ -97,14 +99,14 @@ class WantedFilesPage extends WantedQueryPage {
|
|||
/**
|
||||
* Does the file exist?
|
||||
*
|
||||
* Use wfFindFile so we still think file namespace pages without
|
||||
* files are missing, but valid file redirects and foreign files are ok.
|
||||
* Use findFile() so we still think file namespace pages without files
|
||||
* are missing, but valid file redirects and foreign files are ok.
|
||||
*
|
||||
* @param Title $title
|
||||
* @return bool
|
||||
*/
|
||||
protected function existenceCheck( Title $title ) {
|
||||
return (bool)wfFindFile( $title );
|
||||
return (bool)MediaWikiServices::getInstance()->getRepoGroup()->findFile( $title );
|
||||
}
|
||||
|
||||
function getQueryInfo() {
|
||||
|
|
|
|||
|
|
@ -436,7 +436,8 @@ class ImageListPager extends TablePager {
|
|||
* @throws MWException
|
||||
*/
|
||||
function formatValue( $field, $value ) {
|
||||
$linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$linkRenderer = $services->getLinkRenderer();
|
||||
switch ( $field ) {
|
||||
case 'thumb':
|
||||
$opt = [ 'time' => wfTimestamp( TS_MW, $this->mCurrentRow->img_timestamp ) ];
|
||||
|
|
@ -468,8 +469,9 @@ class ImageListPager extends TablePager {
|
|||
$filePage,
|
||||
$filePage->getText()
|
||||
);
|
||||
$download = Xml::element( 'a',
|
||||
[ 'href' => wfLocalFile( $filePage )->getUrl() ],
|
||||
$download = Xml::element(
|
||||
'a',
|
||||
[ 'href' => $services->getRepoGroup()->findFile( $filePage )->getUrl() ],
|
||||
$imgfile
|
||||
);
|
||||
$download = $this->msg( 'parentheses' )->rawParams( $download )->escaped();
|
||||
|
|
|
|||
|
|
@ -2069,10 +2069,10 @@ abstract class UploadBase {
|
|||
$partname = $n ? substr( $filename, 0, $n ) : $filename;
|
||||
|
||||
return (
|
||||
substr( $partname, 3, 3 ) == 'px-' ||
|
||||
substr( $partname, 2, 3 ) == 'px-'
|
||||
) &&
|
||||
preg_match( "/[0-9]{2}/", substr( $partname, 0, 2 ) );
|
||||
substr( $partname, 3, 3 ) == 'px-' ||
|
||||
substr( $partname, 2, 3 ) == 'px-'
|
||||
) &&
|
||||
preg_match( "/[0-9]{2}/", substr( $partname, 0, 2 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use Category;
|
|||
use Hooks;
|
||||
use HtmlArmor;
|
||||
use MediaWiki\Linker\LinkRenderer;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use SearchResult;
|
||||
use SpecialSearch;
|
||||
use Title;
|
||||
|
|
@ -248,7 +249,8 @@ class FullSearchResultWidget implements SearchResultWidget {
|
|||
$descHtml = null;
|
||||
$thumbHtml = null;
|
||||
|
||||
$img = $result->getFile() ?: wfFindFile( $title );
|
||||
$img = $result->getFile() ?: MediaWikiServices::getInstance()->getRepoGroup()
|
||||
->findFile( $title );
|
||||
if ( $img ) {
|
||||
$thumb = $img->transform( [ 'width' => 120, 'height' => 120 ] );
|
||||
if ( $thumb ) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
* @ingroup Maintenance
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
require_once __DIR__ . '/Maintenance.php';
|
||||
|
||||
/**
|
||||
|
|
@ -98,7 +100,9 @@ class DeleteBatch extends Maintenance {
|
|||
|
||||
$this->output( $title->getPrefixedText() );
|
||||
if ( $title->getNamespace() == NS_FILE ) {
|
||||
$img = wfFindFile( $title, [ 'ignoreRedirect' => true ] );
|
||||
$img = MediaWikiServices::getInstance()->getRepoGroup()->findFile(
|
||||
$title, [ 'ignoreRedirect' => true ]
|
||||
);
|
||||
if ( $img && $img->isLocal() && !$img->delete( $reason ) ) {
|
||||
$this->output( " FAILED to delete associated file... " );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
* @ingroup Maintenance
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
require_once __DIR__ . '/Maintenance.php';
|
||||
|
||||
/**
|
||||
|
|
@ -109,7 +111,7 @@ By default, outputs relative paths against the parent directory of $wgUploadDire
|
|||
}
|
||||
|
||||
function outputItem( $name, $shared ) {
|
||||
$file = wfFindFile( $name );
|
||||
$file = MediaWikiServices::getInstance()->getRepoGroup()->findFile( $name );
|
||||
if ( $file && $this->filterItem( $file, $shared ) ) {
|
||||
$filename = $file->getLocalRefPath();
|
||||
$rel = wfRelativePath( $filename, $this->mBasePath );
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
* @ingroup Maintenance
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
require_once __DIR__ . '/Maintenance.php';
|
||||
|
||||
/**
|
||||
|
|
@ -66,7 +68,7 @@ class EraseArchivedFile extends Maintenance {
|
|||
$afile = ArchivedFile::newFromRow( $row );
|
||||
}
|
||||
|
||||
$file = wfLocalFile( $filename );
|
||||
$file = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()->newFile( $filename );
|
||||
if ( $file->exists() ) {
|
||||
$this->fatalError( "File '$filename' is still a public file, use the delete form.\n" );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@
|
|||
* @author Mij <mij@bitchx.it>
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
require_once __DIR__ . '/Maintenance.php';
|
||||
|
||||
class ImportImages extends Maintenance {
|
||||
|
|
@ -219,7 +221,8 @@ class ImportImages extends Maintenance {
|
|||
}
|
||||
|
||||
# Check existence
|
||||
$image = wfLocalFile( $title );
|
||||
$image = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
|
||||
->newFile( $title );
|
||||
if ( $image->exists() ) {
|
||||
if ( $this->hasOption( 'overwrite' ) ) {
|
||||
$this->output( "{$base} exists, overwriting..." );
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
* @ingroup Maintenance
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Shell\Shell;
|
||||
|
||||
require_once __DIR__ . '/Maintenance.php';
|
||||
|
|
@ -125,7 +126,8 @@ class PopulateImageSha1 extends LoggedUpdateMaintenance {
|
|||
wfWaitForSlaves();
|
||||
}
|
||||
|
||||
$file = wfLocalFile( $row->img_name );
|
||||
$file = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
|
||||
->newFile( $row->img_name );
|
||||
if ( !$file ) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -195,9 +195,9 @@ class ImageBuilder extends Maintenance {
|
|||
|
||||
function addMissingImage( $filename, $fullpath ) {
|
||||
$timestamp = $this->dbw->timestamp( $this->getRepo()->getFileTimestamp( $fullpath ) );
|
||||
$services = MediaWikiServices::getInstance();
|
||||
|
||||
$altname = MediaWikiServices::getInstance()->getContentLanguage()->
|
||||
checkTitleEncoding( $filename );
|
||||
$altname = $services->getContentLanguage()->checkTitleEncoding( $filename );
|
||||
if ( $altname != $filename ) {
|
||||
if ( $this->dryrun ) {
|
||||
$filename = $altname;
|
||||
|
|
@ -214,7 +214,7 @@ class ImageBuilder extends Maintenance {
|
|||
return;
|
||||
}
|
||||
if ( !$this->dryrun ) {
|
||||
$file = wfLocalFile( $filename );
|
||||
$file = $services->getRepoGroup()->getLocalRepo()->newFile( $filename );
|
||||
if ( !$file->recordUpload(
|
||||
'',
|
||||
'(recovered file, missing upload log entry)',
|
||||
|
|
|
|||
Loading…
Reference in a new issue