X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryDeletedrevs.php;h=4fbc1575b322e51ddf269bd7153d937f1ea36db4;hb=45cf5258871867a159c264983e8dc60ed083d9fe;hp=e84b9b22471562b68dbd24c60d6574563a8a853b;hpb=9c0eeb1a2d985f77134385975bf611ddc2bb8c7b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryDeletedrevs.php b/includes/api/ApiQueryDeletedrevs.php index e84b9b2247..4fbc1575b3 100644 --- a/includes/api/ApiQueryDeletedrevs.php +++ b/includes/api/ApiQueryDeletedrevs.php @@ -36,8 +36,6 @@ class ApiQueryDeletedrevs extends ApiQueryBase { } public function execute() { - global $wgChangeTagsSchemaMigrationStage; - // Before doing anything at all, let's check permissions $this->checkUserRightsAny( 'deletedhistory' ); @@ -61,10 +59,6 @@ class ApiQueryDeletedrevs extends ApiQueryBase { $fld_token = isset( $prop['token'] ); $fld_tags = isset( $prop['tags'] ); - if ( isset( $prop['token'] ) ) { - $p = $this->getModulePrefix(); - } - // If we're in a mode that breaks the same-origin policy, no tokens can // be obtained if ( $this->lacksSameOriginSecurity() ) { @@ -110,62 +104,33 @@ class ApiQueryDeletedrevs extends ApiQueryBase { $this->dieWithError( 'user and excludeuser cannot be used together', 'badparams' ); } - $this->addTables( 'archive' ); - $this->addFields( [ 'ar_title', 'ar_namespace', 'ar_timestamp', 'ar_deleted', 'ar_id' ] ); - - $this->addFieldsIf( 'ar_parent_id', $fld_parentid ); - $this->addFieldsIf( 'ar_rev_id', $fld_revid ); - if ( $fld_user || $fld_userid ) { - $actorQuery = ActorMigration::newMigration()->getJoin( 'ar_user' ); - $this->addTables( $actorQuery['tables'] ); - $this->addFields( $actorQuery['fields'] ); - $this->addJoinConds( $actorQuery['joins'] ); - } - $this->addFieldsIf( 'ar_minor_edit', $fld_minor ); - $this->addFieldsIf( 'ar_len', $fld_len ); - $this->addFieldsIf( 'ar_sha1', $fld_sha1 ); - - if ( $fld_comment || $fld_parsedcomment ) { - $commentQuery = $commentStore->getJoin( 'ar_comment' ); - $this->addTables( $commentQuery['tables'] ); - $this->addFields( $commentQuery['fields'] ); - $this->addJoinConds( $commentQuery['joins'] ); - } + $revisionStore = MediaWikiServices::getInstance()->getRevisionStore(); + $arQuery = $revisionStore->getArchiveQueryInfo(); + $this->addTables( $arQuery['tables'] ); + $this->addFields( $arQuery['fields'] ); + $this->addJoinConds( $arQuery['joins'] ); + $this->addFields( [ 'ar_title', 'ar_namespace' ] ); if ( $fld_tags ) { - $this->addTables( 'tag_summary' ); - $this->addJoinConds( - [ 'tag_summary' => [ 'LEFT JOIN', [ 'ar_rev_id=ts_rev_id' ] ] ] - ); - $this->addFields( 'ts_tags' ); + $this->addFields( [ 'ts_tags' => ChangeTags::makeTagSummarySubquery( 'archive' ) ] ); } if ( !is_null( $params['tag'] ) ) { $this->addTables( 'change_tag' ); $this->addJoinConds( - [ 'change_tag' => [ 'INNER JOIN', [ 'ar_rev_id=ct_rev_id' ] ] ] + [ 'change_tag' => [ 'JOIN', [ 'ar_rev_id=ct_rev_id' ] ] ] ); - if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) { - $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore(); - try { - $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) ); - } catch ( NameTableAccessException $exception ) { - // Return nothing. - $this->addWhere( '1=0' ); - } - } else { - $this->addWhereFld( 'ct_tag', $params['tag'] ); + $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore(); + try { + $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) ); + } catch ( NameTableAccessException $exception ) { + // Return nothing. + $this->addWhere( '1=0' ); } } + // This means stricter restrictions if ( $fld_content ) { - $this->addTables( 'text' ); - $this->addJoinConds( - [ 'text' => [ 'LEFT JOIN', [ 'ar_text_id=old_id' ] ] ] - ); - $this->addFields( [ 'ar_text_id', 'old_text', 'old_flags' ] ); - - // This also means stricter restrictions $this->checkUserRightsAny( [ 'deletedtext', 'undelete' ] ); } // Check limits @@ -248,7 +213,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase { $op = ( $dir == 'newer' ? '>' : '<' ); if ( $mode == 'all' || $mode == 'revs' ) { $this->dieContinueUsageIf( count( $cont ) != 4 ); - $ns = intval( $cont[0] ); + $ns = (int)$cont[0]; $this->dieContinueUsageIf( strval( $ns ) !== $cont[0] ); $title = $db->addQuotes( $cont[1] ); $ts = $db->addQuotes( $db->timestamp( $cont[2] ) ); @@ -317,10 +282,10 @@ class ApiQueryDeletedrevs extends ApiQueryBase { $rev['timestamp'] = wfTimestamp( TS_ISO_8601, $row->ar_timestamp ); if ( $fld_revid ) { - $rev['revid'] = intval( $row->ar_rev_id ); + $rev['revid'] = (int)$row->ar_rev_id; } if ( $fld_parentid && !is_null( $row->ar_parent_id ) ) { - $rev['parentid'] = intval( $row->ar_parent_id ); + $rev['parentid'] = (int)$row->ar_parent_id; } if ( $fld_user || $fld_userid ) { if ( $row->ar_deleted & Revision::DELETED_USER ) { @@ -379,7 +344,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase { $anyHidden = true; } if ( Revision::userCanBitfield( $row->ar_deleted, Revision::DELETED_TEXT, $user ) ) { - ApiResult::setContentValue( $rev, 'text', Revision::getRevisionText( $row ) ); + ApiResult::setContentValue( $rev, 'text', Revision::getRevisionText( $row, 'ar_' ) ); } }