Merge "Add attributes parameter to ShowSearchHitTitle"
[lhc/web/wiklou.git] / includes / revisiondelete / RevDelFileList.php
index f485d16..6a6b86c 100644 (file)
  * @ingroup RevisionDelete
  */
 
+use Wikimedia\Rdbms\IDatabase;
+
 /**
  * List for oldimage table items
  */
 class RevDelFileList extends RevDelList {
        /** @var array */
-       var $storeBatch;
+       public $storeBatch;
 
        /** @var array */
-       var $deleteBatch;
+       public $deleteBatch;
 
        /** @var array */
-       var $cleanupBatch;
+       public $cleanupBatch;
 
        public function getType() {
                return 'oldimage';
@@ -49,16 +51,27 @@ class RevDelFileList extends RevDelList {
        }
 
        /**
-        * @param DatabaseBase $db
+        * @param IDatabase $db
         * @return mixed
         */
        public function doQuery( $db ) {
-               $archiveNames = array();
+               $archiveNames = [];
                foreach ( $this->ids as $timestamp ) {
                        $archiveNames[] = $timestamp . '!' . $this->title->getDBkey();
                }
 
-               return $db->select( 'oldimage', OldLocalFile::selectFields(), array( 'oi_name' => $this->title->getDBkey(), 'oi_archive_name' => $archiveNames ), __METHOD__, array( 'ORDER BY' => 'oi_timestamp DESC' ) );
+               $oiQuery = OldLocalFile::getQueryInfo();
+               return $db->select(
+                       $oiQuery['tables'],
+                       $oiQuery['fields'],
+                       [
+                               'oi_name' => $this->title->getDBkey(),
+                               'oi_archive_name' => $archiveNames
+                       ],
+                       __METHOD__,
+                       [ 'ORDER BY' => 'oi_timestamp DESC' ],
+                       $oiQuery['joins']
+               );
        }
 
        public function newItem( $row ) {
@@ -66,9 +79,9 @@ class RevDelFileList extends RevDelList {
        }
 
        public function clearFileOps() {
-               $this->deleteBatch = array();
-               $this->storeBatch = array();
-               $this->cleanupBatch = array();
+               $this->deleteBatch = [];
+               $this->storeBatch = [];
+               $this->cleanupBatch = [];
        }
 
        public function doPreCommitUpdates() {
@@ -95,20 +108,22 @@ class RevDelFileList extends RevDelList {
                return $status;
        }
 
-       public function doPostCommitUpdates() {
+       public function doPostCommitUpdates( array $visibilityChangeMap ) {
                $file = wfLocalFile( $this->title );
                $file->purgeCache();
                $file->purgeDescription();
-               $purgeUrls = array();
+
+               // Purge full images from cache
+               $purgeUrls = [];
                foreach ( $this->ids as $timestamp ) {
                        $archiveName = $timestamp . '!' . $this->title->getDBkey();
                        $file->purgeOldThumbnails( $archiveName );
                        $purgeUrls[] = $file->getArchiveUrl( $archiveName );
                }
-               if ( $this->getConfig()->get( 'UseSquid' ) ) {
-                       // purge full images from cache
-                       SquidUpdate::purge( $purgeUrls );
-               }
+               DeferredUpdates::addUpdate(
+                       new CdnCacheUpdate( $purgeUrls ),
+                       DeferredUpdates::PRESEND
+               );
 
                return Status::newGood();
        }
@@ -116,4 +131,4 @@ class RevDelFileList extends RevDelList {
        public function getSuppressBit() {
                return File::DELETED_RESTRICTED;
        }
-}
\ No newline at end of file
+}