/** * @param FlaggedRevision $frev * Removes flagged revision data for this page/id set * @return bool */ private function unapproveRevision(FlaggedRevision $frev) { wfProfileIn(__METHOD__); # Get current stable version ID (for logging) $oldSv = FlaggedRevision::newFromStable($this->page, FR_MASTER); # Delete from flaggedrevs table $frev->delete(); # Update the article review log $oldSvId = $oldSv ? $oldSv->getRevId() : 0; FlaggedRevsLog::updateReviewLog($this->page, $this->dims, $this->oldFlags, $this->comment, $this->oldid, $oldSvId, false); # Get the new stable version as of now $sv = FlaggedRevision::determineStable($this->page, FR_MASTER); # Update recent changes self::updateRecentChanges($frev->getRevision(), 'unpatrol', $sv); # Update page and tracking tables and clear cache $changed = FlaggedRevs::stableVersionUpdates($this->page, $sv, $oldSv); if ($changed) { FlaggedRevs::HTMLCacheUpdates($this->page); // purge pages that use this page } # Caller may want to get the change time $this->newLastChangeTime = ''; wfProfileOut(__METHOD__); return true; }
/** * 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; }