X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Frevisiondelete%2FRevDelList.php;h=89025bc61a884f94e848a2b126daa2f5d0c0d295;hp=64a6aec806d593e0806725d19ee7cc5f5c8ac8ab;hb=27c61fb1e94da9114314468fd00bcf129ec064b6;hpb=ef96494e66ca6d36313dd08847c32aea93911c39 diff --git a/includes/revisiondelete/RevDelList.php b/includes/revisiondelete/RevDelList.php index 64a6aec806..89025bc61a 100644 --- a/includes/revisiondelete/RevDelList.php +++ b/includes/revisiondelete/RevDelList.php @@ -83,7 +83,7 @@ abstract class RevDelList extends RevisionListBase { public function areAnySuppressed() { $bit = $this->getSuppressBit(); - /** @var $item RevDelItem */ + /** @var RevDelItem $item */ foreach ( $this as $item ) { if ( $item->getBits() & $bit ) { return true; @@ -106,6 +106,8 @@ abstract class RevDelList extends RevisionListBase { * @since 1.23 Added 'perItemStatus' param */ public function setVisibility( array $params ) { + global $wgActorTableSchemaMigrationStage; + $status = Status::newGood(); $bitPars = $params['value']; @@ -134,7 +136,7 @@ abstract class RevDelList extends RevisionListBase { $missing = array_flip( $this->ids ); $this->clearFileOps(); $idsForLog = []; - $authorIds = $authorIPs = []; + $authorIds = $authorIPs = $authorActors = []; if ( $perItemStatus ) { $status->itemStatuses = []; @@ -151,7 +153,7 @@ abstract class RevDelList extends RevisionListBase { // passed to doPostCommitUpdates(). $visibilityChangeMap = []; - /** @var $item RevDelItem */ + /** @var RevDelItem $item */ foreach ( $this as $item ) { unset( $missing[$item->getId()] ); @@ -216,10 +218,15 @@ abstract class RevDelList extends RevisionListBase { $virtualOldBits |= $removedBits; $status->successCount++; - if ( $item->getAuthorId() > 0 ) { - $authorIds[] = $item->getAuthorId(); - } elseif ( IP::isIPAddress( $item->getAuthorName() ) ) { - $authorIPs[] = $item->getAuthorName(); + if ( $wgActorTableSchemaMigrationStage <= MIGRATION_WRITE_BOTH ) { + if ( $item->getAuthorId() > 0 ) { + $authorIds[] = $item->getAuthorId(); + } elseif ( IP::isIPAddress( $item->getAuthorName() ) ) { + $authorIPs[] = $item->getAuthorName(); + } + } + if ( $wgActorTableSchemaMigrationStage >= MIGRATION_WRITE_BOTH ) { + $authorActors[] = $item->getAuthorActor(); } // Save the old and new bits in $visibilityChangeMap for @@ -263,6 +270,14 @@ abstract class RevDelList extends RevisionListBase { } // Log it + $authorFields = []; + if ( $wgActorTableSchemaMigrationStage <= MIGRATION_WRITE_BOTH ) { + $authorFields['authorIds'] = $authorIds; + $authorFields['authorIPs'] = $authorIPs; + } + if ( $wgActorTableSchemaMigrationStage >= MIGRATION_WRITE_BOTH ) { + $authorFields['authorActors'] = $authorActors; + } $this->updateLog( $logType, [ @@ -272,10 +287,8 @@ abstract class RevDelList extends RevisionListBase { 'oldBits' => $virtualOldBits, 'comment' => $comment, 'ids' => $idsForLog, - 'authorIds' => $authorIds, - 'authorIPs' => $authorIPs, 'tags' => isset( $params['tags'] ) ? $params['tags'] : [], - ] + ] + $authorFields ); // Clear caches after commit @@ -294,7 +307,7 @@ abstract class RevDelList extends RevisionListBase { final protected function acquireItemLocks() { $status = Status::newGood(); - /** @var $item RevDelItem */ + /** @var RevDelItem $item */ foreach ( $this as $item ) { $status->merge( $item->lock() ); } @@ -304,7 +317,7 @@ abstract class RevDelList extends RevisionListBase { final protected function releaseItemLocks() { $status = Status::newGood(); - /** @var $item RevDelItem */ + /** @var RevDelItem $item */ foreach ( $this as $item ) { $status->merge( $item->unlock() ); } @@ -330,8 +343,9 @@ abstract class RevDelList extends RevisionListBase { * title: The target title * ids: The ID list * comment: The log comment - * authorsIds: The array of the user IDs of the offenders - * authorsIPs: The array of the IP/anon user offenders + * authorIds: The array of the user IDs of the offenders + * authorIPs: The array of the IP/anon user offenders + * authorActors: The array of the actor IDs of the offenders * tags: The array of change tags to apply to the log entry * @throws MWException */ @@ -350,11 +364,21 @@ abstract class RevDelList extends RevisionListBase { $logEntry->setParameters( $logParams ); $logEntry->setPerformer( $this->getUser() ); // Allow for easy searching of deletion log items for revision/log items - $logEntry->setRelations( [ + $relations = [ $field => $params['ids'], - 'target_author_id' => $params['authorIds'], - 'target_author_ip' => $params['authorIPs'], - ] ); + ]; + if ( isset( $params['authorIds'] ) ) { + $relations += [ + 'target_author_id' => $params['authorIds'], + 'target_author_ip' => $params['authorIPs'], + ]; + } + if ( isset( $params['authorActors'] ) ) { + $relations += [ + 'target_author_actor' => $params['authorActors'], + ]; + } + $logEntry->setRelations( $relations ); // Apply change tags to the log entry $logEntry->setTags( $params['tags'] ); $logId = $logEntry->insert(); @@ -402,7 +426,7 @@ abstract class RevDelList extends RevisionListBase { /** * A hook for setVisibility(): do any necessary updates post-commit. * STUB - * @param array [id => ['oldBits' => $oldBits, 'newBits' => $newBits], ... ] + * @param array $visibilityChangeMap [id => ['oldBits' => $oldBits, 'newBits' => $newBits], ... ] * @return Status */ public function doPostCommitUpdates( array $visibilityChangeMap ) {