MediaWiki  1.30.0
MergeHistory Class Reference

Handles the backend logic of merging the histories of two pages. More...

Collaboration diagram for MergeHistory:

Public Member Functions

 __construct (Title $source, Title $dest, $timestamp=false)
 
 checkPermissions (User $user, $reason)
 Check if the merge is possible. More...
 
 getMergedRevisionCount ()
 Get the number of revisions that were moved Used in the SpecialMergeHistory success message. More...
 
 getRevisionCount ()
 Get the number of revisions that will be moved. More...
 
 isValidMerge ()
 Does various sanity checks that the merge is valid. More...
 
 merge (User $user, $reason='')
 Actually attempt the history move. More...
 

Public Attributes

const REVISION_LIMIT = 5000
 @const int Maximum number of revisions that can be merged at once More...
 

Protected Attributes

IDatabase $dbw
 Database that we are using. More...
 
Title $dest
 Page to which history will be merged. More...
 
MWTimestamp $maxTimestamp
 Maximum timestamp that we can use (oldest timestamp of dest) More...
 
int $revisionsMerged
 Number of revisions merged (for Special:MergeHistory success message) More...
 
Title $source
 Page from which history will be merged. More...
 
MWTimestamp bool $timestampLimit
 Timestamp upto which history from the source will be merged. More...
 
string $timeWhere
 SQL WHERE condition that selects source revisions to insert into destination. More...
 

Detailed Description

Handles the backend logic of merging the histories of two pages.

Since
1.27

Definition at line 36 of file MergeHistory.php.

Constructor & Destructor Documentation

◆ __construct()

MergeHistory::__construct ( Title  $source,
Title  $dest,
  $timestamp = false 
)
Parameters
Title$sourcePage from which history will be merged
Title$destPage to which history will be merged
string | bool$timestampTimestamp up to which history from the source will be merged

Definition at line 67 of file MergeHistory.php.

References $dest, $maxTimestamp, $source, DB_MASTER, source, and wfGetDB().

Member Function Documentation

◆ checkPermissions()

MergeHistory::checkPermissions ( User  $user,
  $reason 
)

Check if the merge is possible.

Parameters
User$user
string$reason
Returns
Status

Definition at line 161 of file MergeHistory.php.

References $user, as, EditPage\matchSummarySpamRegex(), source, and wfMergeErrorArrays().

Referenced by merge().

◆ getMergedRevisionCount()

MergeHistory::getMergedRevisionCount ( )

Get the number of revisions that were moved Used in the SpecialMergeHistory success message.

Returns
int

Definition at line 151 of file MergeHistory.php.

References $revisionsMerged.

◆ getRevisionCount()

MergeHistory::getRevisionCount ( )

Get the number of revisions that will be moved.

Returns
int

Definition at line 136 of file MergeHistory.php.

References $timeWhere, and source.

Referenced by isValidMerge().

◆ isValidMerge()

MergeHistory::isValidMerge ( )

Does various sanity checks that the merge is valid.

Only things based on the two pages should be checked here.

Returns
Status

Definition at line 199 of file MergeHistory.php.

References getRevisionCount(), and source.

Referenced by merge().

◆ merge()

MergeHistory::merge ( User  $user,
  $reason = '' 
)

Actually attempt the history move.

Todo:
if all versions of page A are moved to B and then a user tries to do a reverse-merge via the "unmerge" log link, then page A will still be a redirect (as it was after the original merge), though it will have the old revisions back from before (as expected). The user may have to "undo" the redirect manually to finish the "unmerge". Maybe this should delete redirects at the source page of merges?
Parameters
User$user
string$reason
Returns
Status status of the history merge

Definition at line 247 of file MergeHistory.php.

References $timeWhere, $user, checkPermissions(), WikiPage\factory(), ContentHandler\getForTitle(), Revision\insertOn(), isValidMerge(), plain, Hooks\run(), source, and wfMessage().

Member Data Documentation

◆ $dbw

IDatabase MergeHistory::$dbw
protected

Database that we are using.

Definition at line 48 of file MergeHistory.php.

◆ $dest

Title MergeHistory::$dest
protected

Page to which history will be merged.

Definition at line 45 of file MergeHistory.php.

Referenced by __construct().

◆ $maxTimestamp

MWTimestamp MergeHistory::$maxTimestamp
protected

Maximum timestamp that we can use (oldest timestamp of dest)

Definition at line 51 of file MergeHistory.php.

Referenced by __construct().

◆ $revisionsMerged

int MergeHistory::$revisionsMerged
protected

Number of revisions merged (for Special:MergeHistory success message)

Definition at line 60 of file MergeHistory.php.

Referenced by getMergedRevisionCount().

◆ $source

Title MergeHistory::$source
protected

Page from which history will be merged.

Definition at line 42 of file MergeHistory.php.

Referenced by __construct().

◆ $timestampLimit

MWTimestamp bool MergeHistory::$timestampLimit
protected

Timestamp upto which history from the source will be merged.

Definition at line 57 of file MergeHistory.php.

◆ $timeWhere

string MergeHistory::$timeWhere
protected

SQL WHERE condition that selects source revisions to insert into destination.

Definition at line 54 of file MergeHistory.php.

Referenced by getRevisionCount(), and merge().

◆ REVISION_LIMIT

const MergeHistory::REVISION_LIMIT = 5000

@const int Maximum number of revisions that can be merged at once

Definition at line 39 of file MergeHistory.php.

Referenced by MergeHistoryTest\testIsValidMergeRevisionLimit().


The documentation for this class was generated from the following file: