From: Aaron Schulz Date: Tue, 10 Jun 2014 21:27:49 +0000 (-0700) Subject: Some improvements to Special:MergeHistory X-Git-Tag: 1.31.0-rc.0~15318^2 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=cf8e994053afdbf2c48d00e3ecf60bcff8c06606;p=lhc%2Fweb%2Fwiklou.git Some improvements to Special:MergeHistory * Added a 5000 revision limit. * Also fixed the radio-button selection to reflect the URL params so the "unmerge" log link works as expected. * Added some TODO comments. bug: 66155 Change-Id: Ib70e9d58ae2de723b965e52c679c4e786016420e --- diff --git a/includes/specials/SpecialMergeHistory.php b/includes/specials/SpecialMergeHistory.php index 097f1b6b54..a27cf4c0d7 100644 --- a/includes/specials/SpecialMergeHistory.php +++ b/includes/specials/SpecialMergeHistory.php @@ -283,7 +283,7 @@ class SpecialMergeHistory extends SpecialPage { $last = $this->message['last']; $ts = wfTimestamp( TS_MW, $row->rev_timestamp ); - $checkBox = Xml::radio( 'mergepoint', $ts, false ); + $checkBox = Xml::radio( 'mergepoint', $ts, ( $this->mTimestamp === $ts ) ); $user = $this->getUser(); @@ -325,6 +325,18 @@ class SpecialMergeHistory extends SpecialPage { ->rawParams( $checkBox, $last, $pageLink, $userLink, $stxt, $comment )->escaped() ); } + /** + * 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 target page of merges? + * + * @return boolean Success + */ function merge() { # Get the titles directly from the IDs, in case the target page params # were spoofed. The queries are done based on the IDs, so it's best to @@ -368,7 +380,7 @@ class SpecialMergeHistory extends SpecialPage { return false; } - # Update the revisions + # Get the timestamp pivot condition if ( $this->mTimestamp ) { $timewhere = "rev_timestamp <= {$this->mTimestamp}"; $timestampLimit = wfTimestamp( TS_MW, $this->mTimestamp ); @@ -376,6 +388,18 @@ class SpecialMergeHistory extends SpecialPage { $timewhere = "rev_timestamp <= {$maxtimestamp}"; $timestampLimit = wfTimestamp( TS_MW, $lasttimestamp ); } + # Check that there are not too many revisions to move + $limit = 5000; // avoid too much slave lag + $count = $dbw->select( 'revision', '1', + array( 'rev_page' => $this->mTargetID, $timewhere ), + __METHOD__, + array( 'LIMIT' => $limit + 1 ) + )->numRows(); + if ( $count > $limit ) { + $this->getOutput()->addWikiMsg( 'mergehistory-fail-toobig' ); + + return false; + } # Do the moving... $dbw->update( 'revision', @@ -452,6 +476,7 @@ class SpecialMergeHistory extends SpecialPage { array( $destTitle->getPrefixedText(), $timestampLimit ), $this->getUser() ); + # @TODO: message should use redirect=no $this->getOutput()->addWikiMsg( 'mergehistory-success', $targetTitle->getPrefixedText(), $destTitle->getPrefixedText(), $count ); diff --git a/languages/i18n/en.json b/languages/i18n/en.json index df4a05fe65..6f56d0ab94 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -840,6 +840,7 @@ "mergehistory-empty": "No revisions can be merged.", "mergehistory-success": "$3 {{PLURAL:$3|revision|revisions}} of [[:$1]] successfully merged into [[:$2]].", "mergehistory-fail": "Unable to perform history merge, please recheck the page and time parameters.", + "mergehistory-fail-toobig" : "Unable to perform history merge as more than the limit of $1 {{PLURAL:$1|revision|revisions}} would be moved.", "mergehistory-no-source": "Source page $1 does not exist.", "mergehistory-no-destination": "Destination page $1 does not exist.", "mergehistory-invalid-source": "Source page must be a valid title.", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 2dd4d63e81..424c807b73 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -1002,6 +1002,7 @@ "mergehistory-empty": "Used in [[Special:MergeHistory]].", "mergehistory-success": "Used in [[Special:MergeHistory]].\n* $1 - target page title\n* $2 - destination page title\n* $3 - number of revisions which succeeded to merge", "mergehistory-fail": "Used as error message in [[Special:MergeHistory]].", + "mergehistory-fail-toobig": "Used as error message in [[Special:MergeHistory]].\n* $1 - maximum allowed number of revisions that can be moved", "mergehistory-no-source": "Used as error message in [[Special:MergeHistory]].\n* $1 - source page title\nSee also:\n* {{msg-mw|mergehistory-invalid-source}}\n* {{msg-mw|mergehistory-invalid-destination}}\n* {{msg-mw|mergehistory-no-destination}}\n* {{msg-mw|mergehistory-same-destination}}", "mergehistory-no-destination": "Used as error message in [[Special:MergeHistory]].\n* $1 - destination page title\nSee also:\n* {{msg-mw|mergehistory-invalid-source}}\n* {{msg-mw|mergehistory-no-source}}\n* {{msg-mw|mergehistory-invalid-destination}}\n* {{msg-mw|mergehistory-same-destination}}", "mergehistory-invalid-source": "Used as error message in [[Special:MergeHistory]].\n\nSee also:\n* {{msg-mw|mergehistory-no-source}}\n* {{msg-mw|mergehistory-invalid-destination}}\n* {{msg-mw|mergehistory-no-destination}}\n* {{msg-mw|mergehistory-same-destination}}",