[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/revisiondelete/ -> RevDelFileList.php (source)

   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  
  22  /**
  23   * List for oldimage table items
  24   */
  25  class RevDelFileList extends RevDelList {
  26      /** @var array */
  27      public $storeBatch;
  28  
  29      /** @var array */
  30      public $deleteBatch;
  31  
  32      /** @var array */
  33      public $cleanupBatch;
  34  
  35  	public function getType() {
  36          return 'oldimage';
  37      }
  38  
  39  	public static function getRelationType() {
  40          return 'oi_archive_name';
  41      }
  42  
  43  	public static function getRestriction() {
  44          return 'deleterevision';
  45      }
  46  
  47  	public static function getRevdelConstant() {
  48          return File::DELETED_FILE;
  49      }
  50  
  51      /**
  52       * @param DatabaseBase $db
  53       * @return mixed
  54       */
  55  	public function doQuery( $db ) {
  56          $archiveNames = array();
  57          foreach ( $this->ids as $timestamp ) {
  58              $archiveNames[] = $timestamp . '!' . $this->title->getDBkey();
  59          }
  60  
  61          return $db->select(
  62              'oldimage',
  63              OldLocalFile::selectFields(),
  64              array(
  65                  'oi_name' => $this->title->getDBkey(),
  66                  'oi_archive_name' => $archiveNames
  67              ),
  68              __METHOD__,
  69              array( 'ORDER BY' => 'oi_timestamp DESC' )
  70          );
  71      }
  72  
  73  	public function newItem( $row ) {
  74          return new RevDelFileItem( $this, $row );
  75      }
  76  
  77  	public function clearFileOps() {
  78          $this->deleteBatch = array();
  79          $this->storeBatch = array();
  80          $this->cleanupBatch = array();
  81      }
  82  
  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 ) );
  88          }
  89          if ( !$status->isOK() ) {
  90              return $status;
  91          }
  92          if ( $this->deleteBatch ) {
  93              $status->merge( $repo->deleteBatch( $this->deleteBatch ) );
  94          }
  95          if ( !$status->isOK() ) {
  96              // Running cleanupDeletedBatch() after a failed storeBatch() with the DB already
  97              // modified (but destined for rollback) causes data loss
  98              return $status;
  99          }
 100          if ( $this->cleanupBatch ) {
 101              $status->merge( $repo->cleanupDeletedBatch( $this->cleanupBatch ) );
 102          }
 103  
 104          return $status;
 105      }
 106  
 107  	public function doPostCommitUpdates() {
 108          $file = wfLocalFile( $this->title );
 109          $file->purgeCache();
 110          $file->purgeDescription();
 111          $purgeUrls = array();
 112          foreach ( $this->ids as $timestamp ) {
 113              $archiveName = $timestamp . '!' . $this->title->getDBkey();
 114              $file->purgeOldThumbnails( $archiveName );
 115              $purgeUrls[] = $file->getArchiveUrl( $archiveName );
 116          }
 117          if ( $this->getConfig()->get( 'UseSquid' ) ) {
 118              // purge full images from cache
 119              SquidUpdate::purge( $purgeUrls );
 120          }
 121  
 122          return Status::newGood();
 123      }
 124  
 125  	public function getSuppressBit() {
 126          return File::DELETED_RESTRICTED;
 127      }
 128  }


Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1