From 37ad84cb911a4cac1973dc96d54efbc31beb9aa2 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 17 Sep 2016 22:29:06 -0700 Subject: [PATCH] Cleanups and IDEA warning fixes to FileRepo classes Change-Id: I98247b299c31b93df183981adc517187cb4aefe5 --- includes/filerepo/FileRepo.php | 4 ++-- includes/filerepo/ForeignDBViaLBRepo.php | 3 +++ includes/filerepo/file/ArchivedFile.php | 1 + includes/filerepo/file/ForeignAPIFile.php | 8 ++++---- includes/filerepo/file/LocalFile.php | 10 ++++++---- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index b8b1cf6a17..8fee3bfa74 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -825,7 +825,7 @@ class FileRepo { $status = $this->storeBatch( [ [ $srcPath, $dstZone, $dstRel ] ], $flags ); if ( $status->successCount == 0 ) { - $status->ok = false; + $status->setOK( false ); } return $status; @@ -1166,7 +1166,7 @@ class FileRepo { $status = $this->publishBatch( [ [ $src, $dstRel, $archiveRel, $options ] ], $flags ); if ( $status->successCount == 0 ) { - $status->ok = false; + $status->setOK( false ); } if ( isset( $status->value[0] ) ) { $status->value = $status->value[0]; diff --git a/includes/filerepo/ForeignDBViaLBRepo.php b/includes/filerepo/ForeignDBViaLBRepo.php index f8b1ed9f79..55df1af03b 100644 --- a/includes/filerepo/ForeignDBViaLBRepo.php +++ b/includes/filerepo/ForeignDBViaLBRepo.php @@ -42,6 +42,9 @@ class ForeignDBViaLBRepo extends LocalRepo { /** @var array */ protected $fileFromRowFactory = [ 'ForeignDBFile', 'newFromRow' ]; + /** @var bool */ + protected $hasSharedCache; + /** * @param array|null $info */ diff --git a/includes/filerepo/file/ArchivedFile.php b/includes/filerepo/file/ArchivedFile.php index d1e683ac70..921e129c36 100644 --- a/includes/filerepo/file/ArchivedFile.php +++ b/includes/filerepo/file/ArchivedFile.php @@ -425,6 +425,7 @@ class ArchivedFile { */ function pageCount() { if ( !isset( $this->pageCount ) ) { + // @FIXME: callers expect File objects if ( $this->getHandler() && $this->handler->isMultiPage( $this ) ) { $this->pageCount = $this->handler->pageCount( $this ); } else { diff --git a/includes/filerepo/file/ForeignAPIFile.php b/includes/filerepo/file/ForeignAPIFile.php index f6752d8308..43b6855f82 100644 --- a/includes/filerepo/file/ForeignAPIFile.php +++ b/includes/filerepo/file/ForeignAPIFile.php @@ -28,7 +28,10 @@ * @ingroup FileAbstraction */ class ForeignAPIFile extends File { + /** @var bool */ private $mExists; + /** @var array */ + private $mInfo = []; protected $repoClass = 'ForeignApiRepo'; @@ -244,7 +247,7 @@ class ForeignAPIFile extends File { public function getUser( $type = 'text' ) { if ( $type == 'text' ) { return isset( $this->mInfo['user'] ) ? strval( $this->mInfo['user'] ) : null; - } elseif ( $type == 'id' ) { + } else { return 0; // What makes sense here, for a remote user? } } @@ -344,9 +347,6 @@ class ForeignAPIFile extends File { return $files; } - /** - * @see File::purgeCache() - */ function purgeCache( $options = [] ) { $this->purgeThumbnails( $options ); $this->purgeDescriptionPage(); diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 618272c0c9..f3980f3675 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -1480,8 +1480,10 @@ class LocalFile extends File { ); if ( isset( $status->value['revision'] ) ) { + /** @var $rev Revision */ + $rev = $status->value['revision']; // Associate new page revision id - $logEntry->setAssociatedRevId( $status->value['revision']->getId() ); + $logEntry->setAssociatedRevId( $rev->getId() ); } // This relies on the resetArticleID() call in WikiPage::insertOn(), // which is triggered on $descTitle by doEditContent() above. @@ -2692,7 +2694,7 @@ class LocalFileRestoreBatch { // Even if some files could be copied, fail entirely as that is the // easiest thing to do without data loss $this->cleanupFailedBatch( $storeStatus, $storeBatch ); - $status->ok = false; + $status->setOk( false ); $this->file->unlock(); return $status; @@ -2952,7 +2954,7 @@ class LocalFileMoveBatch { if ( !$statusDb->isGood() ) { $destFile->unlock(); $this->file->unlock(); - $statusDb->ok = false; + $statusDb->setOK( false ); return $statusDb; } @@ -2971,7 +2973,7 @@ class LocalFileMoveBatch { $this->file->unlock(); wfDebugLog( 'imagemove', "Error in moving files: " . $statusMove->getWikiText( false, false, 'en' ) ); - $statusMove->ok = false; + $statusMove->setOK( false ); return $statusMove; } -- 2.20.1