X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fpage%2FWikiPage.php;h=ca7d74703f586df6736fa978c1a61fbf7a402864;hp=544d23d290e542c3b95302c9a36a4683c11e33ba;hb=a21ae2edac758807a2c466be2f5016d87fb526ef;hpb=78aea614f0ca9d7ddcbc329e2cc67c838efd72cb diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 544d23d290..ca7d74703f 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -1036,11 +1036,15 @@ class WikiPage implements Page, IDBAccessObject { $dbr = wfGetDB( DB_REPLICA ); - $tables = [ 'revision', 'user' ]; + $actorMigration = ActorMigration::newMigration(); + $actorQuery = $actorMigration->getJoin( 'rev_user' ); + + $tables = array_merge( [ 'revision' ], $actorQuery['tables'], [ 'user' ] ); $fields = [ - 'user_id' => 'rev_user', - 'user_name' => 'rev_user_text', + 'user_id' => $actorQuery['fields']['rev_user'], + 'user_name' => $actorQuery['fields']['rev_user_text'], + 'actor_id' => $actorQuery['fields']['rev_actor'], 'user_real_name' => 'MIN(user_real_name)', 'timestamp' => 'MAX(rev_timestamp)', ]; @@ -1049,22 +1053,20 @@ class WikiPage implements Page, IDBAccessObject { // The user who made the top revision gets credited as "this page was last edited by // John, based on contributions by Tom, Dick and Harry", so don't include them twice. - $user = $this->getUser(); - if ( $user ) { - $conds[] = "rev_user != $user"; - } else { - $conds[] = "rev_user_text != {$dbr->addQuotes( $this->getUserText() )}"; - } + $user = $this->getUser() + ? User::newFromId( $this->getUser() ) + : User::newFromName( $this->getUserText(), false ); + $conds[] = 'NOT(' . $actorMigration->getWhere( $dbr, 'rev_user', $user )['conds'] . ')'; // Username hidden? $conds[] = "{$dbr->bitAnd( 'rev_deleted', Revision::DELETED_USER )} = 0"; $jconds = [ - 'user' => [ 'LEFT JOIN', 'rev_user = user_id' ], - ]; + 'user' => [ 'LEFT JOIN', $actorQuery['fields']['rev_user'] . ' = user_id' ], + ] + $actorQuery['joins']; $options = [ - 'GROUP BY' => [ 'rev_user', 'rev_user_text' ], + 'GROUP BY' => [ $fields['user_id'], $fields['user_name'] ], 'ORDER BY' => 'timestamp DESC', ]; @@ -2772,7 +2774,7 @@ class WikiPage implements Page, IDBAccessObject { * @param int $u1 Unused * @param bool $u2 Unused * @param array|string &$error Array of errors to append to - * @param User $user The deleting user + * @param User $deleter The deleting user * @param array $tags Tags to apply to the deletion action * @param string $logsubtype * @return Status Status object; if successful, $status->value is the log_id of the @@ -2780,10 +2782,11 @@ class WikiPage implements Page, IDBAccessObject { * found, $status is a non-fatal 'cannotdelete' error */ public function doDeleteArticleReal( - $reason, $suppress = false, $u1 = null, $u2 = null, &$error = '', User $user = null, + $reason, $suppress = false, $u1 = null, $u2 = null, &$error = '', User $deleter = null, $tags = [], $logsubtype = 'delete' ) { - global $wgUser, $wgContentHandlerUseDB, $wgCommentTableSchemaMigrationStage; + global $wgUser, $wgContentHandlerUseDB, $wgCommentTableSchemaMigrationStage, + $wgActorTableSchemaMigrationStage; wfDebug( __METHOD__ . "\n" ); @@ -2798,9 +2801,9 @@ class WikiPage implements Page, IDBAccessObject { // Avoid PHP 7.1 warning of passing $this by reference $wikiPage = $this; - $user = is_null( $user ) ? $wgUser : $user; + $deleter = is_null( $deleter ) ? $wgUser : $deleter; if ( !Hooks::run( 'ArticleDelete', - [ &$wikiPage, &$user, &$reason, &$error, &$status, $suppress ] + [ &$wikiPage, &$deleter, &$reason, &$error, &$status, $suppress ] ) ) { if ( $status->isOK() ) { // Hook aborted but didn't set a fatal status @@ -2848,6 +2851,7 @@ class WikiPage implements Page, IDBAccessObject { } $commentStore = CommentStore::getStore(); + $actorMigration = ActorMigration::newMigration(); $revQuery = Revision::getQueryInfo(); $bitfield = false; @@ -2884,11 +2888,10 @@ class WikiPage implements Page, IDBAccessObject { foreach ( $res as $row ) { $comment = $commentStore->getComment( 'rev_comment', $row ); + $user = User::newFromAnyId( $row->rev_user, $row->rev_user_text, $row->rev_actor ); $rowInsert = [ 'ar_namespace' => $namespace, 'ar_title' => $dbKey, - 'ar_user' => $row->rev_user, - 'ar_user_text' => $row->rev_user_text, 'ar_timestamp' => $row->rev_timestamp, 'ar_minor_edit' => $row->rev_minor_edit, 'ar_rev_id' => $row->rev_id, @@ -2900,7 +2903,8 @@ class WikiPage implements Page, IDBAccessObject { 'ar_page_id' => $id, 'ar_deleted' => $suppress ? $bitfield : $row->rev_deleted, 'ar_sha1' => $row->rev_sha1, - ] + $commentStore->insert( $dbw, 'ar_comment', $comment ); + ] + $commentStore->insert( $dbw, 'ar_comment', $comment ) + + $actorMigration->getInsertValues( $dbw, 'ar_user', $user ); if ( $wgContentHandlerUseDB ) { $rowInsert['ar_content_model'] = $row->rev_content_model; $rowInsert['ar_content_format'] = $row->rev_content_format; @@ -2930,6 +2934,9 @@ class WikiPage implements Page, IDBAccessObject { if ( $wgCommentTableSchemaMigrationStage > MIGRATION_OLD ) { $dbw->delete( 'revision_comment_temp', [ 'revcomment_rev' => $revids ], __METHOD__ ); } + if ( $wgActorTableSchemaMigrationStage > MIGRATION_OLD ) { + $dbw->delete( 'revision_actor_temp', [ 'revactor_rev' => $revids ], __METHOD__ ); + } // Also delete records from ip_changes as applicable. if ( count( $ipRevIds ) > 0 ) { @@ -2940,7 +2947,7 @@ class WikiPage implements Page, IDBAccessObject { $logtype = $suppress ? 'suppress' : 'delete'; $logEntry = new ManualLogEntry( $logtype, $logsubtype ); - $logEntry->setPerformer( $user ); + $logEntry->setPerformer( $deleter ); $logEntry->setTarget( $logTitle ); $logEntry->setComment( $reason ); $logEntry->setTags( $tags ); @@ -2956,11 +2963,11 @@ class WikiPage implements Page, IDBAccessObject { $dbw->endAtomic( __METHOD__ ); - $this->doDeleteUpdates( $id, $content, $revision, $user ); + $this->doDeleteUpdates( $id, $content, $revision, $deleter ); Hooks::run( 'ArticleDeleteComplete', [ &$wikiPageBeforeDelete, - &$user, + &$deleter, $reason, $id, $content, @@ -3161,16 +3168,31 @@ class WikiPage implements Page, IDBAccessObject { // Get the last edit not by this person... // Note: these may not be public values - $user = intval( $current->getUser( Revision::RAW ) ); - $user_text = $dbw->addQuotes( $current->getUserText( Revision::RAW ) ); - $s = $dbw->selectRow( 'revision', + $userId = intval( $current->getUser( Revision::RAW ) ); + $userName = $current->getUserText( Revision::RAW ); + if ( $userId ) { + $user = User::newFromId( $userId ); + $user->setName( $userName ); + } else { + $user = User::newFromName( $current->getUserText( Revision::RAW ), false ); + } + + $actorWhere = ActorMigration::newMigration()->getWhere( $dbw, 'rev_user', $user ); + + $s = $dbw->selectRow( + [ 'revision' ] + $actorWhere['tables'], [ 'rev_id', 'rev_timestamp', 'rev_deleted' ], - [ 'rev_page' => $current->getPage(), - "rev_user != {$user} OR rev_user_text != {$user_text}" - ], __METHOD__, - [ 'USE INDEX' => 'page_timestamp', - 'ORDER BY' => 'rev_timestamp DESC' ] - ); + [ + 'rev_page' => $current->getPage(), + 'NOT(' . $actorWhere['conds'] . ')', + ], + __METHOD__, + [ + 'USE INDEX' => [ 'revision' => 'page_timestamp' ], + 'ORDER BY' => 'rev_timestamp DESC' + ], + $actorWhere['joins'] + ); if ( $s === false ) { // No one else ever edited this page return [ [ 'cantrollback' ] ]; @@ -3249,11 +3271,12 @@ class WikiPage implements Page, IDBAccessObject { } if ( count( $set ) ) { + $actorWhere = ActorMigration::newMigration()->getWhere( $dbw, 'rc_user', $user, false ); $dbw->update( 'recentchanges', $set, [ /* WHERE */ 'rc_cur_id' => $current->getPage(), - 'rc_user_text' => $current->getUserText(), 'rc_timestamp > ' . $dbw->addQuotes( $s->rev_timestamp ), + $actorWhere['conds'], // No tables/joins are needed for rc_user ], __METHOD__ );