Beispiel #1
0
 /**
  * @param string|CodeRepository $repo
  * @param string|CodeRevision $rev
  * @param null $replyTarget
  */
 function __construct($repo, $rev, $replyTarget = null)
 {
     parent::__construct($repo);
     global $wgRequest;
     if ($rev instanceof CodeRevision) {
         $this->mRevId = $rev->getId();
         $this->mRev = $rev;
     } else {
         $this->mRevId = intval(ltrim($rev, 'r'));
         $this->mRev = $this->mRepo ? $this->mRepo->getRevision($this->mRevId) : null;
     }
     $this->mPreviewText = false;
     # Search path for navigation links
     $this->mPath = htmlspecialchars(trim($wgRequest->getVal('path')));
     if (strlen($this->mPath) && $this->mPath[0] !== '/') {
         $this->mPath = "/{$this->mPath}";
         // make sure this is a valid path
     }
     # URL params...
     $this->mAddTags = $wgRequest->getText('wpTag');
     $this->mRemoveTags = $wgRequest->getText('wpRemoveTag');
     $this->mStatus = $wgRequest->getText('wpStatus');
     $this->jumpToNext = $wgRequest->getCheck('wpSaveAndNext') || $wgRequest->getCheck('wpNext');
     $this->mReplyTarget = $replyTarget ? (int) $replyTarget : $wgRequest->getIntOrNull('wpParent');
     $this->text = $wgRequest->getText("wpReply{$this->mReplyTarget}");
     $this->mSkipCache = $wgRequest->getVal('action') == 'purge';
     # Make tag arrays
     $this->mAddTags = $this->splitTags($this->mAddTags);
     $this->mRemoveTags = $this->splitTags($this->mRemoveTags);
     $this->mSignoffFlags = $wgRequest->getCheck('wpSignoff') ? $wgRequest->getArray('wpSignoffFlags') : array();
     $this->mSelectedSignoffs = $wgRequest->getArray('wpSignoffs');
     $this->mStrikeSignoffs = $wgRequest->getCheck('wpStrikeSignoffs') ? $this->mSelectedSignoffs : array();
     $this->mAddReferences = $wgRequest->getCheck('wpAddReferencesSubmit') ? $this->stringToRevList($wgRequest->getText('wpAddReferences')) : array();
     $this->mRemoveReferences = $wgRequest->getCheck('wpRemoveReferences') ? $wgRequest->getIntArray('wpReferences', array()) : array();
     $this->mAddReferenced = $wgRequest->getCheck('wpAddReferencedSubmit') ? $this->stringToRevList($wgRequest->getText('wpAddReferenced')) : array();
     $this->mRemoveReferenced = $wgRequest->getCheck('wpRemoveReferenced') ? $wgRequest->getIntArray('wpReferenced', array()) : array();
 }
Beispiel #2
0
 /**
  * Set diff cache (for import operations)
  * @param $codeRev CodeRevision
  */
 public function setDiffCache(CodeRevision $codeRev)
 {
     global $wgMemc;
     wfProfileIn(__METHOD__);
     $rev1 = $codeRev->getId() - 1;
     $rev2 = $codeRev->getId();
     $svn = SubversionAdaptor::newFromRepo($this->path);
     $data = $svn->getDiff('', $rev1, $rev2);
     // Store to cache
     $key = wfMemcKey('svn', md5($this->path), 'diff', $rev1, $rev2);
     $wgMemc->set($key, $data, 3600 * 24 * 3);
     // Permanent DB storage
     $storedData = $data;
     $flags = Revision::compressRevisionText($storedData);
     $dbw = wfGetDB(DB_MASTER);
     $dbw->update('code_rev', array('cr_diff' => $storedData, 'cr_flags' => $flags), array('cr_repo_id' => $this->id, 'cr_id' => $codeRev->getId()), __METHOD__);
     wfProfileOut(__METHOD__);
 }