Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / revisiondelete / RevDelArchivedFileList.php
blobbbbc1b87ab3e4c6e63363a9404f642d0cfa8a135
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @file
19 * @ingroup RevisionDelete
22 use MediaWiki\Cache\HTMLCacheUpdater;
23 use MediaWiki\Context\IContextSource;
24 use MediaWiki\FileRepo\File\FileSelectQueryBuilder;
25 use MediaWiki\Page\PageIdentity;
26 use Wikimedia\Rdbms\IReadableDatabase;
27 use Wikimedia\Rdbms\IResultWrapper;
28 use Wikimedia\Rdbms\LBFactory;
29 use Wikimedia\Rdbms\SelectQueryBuilder;
31 /**
32 * List for filearchive table items
34 class RevDelArchivedFileList extends RevDelFileList {
36 /**
37 * @param IContextSource $context
38 * @param PageIdentity $page
39 * @param array $ids
40 * @param LBFactory $lbFactory
41 * @param HTMLCacheUpdater $htmlCacheUpdater
42 * @param RepoGroup $repoGroup
44 public function __construct(
45 IContextSource $context,
46 PageIdentity $page,
47 array $ids,
48 LBFactory $lbFactory,
49 HTMLCacheUpdater $htmlCacheUpdater,
50 RepoGroup $repoGroup
51 ) {
52 parent::__construct(
53 $context,
54 $page,
55 $ids,
56 $lbFactory,
57 $htmlCacheUpdater,
58 $repoGroup
60 // Technically, we could just inherit the constructor from RevDelFileList,
61 // but since ArchivedFile::getQueryInfo() uses MediaWikiServices it might
62 // be useful to replace at some point with either a callback or a separate
63 // service to allow for unit testing
66 public function getType() {
67 return 'filearchive';
70 public static function getRelationType() {
71 return 'fa_id';
74 /**
75 * @param IReadableDatabase $db
76 * @return IResultWrapper
78 public function doQuery( $db ) {
79 $ids = array_map( 'intval', $this->ids );
81 $queryBuilder = FileSelectQueryBuilder::newForArchivedFile( $db );
82 $queryBuilder->where( [ 'fa_name' => $this->page->getDBkey(), 'fa_id' => $ids ] )
83 ->orderBy( 'fa_id', SelectQueryBuilder::SORT_DESC );
85 return $queryBuilder->caller( __METHOD__ )->fetchResultSet();
88 public function newItem( $row ) {
89 return new RevDelArchivedFileItem( $this, $row );