protected static function fetchFileChanges(FlaggedRevision $frev, $newFiles = null) { $diffLinks = array(); if ($newFiles === null) { $changes = $frev->findPendingFileChanges('noForeign'); } else { $changes = $frev->findFileChanges($newFiles, 'noForeign'); } foreach ($changes as $tuple) { list($title, $revIdStable, $hasStable) = $tuple; // @TODO: change when MW has file diffs $link = Linker::link($title, htmlspecialchars($title->getPrefixedText())); if (!$hasStable) { $link = "<strong>{$link}</strong>"; } $diffLinks[] = $link; } return $diffLinks; }
/** * Updates the flagging tracking tables for this page * @param FlaggedRevision $srev The new stable version * @param int|null $latest The latest rev ID (optional) * @return bool Updates were done */ public function updateStableVersion(FlaggedRevision $srev, $latest = null) { $rev = $srev->getRevision(); if (!$this->exists() || !$rev) { return false; // no bogus entries } # Get the latest revision ID if not set if (!$latest) { $latest = $this->mTitle->getLatestRevID(Title::GAID_FOR_UPDATE); } $dbw = wfGetDB(DB_MASTER); # Get the highest quality revision (not necessarily this one)... if ($srev->getQuality() === FlaggedRevs::highestReviewTier()) { $maxQuality = $srev->getQuality(); // save a query } else { $maxQuality = $dbw->selectField(array('flaggedrevs', 'revision'), 'fr_quality', array('fr_page_id' => $this->getId(), 'rev_id = fr_rev_id', 'rev_page = fr_page_id', 'rev_deleted & ' . Revision::DELETED_TEXT => 0), __METHOD__, array('ORDER BY' => 'fr_quality DESC', 'LIMIT' => 1)); $maxQuality = max($maxQuality, $srev->getQuality()); // sanity } # Get the timestamp of the first edit after the stable version (if any)... $nextTimestamp = null; if ($rev->getId() != $latest) { $timestamp = $dbw->timestamp($rev->getTimestamp()); $nextEditTS = $dbw->selectField('revision', 'rev_timestamp', array('rev_page' => $this->getId(), "rev_timestamp > " . $dbw->addQuotes($timestamp)), __METHOD__, array('ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 1)); if ($nextEditTS) { // sanity check $nextTimestamp = $nextEditTS; } } # Get the new page sync status... $synced = !($nextTimestamp !== null || $srev->findPendingTemplateChanges() || $srev->findPendingFileChanges('noForeign')); # Alter table metadata $dbw->replace('flaggedpages', array('fp_page_id'), array('fp_page_id' => $this->getId(), 'fp_stable' => $rev->getId(), 'fp_reviewed' => $synced ? 1 : 0, 'fp_quality' => $maxQuality === false ? null : $maxQuality, 'fp_pending_since' => $dbw->timestampOrNull($nextTimestamp)), __METHOD__); # Update pending edit tracking table self::updatePendingList($this->getId(), $latest); return true; }