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 Wikimedia\Rdbms\IDatabase
;
25 * List for oldimage table items
27 class RevDelFileList
extends RevDelList
{
37 public function getType() {
41 public static function getRelationType() {
42 return 'oi_archive_name';
45 public static function getRestriction() {
46 return 'deleterevision';
49 public static function getRevdelConstant() {
50 return File
::DELETED_FILE
;
54 * @param IDatabase $db
57 public function doQuery( $db ) {
59 foreach ( $this->ids
as $timestamp ) {
60 $archiveNames[] = $timestamp . '!' . $this->title
->getDBkey();
63 $oiQuery = OldLocalFile
::getQueryInfo();
68 'oi_name' => $this->title
->getDBkey(),
69 'oi_archive_name' => $archiveNames
72 [ 'ORDER BY' => 'oi_timestamp DESC' ],
77 public function newItem( $row ) {
78 return new RevDelFileItem( $this, $row );
81 public function clearFileOps() {
82 $this->deleteBatch
= [];
83 $this->storeBatch
= [];
84 $this->cleanupBatch
= [];
87 public function doPreCommitUpdates() {
88 $status = Status
::newGood();
89 $repo = RepoGroup
::singleton()->getLocalRepo();
90 if ( $this->storeBatch
) {
91 $status->merge( $repo->storeBatch( $this->storeBatch
, FileRepo
::OVERWRITE_SAME
) );
93 if ( !$status->isOK() ) {
96 if ( $this->deleteBatch
) {
97 $status->merge( $repo->deleteBatch( $this->deleteBatch
) );
99 if ( !$status->isOK() ) {
100 // Running cleanupDeletedBatch() after a failed storeBatch() with the DB already
101 // modified (but destined for rollback) causes data loss
104 if ( $this->cleanupBatch
) {
105 $status->merge( $repo->cleanupDeletedBatch( $this->cleanupBatch
) );
111 public function doPostCommitUpdates( array $visibilityChangeMap ) {
112 $file = wfLocalFile( $this->title
);
114 $file->purgeDescription();
116 // Purge full images from cache
118 foreach ( $this->ids
as $timestamp ) {
119 $archiveName = $timestamp . '!' . $this->title
->getDBkey();
120 $file->purgeOldThumbnails( $archiveName );
121 $purgeUrls[] = $file->getArchiveUrl( $archiveName );
123 DeferredUpdates
::addUpdate(
124 new CdnCacheUpdate( $purgeUrls ),
125 DeferredUpdates
::PRESEND
128 return Status
::newGood();
131 public function getSuppressBit() {
132 return File
::DELETED_RESTRICTED
;