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
23 * List for oldimage table items
25 class RevDelFileList
extends RevDelList
{
35 public function getType() {
39 public static function getRelationType() {
40 return 'oi_archive_name';
43 public static function getRestriction() {
44 return 'deleterevision';
47 public static function getRevdelConstant() {
48 return File
::DELETED_FILE
;
52 * @param IDatabase $db
55 public function doQuery( $db ) {
57 foreach ( $this->ids
as $timestamp ) {
58 $archiveNames[] = $timestamp . '!' . $this->title
->getDBkey();
63 OldLocalFile
::selectFields(),
65 'oi_name' => $this->title
->getDBkey(),
66 'oi_archive_name' => $archiveNames
69 [ 'ORDER BY' => 'oi_timestamp DESC' ]
73 public function newItem( $row ) {
74 return new RevDelFileItem( $this, $row );
77 public function clearFileOps() {
78 $this->deleteBatch
= [];
79 $this->storeBatch
= [];
80 $this->cleanupBatch
= [];
83 public function doPreCommitUpdates() {
84 $status = Status
::newGood();
85 $repo = RepoGroup
::singleton()->getLocalRepo();
86 if ( $this->storeBatch
) {
87 $status->merge( $repo->storeBatch( $this->storeBatch
, FileRepo
::OVERWRITE_SAME
) );
89 if ( !$status->isOK() ) {
92 if ( $this->deleteBatch
) {
93 $status->merge( $repo->deleteBatch( $this->deleteBatch
) );
95 if ( !$status->isOK() ) {
96 // Running cleanupDeletedBatch() after a failed storeBatch() with the DB already
97 // modified (but destined for rollback) causes data loss
100 if ( $this->cleanupBatch
) {
101 $status->merge( $repo->cleanupDeletedBatch( $this->cleanupBatch
) );
107 public function doPostCommitUpdates() {
108 $file = wfLocalFile( $this->title
);
110 $file->purgeDescription();
112 // Purge full images from cache
114 foreach ( $this->ids
as $timestamp ) {
115 $archiveName = $timestamp . '!' . $this->title
->getDBkey();
116 $file->purgeOldThumbnails( $archiveName );
117 $purgeUrls[] = $file->getArchiveUrl( $archiveName );
119 DeferredUpdates
::addUpdate(
120 new CdnCacheUpdate( $purgeUrls ),
121 DeferredUpdates
::PRESEND
124 return Status
::newGood();
127 public function getSuppressBit() {
128 return File
::DELETED_RESTRICTED
;