/** * This function does essentially the same as RevisionReview::AjaxReview, * except that it generates the template and image parameters itself. */ public function execute() { global $wgUser; $params = $this->extractRequestParams(); // Check basic permissions if (!$wgUser->isAllowed('review')) { $this->dieUsage("You don't have the right to review revisions.", 'permissiondenied'); } elseif ($wgUser->isBlocked(false)) { $this->dieUsageMsg(array('blockedtext')); } $newRev = Revision::newFromId($params['oldid']); if (!$newRev || !$newRev->getTitle()) { $this->dieUsage("Cannot find a revision with the specified ID.", 'notarget'); } $title = $newRev->getTitle(); $fa = FlaggableWikiPage::getTitleInstance($title); if (!$fa->isReviewable()) { $this->dieUsage("Provided page is not reviewable.", 'notreviewable'); } $status = false; if ($params['previd']) { // changes $oldRev = Revision::newFromId($params['previd']); if (!$oldRev || $oldRev->getPage() != $newRev->getPage()) { $this->dieUsage("Revisions do not belong to the same page.", 'notarget'); } // Mark as reviewing... if ($params['reviewing']) { $status = FRUserActivity::setUserReviewingDiff($wgUser, $params['previd'], $params['oldid']); // Unmark as reviewing... } else { $status = FRUserActivity::clearUserReviewingDiff($wgUser, $params['previd'], $params['oldid']); } } else { // Mark as reviewing... if ($params['reviewing']) { $status = FRUserActivity::setUserReviewingPage($wgUser, $newRev->getPage()); // Unmark as reviewing... } else { $status = FRUserActivity::clearUserReviewingPage($wgUser, $newRev->getPage()); } } # Success in setting flag... if ($status === true) { $this->getResult()->addValue(null, $this->getModuleName(), array('result' => 'Success')); # Failure... } else { $this->getResult()->addValue(null, $this->getModuleName(), array('result' => 'Failure')); } }
protected function list_reviewable_pages($fileHandle) { global $wgFlaggedRevsNamespaces, $wgUseSquid, $wgUseFileCache; $this->output("Building list of all reviewable pages to purge ...\n"); if (!$wgUseSquid && !$wgUseFileCache) { $this->output("Squid/file cache not enabled ... nothing to purge.\n"); return; } elseif (empty($wgFlaggedRevsNamespaces)) { $this->output("There are no reviewable namespaces ... nothing to purge.\n"); return; } $db = wfGetDB(DB_MASTER); $start = $db->selectField('page', 'MIN(page_id)', false, __FUNCTION__); $end = $db->selectField('page', 'MAX(page_id)', false, __FUNCTION__); if (is_null($start) || is_null($end)) { $this->output("... page table seems to be empty.\n"); return; } # Do remaining chunk $end += $this->mBatchSize - 1; $blockStart = $start; $blockEnd = $start + $this->mBatchSize - 1; $count = 0; while ($blockEnd <= $end) { $this->output("... doing page_id from {$blockStart} to {$blockEnd}\n"); $res = $db->select('page', '*', array("page_id BETWEEN {$blockStart} AND {$blockEnd}", 'page_namespace' => $wgFlaggedRevsNamespaces), __FUNCTION__); # Go through and append each purgeable page... foreach ($res as $row) { $title = Title::newFromRow($row); $fa = FlaggableWikiPage::getTitleInstance($title); if ($fa->isReviewable()) { # Need to purge this page - add to list fwrite($fileHandle, $title->getPrefixedDBKey() . "\n"); $count++; } } $db->freeResult($res); $blockStart += $this->mBatchSize - 1; $blockEnd += $this->mBatchSize - 1; wfWaitForSlaves(5); // not really needed } $this->output("List of reviewable pages to purge complete ... {$count} pages\n"); }
public static function AjaxBuildDiffHeaderItems() { $args = func_get_args(); // <oldid, newid> if (count($args) >= 2) { $oldid = (int) $args[0]; $newid = (int) $args[1]; $oldRev = Revision::newFromId($oldid); $newRev = Revision::newFromId($newid); if ($newRev && $newRev->getTitle()) { $fa = FlaggableWikiPage::getTitleInstance($newRev->getTitle()); return self::diffLinkAndMarkers($fa, $oldRev, $newRev); } } return ''; }
/** * Load any objects after ready() called * @return mixed (true on success, error string on failure) */ protected function doBuildOnReady() { $this->article = FlaggableWikiPage::getTitleInstance($this->page); return true; }
/** * Update the page tables with a new stable version. * @param WikiPage|Title $page * @param FlaggedRevision|null $sv, the new stable version (optional) * @param FlaggedRevision|null $oldSv, the old stable version (optional) * @param Object editInfo Article edit info about the current revision (optional) * @return bool stable version text/file changed and FR_INCLUDES_STABLE */ public static function stableVersionUpdates($page, $sv = null, $oldSv = null, $editInfo = null) { if ($page instanceof FlaggableWikiPage) { $article = $page; } elseif ($page instanceof WikiPage) { $article = FlaggableWikiPage::getTitleInstance($page->getTitle()); } elseif ($page instanceof Title) { $article = FlaggableWikiPage::getTitleInstance($page); } else { throw new MWException("First argument must be a Title or WikiPage."); } $title = $article->getTitle(); $changed = false; if ($oldSv === null) { // optional $oldSv = FlaggedRevision::newFromStable($title, FR_MASTER); } if ($sv === null) { // optional $sv = FlaggedRevision::determineStable($title, FR_MASTER); } if (!$sv) { # Empty flaggedrevs data for this page if there is no stable version $article->clearStableVersion(); # Check if pages using this need to be refreshed... if (FlaggedRevs::inclusionSetting() == FR_INCLUDES_STABLE) { $changed = (bool) $oldSv; } } else { # Update flagged page related fields $article->updateStableVersion($sv, $editInfo ? $editInfo->revid : null); # Check if pages using this need to be invalidated/purged... if (FlaggedRevs::inclusionSetting() == FR_INCLUDES_STABLE) { $changed = !$oldSv || $sv->getRevId() != $oldSv->getRevId() || $sv->getFileTimestamp() != $oldSv->getFileTimestamp() || $sv->getFileSha1() != $oldSv->getFileSha1(); } # Update template/file version cache... if ($editInfo && $sv->getRevId() != $editInfo->revid) { FRInclusionCache::setRevIncludes($title, $editInfo->revid, $editInfo->output); } } # Lazily rebuild dependancies on next parse (we invalidate below) FlaggedRevs::clearStableOnlyDeps($title->getArticleID()); # Clear page cache $title->invalidateCache(); self::purgeSquid($title); return $changed; }
/** * Mark auto-reviewed edits as patrolled */ public static function autoMarkPatrolled(RecentChange &$rc) { if (empty($rc->mAttribs['rc_this_oldid'])) { return true; } $fa = FlaggableWikiPage::getTitleInstance($rc->getTitle()); $fa->loadPageData('fromdbmaster'); // Is the page reviewable? if ($fa->isReviewable()) { $revId = $rc->mAttribs['rc_this_oldid']; // If the edit we just made was reviewed, then it's the stable rev $frev = FlaggedRevision::newFromTitle($rc->getTitle(), $revId, FR_MASTER); // Reviewed => patrolled if ($frev) { RevisionReviewForm::updateRecentChanges($rc, 'patrol', $frev); $rc->mAttribs['rc_patrolled'] = 1; // make sure irc/email notifs know status } return true; } return true; }
public static function addToHistLine(HistoryPager $history, $row, &$s, &$liClasses) { $fa = FlaggableWikiPage::getTitleInstance($history->getTitle()); if (!$fa->isReviewable()) { return true; // nothing to do here } # Fetch and process cache the stable revision if (!isset($history->fr_stableRevId)) { $srev = $fa->getStableRev(); $history->fr_stableRevId = $srev ? $srev->getRevId() : null; $history->fr_stableRevUTS = $srev ? wfTimestamp(TS_UNIX, $srev->getRevTimestamp()) : null; $history->fr_pendingRevs = false; } if (!$history->fr_stableRevId) { return true; // nothing to do here } $title = $history->getTitle(); $revId = (int) $row->rev_id; // Pending revision: highlight and add diff link $link = $class = ''; if (wfTimestamp(TS_UNIX, $row->rev_timestamp) > $history->fr_stableRevUTS) { $class = 'flaggedrevs-pending'; $link = wfMsgExt('revreview-hist-pending-difflink', 'parseinline', $title->getPrefixedText(), $history->fr_stableRevId, $revId); $link = '<span class="plainlinks mw-fr-hist-difflink">' . $link . '</span>'; $history->fr_pendingRevs = true; // pending rev shown above stable // Reviewed revision: highlight and add link } elseif (isset($row->fr_quality)) { if (!($row->rev_deleted & Revision::DELETED_TEXT)) { # Add link to stable version of *this* rev, if any list($link, $class) = self::markHistoryRow($title, $row); # Space out and demark the stable revision if ($revId == $history->fr_stableRevId && $history->fr_pendingRevs) { $liClasses[] = 'fr-hist-stable-margin'; } } } # Style the row as needed if ($class) { $s = "<span class='{$class}'>{$s}</span>"; } # Add stable old version link if ($link) { $s .= " {$link}"; } return true; }
/** * When an edit is made to a page: * (a) If the page is reviewable, silently mark the edit patrolled if it was auto-reviewed * (b) If the page can be patrolled, auto-patrol the edit patrolled as normal * (c) If the page is new and $wgUseNPPatrol is on, auto-patrol the edit patrolled as normal * (d) If the edit is neither reviewable nor patrolleable, silently mark it patrolled */ public static function autoMarkPatrolled(RecentChange &$rc) { if (empty($rc->mAttribs['rc_this_oldid'])) { return true; } $fa = FlaggableWikiPage::getTitleInstance($rc->getTitle()); $fa->loadPageData('fromdbmaster'); // Is the page reviewable? if ($fa->isReviewable()) { $revId = $rc->mAttribs['rc_this_oldid']; $quality = FlaggedRevision::getRevQuality($revId, FR_MASTER); // Reviewed => patrolled if ($quality !== false && $quality >= FR_CHECKED) { RevisionReviewForm::updateRecentChanges($rc, 'patrol', $fa->getStableRev()); $rc->mAttribs['rc_patrolled'] = 1; // make sure irc/email notifs know status } return true; } return true; }