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
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
;
32 * List for filearchive table items
34 class RevDelArchivedFileList
extends RevDelFileList
{
37 * @param IContextSource $context
38 * @param PageIdentity $page
40 * @param LBFactory $lbFactory
41 * @param HTMLCacheUpdater $htmlCacheUpdater
42 * @param RepoGroup $repoGroup
44 public function __construct(
45 IContextSource
$context,
49 HTMLCacheUpdater
$htmlCacheUpdater,
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() {
70 public static function getRelationType() {
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 );