f485d16f7932e685df7cbd4fee3b6c5b52612f62
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 DatabaseBase $db
55 public function doQuery( $db ) {
56 $archiveNames = array();
57 foreach ( $this->ids
as $timestamp ) {
58 $archiveNames[] = $timestamp . '!' . $this->title
->getDBkey();
61 return $db->select( 'oldimage', OldLocalFile
::selectFields(), array( 'oi_name' => $this->title
->getDBkey(), 'oi_archive_name' => $archiveNames ), __METHOD__
, array( 'ORDER BY' => 'oi_timestamp DESC' ) );
64 public function newItem( $row ) {
65 return new RevDelFileItem( $this, $row );
68 public function clearFileOps() {
69 $this->deleteBatch
= array();
70 $this->storeBatch
= array();
71 $this->cleanupBatch
= array();
74 public function doPreCommitUpdates() {
75 $status = Status
::newGood();
76 $repo = RepoGroup
::singleton()->getLocalRepo();
77 if ( $this->storeBatch
) {
78 $status->merge( $repo->storeBatch( $this->storeBatch
, FileRepo
::OVERWRITE_SAME
) );
80 if ( !$status->isOK() ) {
83 if ( $this->deleteBatch
) {
84 $status->merge( $repo->deleteBatch( $this->deleteBatch
) );
86 if ( !$status->isOK() ) {
87 // Running cleanupDeletedBatch() after a failed storeBatch() with the DB already
88 // modified (but destined for rollback) causes data loss
91 if ( $this->cleanupBatch
) {
92 $status->merge( $repo->cleanupDeletedBatch( $this->cleanupBatch
) );
98 public function doPostCommitUpdates() {
99 $file = wfLocalFile( $this->title
);
101 $file->purgeDescription();
102 $purgeUrls = array();
103 foreach ( $this->ids
as $timestamp ) {
104 $archiveName = $timestamp . '!' . $this->title
->getDBkey();
105 $file->purgeOldThumbnails( $archiveName );
106 $purgeUrls[] = $file->getArchiveUrl( $archiveName );
108 if ( $this->getConfig()->get( 'UseSquid' ) ) {
109 // purge full images from cache
110 SquidUpdate
::purge( $purgeUrls );
113 return Status
::newGood();
116 public function getSuppressBit() {
117 return File
::DELETED_RESTRICTED
;