/**
* List the revisions of the given page. Returns result wrapper with
- * (ar_minor_edit, ar_timestamp, ar_user, ar_user_text, ar_comment) fields.
+ * various archive table fields.
*
* @return ResultWrapper
*/
public function listRevisions() {
$dbr = wfGetDB( DB_REPLICA );
+ $commentQuery = CommentStore::newKey( 'ar_comment' )->getJoin();
- $tables = [ 'archive' ];
+ $tables = [ 'archive' ] + $commentQuery['tables'];
$fields = [
'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text',
- 'ar_comment', 'ar_len', 'ar_deleted', 'ar_rev_id', 'ar_sha1',
+ 'ar_len', 'ar_deleted', 'ar_rev_id', 'ar_sha1',
'ar_page_id'
- ];
+ ] + $commentQuery['fields'];
if ( $this->config->get( 'ContentHandlerUseDB' ) ) {
$fields[] = 'ar_content_format';
$options = [ 'ORDER BY' => 'ar_timestamp DESC' ];
- $join_conds = [];
+ $join_conds = [] + $commentQuery['joins'];
ChangeTags::modifyDisplayQuery(
$tables,
*/
public function getRevision( $timestamp ) {
$dbr = wfGetDB( DB_REPLICA );
+ $commentQuery = CommentStore::newKey( 'ar_comment' )->getJoin();
+
+ $tables = [ 'archive' ] + $commentQuery['tables'];
$fields = [
'ar_rev_id',
'ar_text',
- 'ar_comment',
'ar_user',
'ar_user_text',
'ar_timestamp',
'ar_deleted',
'ar_len',
'ar_sha1',
- ];
+ ] + $commentQuery['fields'];
if ( $this->config->get( 'ContentHandlerUseDB' ) ) {
$fields[] = 'ar_content_format';
$fields[] = 'ar_content_model';
}
- $row = $dbr->selectRow( 'archive',
+ $join_conds = [] + $commentQuery['joins'];
+
+ $row = $dbr->selectRow(
+ $tables,
$fields,
- [ 'ar_namespace' => $this->title->getNamespace(),
+ [
+ 'ar_namespace' => $this->title->getNamespace(),
'ar_title' => $this->title->getDBkey(),
- 'ar_timestamp' => $dbr->timestamp( $timestamp ) ],
- __METHOD__ );
+ 'ar_timestamp' => $dbr->timestamp( $timestamp )
+ ],
+ __METHOD__,
+ [],
+ $join_conds
+ );
if ( $row ) {
return Revision::newFromArchiveRow( $row, [ 'title' => $this->title ] );
// Touch the log!
- if ( $textRestored && $filesRestored ) {
- $reason = wfMessage( 'undeletedrevisions-files' )
- ->numParams( $textRestored, $filesRestored )->inContentLanguage()->text();
- } elseif ( $textRestored ) {
- $reason = wfMessage( 'undeletedrevisions' )->numParams( $textRestored )
- ->inContentLanguage()->text();
- } elseif ( $filesRestored ) {
- $reason = wfMessage( 'undeletedfiles' )->numParams( $filesRestored )
- ->inContentLanguage()->text();
- } else {
+ if ( !$textRestored && !$filesRestored ) {
wfDebug( "Undelete: nothing undeleted...\n" );
return false;
}
- if ( trim( $comment ) != '' ) {
- $reason .= wfMessage( 'colon-separator' )->inContentLanguage()->text() . $comment;
- }
-
if ( $user === null ) {
global $wgUser;
$user = $wgUser;
$logEntry = new ManualLogEntry( 'delete', 'restore' );
$logEntry->setPerformer( $user );
$logEntry->setTarget( $this->title );
- $logEntry->setComment( $reason );
+ $logEntry->setComment( $comment );
$logEntry->setTags( $tags );
+ $logEntry->setParameters( [
+ ':assoc:count' => [
+ 'revisions' => $textRestored,
+ 'files' => $filesRestored,
+ ],
+ ] );
Hooks::run( 'ArticleUndeleteLogEntry', [ $this, &$logEntry, $user ] );
$logid = $logEntry->insert();
$logEntry->publish( $logid );
- return [ $textRestored, $filesRestored, $reason ];
+ return [ $textRestored, $filesRestored, $comment ];
}
/**
$oldWhere['ar_timestamp'] = array_map( [ &$dbw, 'timestamp' ], $timestamps );
}
+ $commentQuery = CommentStore::newKey( 'ar_comment' )->getJoin();
+
+ $tables = [ 'archive', 'revision' ] + $commentQuery['tables'];
+
$fields = [
'ar_id',
'ar_rev_id',
'rev_id',
'ar_text',
- 'ar_comment',
'ar_user',
'ar_user_text',
'ar_timestamp',
'ar_page_id',
'ar_len',
'ar_sha1'
- ];
+ ] + $commentQuery['fields'];
if ( $this->config->get( 'ContentHandlerUseDB' ) ) {
$fields[] = 'ar_content_format';
$fields[] = 'ar_content_model';
}
+ $join_conds = [
+ 'revision' => [ 'LEFT JOIN', 'ar_rev_id=rev_id' ],
+ ] + $commentQuery['joins'];
+
/**
* Select each archived revision...
*/
$result = $dbw->select(
- [ 'archive', 'revision' ],
+ $tables,
$fields,
$oldWhere,
__METHOD__,
/* options */
[ 'ORDER BY' => 'ar_timestamp' ],
- [ 'revision' => [ 'LEFT JOIN', 'ar_rev_id=rev_id' ] ]
+ $join_conds
);
$rev_count = $result->numRows();
] );
$revision->insertOn( $dbw );
+
+ // Also restore reference to the revision in ip_changes if it was an IP edit.
+ if ( (int)$row->ar_rev_id === 0 && IP::isValid( $row->ar_user_text ) ) {
+ $ipcRow = [
+ 'ipc_rev_id' => $row->ar_rev_id,
+ 'ipc_rev_timestamp' => $row->ar_timestamp,
+ 'ipc_hex' => IP::toHex( $row->ar_user_text ),
+ ];
+ $dbw->insert( 'ip_changes', $ipcRow, __METHOD__ );
+ }
+
$restored++;
Hooks::run( 'ArticleRevisionUndeleted',