aboutsummaryrefslogtreecommitdiffstats
path: root/maintenance
diff options
context:
space:
mode:
authorDerick Alangi <alangiderick@gmail.com>2019-05-14 18:00:34 +0100
committerD3r1ck01 <xsavitar.wiki@aol.com>2019-06-11 13:26:37 +0000
commit21e2d71560cb87191dd80ae0750d0190b45063c1 (patch)
treea0088f08e76373bc0cd01e78531829e172210d6e /maintenance
parenta6dce8b8cd0b665ed4a00ad6bdcfabf69f2925c3 (diff)
downloadmediawikicore-21e2d71560cb87191dd80ae0750d0190b45063c1.tar.gz
mediawikicore-21e2d71560cb87191dd80ae0750d0190b45063c1.zip
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
Diffstat (limited to 'maintenance')
-rw-r--r--maintenance/deleteBatch.php6
-rw-r--r--maintenance/dumpUploads.php4
-rw-r--r--maintenance/eraseArchivedFile.php4
-rw-r--r--maintenance/importImages.php5
-rw-r--r--maintenance/populateImageSha1.php4
-rw-r--r--maintenance/rebuildImages.php6
6 files changed, 21 insertions, 8 deletions
diff --git a/maintenance/deleteBatch.php b/maintenance/deleteBatch.php
index 4f9e488343da..ee6e3e5306a0 100644
--- a/maintenance/deleteBatch.php
+++ b/maintenance/deleteBatch.php
@@ -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... " );
}
diff --git a/maintenance/dumpUploads.php b/maintenance/dumpUploads.php
index a5bc6cc0bce4..c4ca056c59bf 100644
--- a/maintenance/dumpUploads.php
+++ b/maintenance/dumpUploads.php
@@ -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 );
diff --git a/maintenance/eraseArchivedFile.php b/maintenance/eraseArchivedFile.php
index ef6d3d8b8957..49fadaa2d802 100644
--- a/maintenance/eraseArchivedFile.php
+++ b/maintenance/eraseArchivedFile.php
@@ -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" );
}
diff --git a/maintenance/importImages.php b/maintenance/importImages.php
index dfa83cdb6aec..381926aac418 100644
--- a/maintenance/importImages.php
+++ b/maintenance/importImages.php
@@ -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..." );
diff --git a/maintenance/populateImageSha1.php b/maintenance/populateImageSha1.php
index a71abb61ec7a..0de9d6737ec5 100644
--- a/maintenance/populateImageSha1.php
+++ b/maintenance/populateImageSha1.php
@@ -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;
}
diff --git a/maintenance/rebuildImages.php b/maintenance/rebuildImages.php
index c0de33412e0f..dfce2021e640 100644
--- a/maintenance/rebuildImages.php
+++ b/maintenance/rebuildImages.php
@@ -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)',