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. 7 * 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. 12 * 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 17 * 18 * @file 19 * @ingroup RevisionDelete 20 */ 21 22use MediaWiki\HookContainer\HookContainer; 23use MediaWiki\Revision\RevisionStore; 24use Wikimedia\Rdbms\IDatabase; 25use Wikimedia\Rdbms\LBFactory; 26 27/** 28 * List for archive table items, i.e. revisions deleted via action=delete 29 */ 30class RevDelArchiveList extends RevDelRevisionList { 31 32 /** @var RevisionStore */ 33 private $revisionStore; 34 35 /** 36 * @param IContextSource $context 37 * @param Title $title 38 * @param array $ids 39 * @param LBFactory $lbFactory 40 * @param HookContainer $hookContainer 41 * @param HtmlCacheUpdater $htmlCacheUpdater 42 * @param RevisionStore $revisionStore 43 * @param WANObjectCache $wanObjectCache 44 */ 45 public function __construct( 46 IContextSource $context, 47 Title $title, 48 array $ids, 49 LBFactory $lbFactory, 50 HookContainer $hookContainer, 51 HtmlCacheUpdater $htmlCacheUpdater, 52 RevisionStore $revisionStore, 53 WANObjectCache $wanObjectCache 54 ) { 55 parent::__construct( 56 $context, 57 $title, 58 $ids, 59 $lbFactory, 60 $hookContainer, 61 $htmlCacheUpdater, 62 $revisionStore, 63 $wanObjectCache 64 ); 65 $this->revisionStore = $revisionStore; 66 } 67 68 public function getType() { 69 return 'archive'; 70 } 71 72 public static function getRelationType() { 73 return 'ar_timestamp'; 74 } 75 76 /** 77 * @param IDatabase $db 78 * @return mixed 79 */ 80 public function doQuery( $db ) { 81 $timestamps = []; 82 foreach ( $this->ids as $id ) { 83 $timestamps[] = $db->timestamp( $id ); 84 } 85 86 $arQuery = $this->revisionStore->getArchiveQueryInfo(); 87 $tables = $arQuery['tables']; 88 $fields = $arQuery['fields']; 89 $conds = [ 90 'ar_namespace' => $this->title->getNamespace(), 91 'ar_title' => $this->title->getDBkey(), 92 'ar_timestamp' => $timestamps, 93 ]; 94 $join_conds = $arQuery['joins']; 95 $options = [ 'ORDER BY' => 'ar_timestamp DESC' ]; 96 97 ChangeTags::modifyDisplayQuery( 98 $tables, 99 $fields, 100 $conds, 101 $join_conds, 102 $options, 103 '' 104 ); 105 106 return $db->select( $tables, 107 $fields, 108 $conds, 109 __METHOD__, 110 $options, 111 $join_conds 112 ); 113 } 114 115 public function newItem( $row ) { 116 return new RevDelArchiveItem( $this, $row ); 117 } 118 119 public function doPreCommitUpdates() { 120 return Status::newGood(); 121 } 122 123 public function doPostCommitUpdates( array $visibilityChangeMap ) { 124 return Status::newGood(); 125 } 126} 127