75 $firstDestTimestamp = $this->dbw->selectField(
78 [
'rev_page' => $this->dest->getArticleID() ],
81 $this->maxTimestamp =
new MWTimestamp( $firstDestTimestamp );
89 $lastWorkingTimestamp = $this->dbw->selectField(
94 $this->dbw->addQuotes( $this->dbw->timestamp( $mwTimestamp ) ),
95 'rev_page' => $this->
source->getArticleID()
99 $mwLastWorkingTimestamp =
new MWTimestamp( $lastWorkingTimestamp );
101 $timeInsert = $mwLastWorkingTimestamp;
102 $this->timestampLimit = $mwLastWorkingTimestamp;
108 $lastSourceTimestamp = $this->dbw->selectField(
109 [
'page',
'revision' ],
111 [
'page_id' => $this->
source->getArticleID(),
112 'page_latest = rev_id'
116 $lasttimestamp =
new MWTimestamp( $lastSourceTimestamp );
119 $this->timestampLimit = $lasttimestamp;
122 $this->timeWhere =
"rev_timestamp <= " .
123 $this->dbw->addQuotes( $this->dbw->timestamp( $timeInsert ) );
127 $this->timestampLimit =
false;
136 $count = $this->dbw->selectRowCount(
'revision',
'1',
139 [
'LIMIT' => self::REVISION_LIMIT + 1 ]
165 $this->
source->getUserPermissionsErrors(
'edit', $user ),
166 $this->dest->getUserPermissionsErrors(
'edit', $user )
171 foreach ( $errors
as $error ) {
172 call_user_func_array( [
$status,
'fatal' ], $error );
179 $status->fatal(
'spamprotectiontext' );
183 if ( !$user->
isAllowed(
'mergehistory' ) ) {
185 $status->fatal(
'mergehistory-fail-permission' );
202 if ( $this->
source->getArticleID() === 0 ) {
203 $status->fatal(
'mergehistory-fail-invalid-source' );
205 if ( $this->dest->getArticleID() === 0 ) {
206 $status->fatal(
'mergehistory-fail-invalid-dest' );
210 if ( $this->
source->equals( $this->dest ) ) {
211 $status->fatal(
'mergehistory-fail-self-merge' );
215 if ( !$this->timestampLimit ) {
216 $status->fatal(
'mergehistory-fail-bad-timestamp' );
220 if ( $this->timestampLimit > $this->maxTimestamp ) {
221 $status->fatal(
'mergehistory-fail-timestamps-overlap' );
225 if ( $this->timestampLimit && $this->
getRevisionCount() > self::REVISION_LIMIT ) {
251 if ( !$validCheck->isOK() ) {
255 if ( !$permCheck->isOK() ) {
261 [
'rev_page' => $this->dest->getArticleID() ],
267 $this->revisionsMerged = $this->dbw->affectedRows();
268 if ( $this->revisionsMerged < 1 ) {
269 $status->fatal(
'mergehistory-fail-no-change' );
274 $haveRevisions = $this->dbw->selectField(
277 [
'rev_page' => $this->
source->getArticleID() ],
281 if ( !$haveRevisions ) {
284 'mergehistory-comment',
285 $this->
source->getPrefixedText(),
286 $this->dest->getPrefixedText(),
288 )->inContentLanguage()->text();
291 'mergehistory-autocomment',
292 $this->
source->getPrefixedText(),
293 $this->dest->getPrefixedText()
294 )->inContentLanguage()->text();
298 $redirectContent = $contentHandler->makeRedirectContent(
300 wfMessage(
'mergehistory-redirect-text' )->inContentLanguage()->
plain()
303 if ( $redirectContent ) {
307 'page' => $this->
source->getArticleID(),
308 'comment' => $reason,
309 'content' => $redirectContent ] );
310 $redirectRevision->
insertOn( $this->dbw );
311 $redirectPage->updateRevisionOn( $this->dbw, $redirectRevision );
317 [
'pl_from' => $this->dest->getArticleID() ],
320 $this->dbw->insert(
'pagelinks',
322 'pl_from' => $this->dest->getArticleID(),
323 'pl_from_namespace' => $this->dest->getNamespace(),
324 'pl_namespace' => $this->dest->getNamespace(),
325 'pl_title' => $this->dest->getDBkey() ],
330 $status->warning(
'mergehistory-warning-redirect-not-created' );
333 $this->
source->invalidateCache();
335 $this->dest->invalidateCache();
339 $logEntry->setPerformer( $user );
340 $logEntry->setComment( $reason );
341 $logEntry->setTarget( $this->
source );
342 $logEntry->setParameters( [
343 '4::dest' => $this->dest->getPrefixedText(),
344 '5::mergepoint' => $this->timestampLimit->getTimestamp(
TS_MW )
346 $logId = $logEntry->insert();
347 $logEntry->publish( $logId );
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
Title $dest
Page to which history will be merged.
Title $source
Page from which history will be merged.
const REVISION_LIMIT
int Maximum number of revisions that can be merged at once
merge(User $user, $reason= '')
Actually attempt the history move.
static matchSummarySpamRegex($text)
Check given input text against $wgSummarySpamRegex, and return the text of the first match...
wfMergeErrorArrays()
Merge arrays in the style of getUserPermissionsErrors, with duplicate removal e.g.
isAllowed($action= '')
Internal mechanics of testing a permission.
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock()-offset Set to overwrite offset parameter in $wgRequest set to ''to unsetoffset-wrap String Wrap the message in html(usually something like"<
__construct(Title $source, Title $dest, $timestamp=false)
MergeHistory constructor.
getMergedRevisionCount()
Get the number of revisions that were moved Used in the SpecialMergeHistory success message...
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
integer $revisionsMerged
Number of revisions merged (for Special:MergeHistory success message)
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
MWTimestamp $maxTimestamp
Maximum timestamp that we can use (oldest timestamp of dest)
MWTimestamp bool $timestampLimit
Timestamp upto which history from the source will be merged.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Class for creating log entries manually, to inject them into the database.
insertOn($dbw)
Insert a new revision into the database, returning the new revision ID number on success and dies hor...
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify prev or next refreshes the diff cache allow viewing deleted revs difference engine object to be used for diff source
string $timeWhere
SQL WHERE condition that selects source revisions to insert into destination.
isValidMerge()
Does various sanity checks that the merge is valid.
getRevisionCount()
Get the number of revisions that will be moved.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Handles the backend logic of merging the histories of two pages.
IDatabase $dbw
Database that we are using.
Library for creating and parsing MW-style timestamps.
checkPermissions(User $user, $reason)
Check if the merge is possible.