X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Ffilerepo%2Ffile%2FLocalFileDeleteBatch.php;h=85988f6141707f34abc6aea6d77f5824c0d9f3df;hp=ecd63e75dd1770e5a3bdbaf769d72fbac3d773d1;hb=64e7e7d760fc3e043f7e01a89cc3697869aaa93b;hpb=492215443de46267cfaba03829563b79facc612f diff --git a/includes/filerepo/file/LocalFileDeleteBatch.php b/includes/filerepo/file/LocalFileDeleteBatch.php index ecd63e75dd..85988f6141 100644 --- a/includes/filerepo/file/LocalFileDeleteBatch.php +++ b/includes/filerepo/file/LocalFileDeleteBatch.php @@ -22,6 +22,7 @@ */ use MediaWiki\MediaWikiServices; +use MediaWiki\Storage\RevisionRecord; /** * Helper class for file deletion @@ -62,12 +63,8 @@ class LocalFileDeleteBatch { $this->file = $file; $this->reason = $reason; $this->suppress = $suppress; - if ( $user ) { - $this->user = $user; - } else { - global $wgUser; - $this->user = $wgUser; - } + global $wgUser; + $this->user = $user ?: $wgUser; $this->status = $file->repo->newGood(); } @@ -181,8 +178,6 @@ class LocalFileDeleteBatch { } protected function doDBInserts() { - global $wgActorTableSchemaMigrationStage; - $now = time(); $dbw = $this->file->repo->getMasterDB(); @@ -199,7 +194,7 @@ class LocalFileDeleteBatch { // Bitfields to further suppress the content if ( $this->suppress ) { - $bitfield = Revision::SUPPRESSED_ALL; + $bitfield = RevisionRecord::SUPPRESSED_ALL; } else { $bitfield = 'oi_deleted'; } @@ -228,7 +223,8 @@ class LocalFileDeleteBatch { 'fa_minor_mime' => 'img_minor_mime', 'fa_description_id' => 'img_description_id', 'fa_timestamp' => 'img_timestamp', - 'fa_sha1' => 'img_sha1' + 'fa_sha1' => 'img_sha1', + 'fa_actor' => 'img_actor', ]; $joins = []; @@ -237,37 +233,6 @@ class LocalFileDeleteBatch { $commentStore->insert( $dbw, 'fa_deleted_reason', $this->reason ) ); - if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) { - $fields['fa_user'] = 'img_user'; - $fields['fa_user_text'] = 'img_user_text'; - } - if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) { - $fields['fa_actor'] = 'img_actor'; - } - - if ( - ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_BOTH ) === SCHEMA_COMPAT_WRITE_BOTH - ) { - // Upgrade any rows that are still old-style. Otherwise an upgrade - // might be missed if a deletion happens while the migration script - // is running. - $res = $dbw->select( - [ 'image' ], - [ 'img_name', 'img_user', 'img_user_text' ], - [ 'img_name' => $this->file->getName(), 'img_actor' => 0 ], - __METHOD__ - ); - foreach ( $res as $row ) { - $actorId = User::newFromAnyId( $row->img_user, $row->img_user_text, null )->getActorId( $dbw ); - $dbw->update( - 'image', - [ 'img_actor' => $actorId ], - [ 'img_name' => $row->img_name, 'img_actor' => 0 ], - __METHOD__ - ); - } - } - $dbw->insertSelect( 'filearchive', $tables, $fields, [ 'img_name' => $this->file->getName() ], __METHOD__, [], [], $joins ); }