Exemplo n.º 1
0
 /**
  * Test merged revision count
  * @covers MergeHistory::getMergedRevisionCount
  */
 public function testGetMergedRevisionCount()
 {
     $mh = new MergeHistory(Title::newFromText('Merge1'), Title::newFromText('Merge2'));
     $sysop = static::getTestSysop()->getUser();
     $mh->merge($sysop);
     $this->assertEquals($mh->getMergedRevisionCount(), 1);
 }
Exemplo n.º 2
0
 /**
  * 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 bool 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
     # keep it consistent...
     $targetTitle = Title::newFromID($this->mTargetID);
     $destTitle = Title::newFromID($this->mDestID);
     if (is_null($targetTitle) || is_null($destTitle)) {
         return false;
         // validate these
     }
     if ($targetTitle->getArticleID() == $destTitle->getArticleID()) {
         return false;
     }
     // MergeHistory object
     $mh = new MergeHistory($targetTitle, $destTitle, $this->mTimestamp);
     // Merge!
     $mergeStatus = $mh->merge($this->getUser(), $this->mComment);
     if (!$mergeStatus->isOK()) {
         // Failed merge
         $this->getOutput()->addWikiMsg($mergeStatus->getMessage());
         return false;
     }
     $targetLink = Linker::link($targetTitle, null, [], ['redirect' => 'no']);
     $this->getOutput()->addWikiMsg($this->msg('mergehistory-done')->rawParams($targetLink)->params($destTitle->getPrefixedText())->numParams($mh->getMergedRevisionCount()));
     return true;
 }
Exemplo n.º 3
0
 /**
  * @param Title $from
  * @param Title $to
  * @param string $timestamp
  * @param string $reason
  * @return Status
  */
 protected function merge(Title $from, Title $to, $timestamp, $reason)
 {
     $mh = new MergeHistory($from, $to, $timestamp);
     return $mh->merge($this->getUser(), $reason);
 }
Exemplo n.º 4
0
 /**
  * Test merged revision count
  * @covers MergeHistory::getMergedRevisionCount
  */
 public function testGetMergedRevisionCount()
 {
     $mh = new MergeHistory(Title::newFromText('Merge1'), Title::newFromText('Merge2'));
     $mh->merge(User::newFromName('UTSysop'));
     $this->assertEquals($mh->getMergedRevisionCount(), 1);
 }
Exemplo n.º 5
0
 /**
  * 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 bool Success
  */
 function merge()
 {
     $opts = $this->mOpts;
     # 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
     # keep it consistent...
     $targetObj = $this->mTargetObj;
     $destObj = $this->mDestObj;
     if (is_null($targetObj) || is_null($destObj) || $targetObj->getArticleID() == $destObj->getArticleID()) {
         return false;
     }
     // MergeHistory object
     $mh = new MergeHistory($targetObj, $destObj, $opts->getValue('mergepoint'));
     // Merge!
     $mergeStatus = $mh->merge($this->getUser(), $opts->getValue('reason'));
     if (!$mergeStatus->isOK()) {
         // Failed merge
         $this->getOutput()->addWikiMsg($mergeStatus->getMessage());
         return false;
     }
     $targetLink = Linker::link($targetObj, null, [], ['redirect' => 'no']);
     $this->getOutput()->addWikiMsg($this->msg('mergehistory-done')->rawParams($targetLink)->params($destObj->getPrefixedText())->numParams($mh->getMergedRevisionCount()));
     return true;
 }