X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=includes%2Frevisiondelete%2FRevDelList.php;h=c5cffea505a08a3bf3ef96b91dee4883011bfe04;hb=b7a4e825455ecf802feba5cd62c7d01a772be4d3;hp=011c7b09dbf25c37373ac549955cd758e9ab077b;hpb=03cd9495a4dac1c1cda738d52e74b553b977beb8;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/revisiondelete/RevDelList.php b/includes/revisiondelete/RevDelList.php index 011c7b09db..c5cffea505 100644 --- a/includes/revisiondelete/RevDelList.php +++ b/includes/revisiondelete/RevDelList.php @@ -106,11 +106,13 @@ abstract class RevDelList extends RevisionListBase { * @since 1.23 Added 'perItemStatus' param */ public function setVisibility( array $params ) { + global $wgActorTableSchemaMigrationStage; + $status = Status::newGood(); $bitPars = $params['value']; $comment = $params['comment']; - $perItemStatus = isset( $params['perItemStatus'] ) ? $params['perItemStatus'] : false; + $perItemStatus = $params['perItemStatus'] ?? false; // CAS-style checks are done on the _deleted fields so the select // does not need to use FOR UPDATE nor be in the atomic section @@ -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 = []; @@ -205,7 +207,7 @@ abstract class RevDelList extends RevisionListBase { if ( $ok ) { $idsForLog[] = $item->getId(); - // If any item field was suppressed or unsupressed + // If any item field was suppressed or unsuppressed if ( ( $oldBits | $newBits ) & $this->getSuppressBit() ) { $logType = 'suppress'; } @@ -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'] : [], - ] + 'tags' => $params['tags'] ?? [], + ] + $authorFields ); // Clear caches after commit @@ -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();