/** * Tags are only shown for unreviewed content and this page is not locked/unlocked? * @return bool */ public function lowProfileUI() { return FlaggedRevs::lowProfileUI() && FlaggedRevs::isStableShownByDefault() == $this->isStableShownByDefault(); }
/** * Does this config equal the default settings? * @param array $config * @return bool */ public static function configIsReset(array $config) { if (FlaggedRevs::useOnlyIfProtected()) { return $config['autoreview'] == ''; } else { return $config['override'] == FlaggedRevs::isStableShownByDefault() && $config['autoreview'] == ''; } }
protected function reallyDoCheckParameters() { # WMF temp hack...protection limit quota global $wgFlaggedRevsProtectQuota; $oldConfig = $this->getOldConfig(); if (isset($wgFlaggedRevsProtectQuota) && $this->autoreview != '' && FRPageConfig::getProtectionLevel($oldConfig) == 'none') { $dbw = wfGetDB(DB_MASTER); $count = $dbw->selectField('flaggedpage_config', 'COUNT(*)', '', __METHOD__); if ($count >= $wgFlaggedRevsProtectQuota) { return 'stabilize_protect_quota'; } } # Autoreview only when protecting currently unprotected pages $this->reviewThis = FRPageConfig::getProtectionLevel($oldConfig) == 'none'; # Autoreview restriction => use stable # No autoreview restriction => site default $this->override = $this->autoreview != '' ? 1 : (int) FlaggedRevs::isStableShownByDefault(); // site default # Check that settings are a valid protection level... $newConfig = array('override' => $this->override, 'autoreview' => $this->autoreview); if (FRPageConfig::getProtectionLevel($newConfig) == 'invalid') { return 'stabilize_invalid_level'; // double-check configuration } # Check autoreview restriction setting if (!FlaggedRevs::userCanSetAutoreviewLevel($this->user, $this->autoreview)) { return 'stabilize_denied'; // invalid value } return true; }
function __construct($form, $namespace, $level = -1, $category = '', $size = null, $watched = false, $stable = false) { $this->mForm = $form; # Must be a content page... $vnamespaces = FlaggedRevs::getReviewNamespaces(); if (is_null($namespace)) { $namespace = $vnamespaces; } else { $namespace = intval($namespace); } # Sanity check if (!in_array($namespace, $vnamespaces)) { $namespace = $vnamespaces; } $this->namespace = $namespace; # Sanity check level: 0 = checked; 1 = quality; 2 = pristine $this->level = $level >= 0 && $level <= 2 ? $level : -1; $this->category = $category ? str_replace(' ', '_', $category) : null; $this->size = $size !== null ? intval($size) : null; $this->watched = (bool) $watched; $this->stable = $stable && !FlaggedRevs::isStableShownByDefault() && !FlaggedRevs::useOnlyIfProtected(); parent::__construct(); # Don't get too expensive $this->mLimitsShown = array(20, 50, 100); $this->setLimit($this->mLimit); // apply max limit }
protected function update_flaggedpages($start = null) { $this->output("Populating and correcting flaggedpages/flaggedpage_config columns\n"); $BATCH_SIZE = 300; $db = wfGetDB(DB_MASTER); if ($start === null) { $start = $db->selectField('page', 'MIN(page_id)', false, __METHOD__); } $end = $db->selectField('page', 'MAX(page_id)', false, __METHOD__); if (is_null($start) || is_null($end)) { $this->output("...flaggedpages table seems to be empty.\n"); return; } # Do remaining chunk $end += $BATCH_SIZE - 1; $blockStart = $start; $blockEnd = $start + $BATCH_SIZE - 1; $count = $deleted = $fixed = 0; while ($blockEnd <= $end) { $this->output("...doing page_id from {$blockStart} to {$blockEnd}\n"); $cond = "page_id BETWEEN {$blockStart} AND {$blockEnd}"; $res = $db->select('page', array('page_id', 'page_namespace', 'page_title', 'page_latest'), $cond, __METHOD__); # Go through and update the de-normalized references... $db->begin(); foreach ($res as $row) { $title = Title::newFromRow($row); $article = new FlaggableWikiPage($title); $oldFrev = FlaggedRevision::newFromStable($title, FR_MASTER); $frev = FlaggedRevision::determineStable($title, FR_MASTER); # Update fp_stable, fp_quality, and fp_reviewed if ($frev) { $article->updateStableVersion($frev, $row->page_latest); $changed = !$oldFrev || $oldFrev->getRevId() != $frev->getRevId(); # Somethings broke? Delete the row... } else { $article->clearStableVersion(); if ($db->affectedRows() > 0) { $deleted++; } $changed = (bool) $oldFrev; } # Get the latest revision $revRow = $db->selectRow('revision', '*', array('rev_page' => $row->page_id), __METHOD__, array('ORDER BY' => 'rev_timestamp DESC')); # Correct page_latest if needed (import/files made plenty of bad rows) if ($revRow) { $revision = new Revision($revRow); if ($article->updateIfNewerOn($db, $revision)) { $fixed++; } } if ($changed) { # Lazily rebuild dependancies on next parse (we invalidate below) FlaggedRevs::clearStableOnlyDeps($title); $title->invalidateCache(); } $count++; } $db->freeResult($res); # Remove manual config settings that simply restate the site defaults $db->delete('flaggedpage_config', array("fpc_page_id BETWEEN {$blockStart} AND {$blockEnd}", 'fpc_override' => intval(FlaggedRevs::isStableShownByDefault()), 'fpc_level' => ''), __METHOD__); $deleted = $deleted + $db->affectedRows(); $db->commit(); $blockStart += $BATCH_SIZE; $blockEnd += $BATCH_SIZE; wfWaitForSlaves(5); } $this->output("flaggedpage columns update complete ..." . " {$count} rows [{$fixed} fixed] [{$deleted} deleted]\n"); }