Merge "Log DNS blacklist matches with info level, non-matches with debug level"
[lhc/web/wiklou.git] / includes / filerepo / file / ArchivedFile.php
index d9763c6..b4fd176 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup FileAbstraction
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Class representing a row of the 'filearchive' table
  *
@@ -92,6 +94,9 @@ class ArchivedFile {
        /** @var Title */
        protected $title; # image title
 
+       /** @var bool */
+       private $exists;
+
        /**
         * @throws MWException
         * @param Title $title
@@ -167,7 +172,7 @@ class ArchivedFile {
                        $conds['fa_sha1'] = $this->sha1;
                }
 
-               if ( !count( $conds ) ) {
+               if ( $conds === [] ) {
                        throw new MWException( "No specific information for retrieving archived file" );
                }
 
@@ -211,49 +216,6 @@ class ArchivedFile {
                return $file;
        }
 
-       /**
-        * Fields in the filearchive table
-        * @deprecated since 1.31, use self::getQueryInfo() instead.
-        * @return string[]
-        */
-       static function selectFields() {
-               global $wgActorTableSchemaMigrationStage;
-
-               if ( $wgActorTableSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
-                       // If code is using this instead of self::getQueryInfo(), there's a
-                       // decent chance it's going to try to directly access
-                       // $row->fa_user or $row->fa_user_text and we can't give it
-                       // useful values here once those aren't being written anymore.
-                       throw new BadMethodCallException(
-                               'Cannot use ' . __METHOD__ . ' when $wgActorTableSchemaMigrationStage > MIGRATION_WRITE_BOTH'
-                       );
-               }
-
-               wfDeprecated( __METHOD__, '1.31' );
-               return [
-                       'fa_id',
-                       'fa_name',
-                       'fa_archive_name',
-                       'fa_storage_key',
-                       'fa_storage_group',
-                       'fa_size',
-                       'fa_bits',
-                       'fa_width',
-                       'fa_height',
-                       'fa_metadata',
-                       'fa_media_type',
-                       'fa_major_mime',
-                       'fa_minor_mime',
-                       'fa_user',
-                       'fa_user_text',
-                       'fa_actor' => $wgActorTableSchemaMigrationStage > MIGRATION_OLD ? 'fa_actor' : null,
-                       'fa_timestamp',
-                       'fa_deleted',
-                       'fa_deleted_timestamp', /* Used by LocalFileRestoreBatch */
-                       'fa_sha1',
-               ] + CommentStore::getStore()->getFields( 'fa_description' );
-       }
-
        /**
         * Return the tables, fields, and join conditions to be selected to create
         * a new archivedfile object.
@@ -264,7 +226,7 @@ class ArchivedFile {
         *   - joins: (array) to include in the `$join_conds` to `IDatabase->select()`
         */
        public static function getQueryInfo() {
-               $commentQuery = CommentStore::getStore()->getJoin( 'fa_description' );
+               $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'fa_description' );
                $actorQuery = ActorMigration::newMigration()->getJoin( 'fa_user' );
                return [
                        'tables' => [ 'filearchive' ] + $commentQuery['tables'] + $actorQuery['tables'],
@@ -310,7 +272,7 @@ class ArchivedFile {
                $this->metadata = $row->fa_metadata;
                $this->mime = "$row->fa_major_mime/$row->fa_minor_mime";
                $this->media_type = $row->fa_media_type;
-               $this->description = CommentStore::getStore()
+               $this->description = MediaWikiServices::getInstance()->getCommentStore()
                        // Legacy because $row may have come from self::selectFields()
                        ->getCommentLegacy( wfGetDB( DB_REPLICA ), 'fa_description', $row )->text;
                $this->user = User::newFromAnyId( $row->fa_user, $row->fa_user_text, $row->fa_actor );