r114402 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114401‎ | r114402 | r114403 >
Date:20:30, 21 March 2012
Author:catrope
Status:ok
Tags:
Comment:
Revert r112773, r112941, r112942, r113389: unreviewed revisions in FlaggedRevs.

All of these revisions are tagged with 'gerritmigration' and will be resubmitted into Gerrit after the Gerrit switchover. See also http://lists.wikimedia.org/pipermail/wikitech-l/2012-March/059124.html
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.setup.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/backend/FRInclusionCache.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/backend/FRPageConfig.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/backend/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/business/PageStabilityForm.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/frontend/FlaggedRevsLogView.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/frontend/RejectConfirmationFormUI.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/frontend/specialpages/actions/Stabilization_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/frontend/specialpages/reports/QualityOversight_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/frontend/specialpages/reports/StablePages_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/frontend/specialpages/actions/Stabilization_body.php
@@ -36,8 +36,7 @@
3737 $out->showErrorPage( 'notargettitle', 'notargettext' );
3838 return;
3939 }
40 - $this->getSkin()->setRelevantTitle( $title );
41 -
 40+
4241 $this->form = new PageStabilityGeneralForm( $user );
4342 $form = $this->form; // convenience
4443
@@ -114,10 +113,10 @@
115114 $showProtectOptions = ( $scExpiryOptions !== '-' && $form->isAllowed() );
116115 $dropdownOptions = array(); // array of <label,value>
117116 # Add the current expiry as a dropdown option
118 - if ( $oldConfig['expiry'] && $oldConfig['expiry'] != 'infinity' ) {
119 - $timestamp = $this->getLanguage()->timeanddate( $oldConfig['expiry'] );
120 - $d = $this->getLanguage()->date( $oldConfig['expiry'] );
121 - $t = $this->getLanguage()->time( $oldConfig['expiry'] );
 117+ if ( $oldConfig['expiry'] && $oldConfig['expiry'] != Block::infinity() ) {
 118+ $timestamp = $this->getLang()->timeanddate( $oldConfig['expiry'] );
 119+ $d = $this->getLang()->date( $oldConfig['expiry'] );
 120+ $t = $this->getLang()->time( $oldConfig['expiry'] );
122121 $dropdownOptions[] = array(
123122 wfMsg( 'protect-existing-expiry', $timestamp, $d, $t ), 'existing' );
124123 }
@@ -240,7 +239,7 @@
241240 </tr>' . Xml::closeElement( 'table' ) .
242241 Html::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ) .
243242 Html::hidden( 'page', $title->getPrefixedText() ) .
244 - Html::hidden( 'wpEditToken', $this->getUser()->getEditToken() );
 243+ Html::hidden( 'wpEditToken', $this->getUser()->editToken() );
245244 } else {
246245 $s .= Xml::closeElement( 'table' );
247246 }
Index: trunk/extensions/FlaggedRevs/frontend/specialpages/reports/QualityOversight_body.php
@@ -41,7 +41,7 @@
4242 }
4343
4444 # Create a LogPager item to get the results and a LogEventsList item to format them...
45 - $loglist = new LogEventsList( $this->getContext()->getSkin(), $out, 0 );
 45+ $loglist = new LogEventsList( $this->getUser()->getSkin(), $out, 0 );
4646 $pager = new LogPager( $loglist, 'review', $this->user, '', '', $conds );
4747
4848 # Explanatory text
Index: trunk/extensions/FlaggedRevs/frontend/specialpages/reports/StablePages_body.php
@@ -153,7 +153,7 @@
154154 $conds['page_namespace'] = $this->namespace;
155155 // Be sure not to include expired items
156156 if( $this->indef ) {
157 - $conds['fpc_expiry'] = $this->mDb->getInfinity();
 157+ $conds['fpc_expiry'] = Block::infinity();
158158 } else {
159159 $encCutoff = $this->mDb->addQuotes( $this->mDb->timestamp() );
160160 $conds[] = "fpc_expiry > {$encCutoff}";
Index: trunk/extensions/FlaggedRevs/frontend/FlaggedRevsLogView.php
@@ -34,8 +34,9 @@
3535 * @return string
3636 */
3737 public static function stabilityLogLinks( $title, $timestamp, $params ) {
 38+ global $wgUser;
3839 # Add history link showing edits right before the config change
39 - $hist = Linker::link(
 40+ $hist = $wgUser->getSkin()->link(
4041 $title,
4142 wfMsgHtml( 'hist' ),
4243 array(),
@@ -96,7 +97,7 @@
9798 * Create revision, diff, and history links for log line entry
9899 */
99100 public static function reviewLogLinks( $action, $title, $params ) {
100 - global $wgLang;
 101+ global $wgUser, $wgLang;
101102 $links = '';
102103 # Show link to page with oldid=x as well as the diff to the former stable rev.
103104 # Param format is <rev id, last stable id, rev timestamp>.
@@ -109,7 +110,7 @@
110111 ? 'review-logentry-diff2' // unreviewed
111112 : 'review-logentry-diff'; // reviewed
112113 $links .= '(';
113 - $links .= Linker::linkKnown(
 114+ $links .= $wgUser->getSkin()->linkKnown(
114115 $title,
115116 wfMsgHtml( $msg ),
116117 array(),
@@ -123,7 +124,7 @@
124125 : $params[2];
125126 $time = $wgLang->timeanddate( $ts, true );
126127 $links .= ' (';
127 - $links .= Linker::linkKnown(
 128+ $links .= $wgUser->getSkin()->linkKnown(
128129 $title,
129130 wfMsgHtml( 'review-logentry-id', $revId, $time ),
130131 array(),
Index: trunk/extensions/FlaggedRevs/frontend/RejectConfirmationFormUI.php
@@ -130,6 +130,7 @@
131131
132132 $form .= '</div>';
133133
 134+ $skin = $this->form->getUser()->getSkin();
134135 $reviewTitle = SpecialPage::getTitleFor( 'RevisionReview' );
135136 $form .= Xml::openElement( 'form',
136137 array( 'method' => 'POST', 'action' => $reviewTitle->getFullUrl() ) );
@@ -145,7 +146,7 @@
146147 'wpReason', 120, $defaultSummary, array( 'maxlength' => 200 ) ) . "<br />";
147148 $form .= Html::input( 'wpSubmit', wfMsg( 'revreview-reject-confirm' ), 'submit' );
148149 $form .= ' ';
149 - $form .= Linker::link( $this->form->getPage(), wfMsg( 'revreview-reject-cancel' ),
 150+ $form .= $skin->link( $this->form->getPage(), wfMsg( 'revreview-reject-cancel' ),
150151 array( 'onClick' => 'history.back(); return history.length <= 1;' ),
151152 array( 'oldid' => $this->form->getRefId(), 'diff' => $this->form->getOldId() ) );
152153 $form .= Xml::closeElement( 'form' );
Index: trunk/extensions/FlaggedRevs/backend/FRPageConfig.php
@@ -32,7 +32,8 @@
3333 */
3434 public static function getVisibilitySettingsFromRow( $row ) {
3535 if ( $row ) {
36 - $expiry = wfGetDB( DB_SLAVE )->decodeExpiry( $row->fpc_expiry );
 36+ # This code should be refactored, now that it's being used more generally.
 37+ $expiry = Block::decodeExpiry( $row->fpc_expiry );
3738 # Only apply the settings if they haven't expired
3839 if ( !$expiry || $expiry < wfTimestampNow() ) {
3940 $row = null; // expired
@@ -48,7 +49,7 @@
4950 $config = array(
5051 'override' => $row->fpc_override ? 1 : 0,
5152 'autoreview' => $level,
52 - 'expiry' => $expiry // TS_MW
 53+ 'expiry' => Block::decodeExpiry( $row->fpc_expiry ) // TS_MW
5354 );
5455 # If there are protection levels defined check if this is valid...
5556 if ( FlaggedRevs::useProtectionLevels() ) {
@@ -95,7 +96,7 @@
9697 $changed = ( $dbw->affectedRows() != 0 ); // did this do anything?
9798 # Otherwise, add/replace row if we are not just setting it to the site default
9899 } else {
99 - $dbExpiry = $dbw->encodeExpiry( $config['expiry'] );
 100+ $dbExpiry = Block::encodeExpiry( $config['expiry'], $dbw );
100101 # Get current config...
101102 $oldRow = $dbw->selectRow( 'flaggedpage_config',
102103 array( 'fpc_override', 'fpc_level', 'fpc_expiry' ),
Index: trunk/extensions/FlaggedRevs/backend/FlaggedRevs.hooks.php
@@ -295,7 +295,7 @@
296296 /**
297297 * Check page move and patrol permissions for FlaggedRevs
298298 */
299 - public static function onGetUserPermissionsErrors( Title $title, $user, $action, &$result ) {
 299+ public static function onUserCan( Title $title, $user, $action, &$result ) {
300300 if ( $result === false ) {
301301 return true; // nothing to do
302302 }
@@ -336,20 +336,6 @@
337337 $result = false;
338338 return false;
339339 }
340 - # Respect page protection to handle cases of "review wars".
341 - # If a page is restricted from editing such that a user cannot
342 - # edit it, then said user should not be able to review it.
343 - foreach ( $title->getRestrictions( 'edit' ) as $right ) {
344 - // Backwards compatibility, rewrite sysop -> protect
345 - $right = ( $right === 'sysop' ) ? 'protect' : $right;
346 - if ( $right != '' && !$user->isAllowed( $right ) ) {
347 - // 'editprotected' bypasses this restriction
348 - if ( !$user->isAllowed( 'editprotected' ) ) {
349 - $result = false;
350 - return false;
351 - }
352 - }
353 - }
354340 }
355341 return true;
356342 }
Index: trunk/extensions/FlaggedRevs/backend/FRInclusionCache.php
@@ -19,98 +19,55 @@
2020 ) {
2121 global $wgParser, $wgMemc;
2222 wfProfileIn( __METHOD__ );
23 -
 23+ $versions = false;
2424 $key = self::getCacheKey( $article->getTitle(), $rev->getId() );
25 - if ( $regen === 'regen' ) {
26 - $versions = false; // skip cache
27 - } elseif ( $rev->isCurrent() ) {
28 - // Check cache entry against page_touched
29 - $versions = FlaggedRevs::getMemcValue( $wgMemc->get( $key ), $article );
30 - } else {
31 - // Old revs won't always be invalidated with template/file changes.
32 - // Also, we don't care if page_touched changed due to a direct edit.
 25+ if ( $regen !== 'regen' ) { // check cache
3326 $versions = FlaggedRevs::getMemcValue( $wgMemc->get( $key ), $article, 'allowStale' );
34 - if ( is_array( $versions ) ) { // entry exists
35 - // Sanity check that the cache is reasonably up to date
36 - list( $templates, $files ) = $versions;
37 - if ( self::templatesStale( $templates ) || self::filesStale( $files ) ) {
38 - $versions = false; // no good
39 - }
40 - }
4127 }
42 -
4328 if ( !is_array( $versions ) ) { // cache miss
4429 $pOut = false;
4530 if ( $rev->isCurrent() ) {
4631 $parserCache = ParserCache::singleton();
47 - # Try current version parser cache for this user...
 32+ # Try current version parser cache (as anon)...
4833 $pOut = $parserCache->get( $article, $article->makeParserOptions( $user ) );
49 - if ( $pOut == false ) {
50 - # Try current version parser cache for the revision author...
51 - $optsUser = $rev->getUser()
52 - ? User::newFromId( $rev->getUser() )
53 - : 'canonical';
54 - $pOut = $parserCache->get( $article, $article->makeParserOptions( $optsUser ) );
 34+ if ( $pOut == false && $rev->getUser() ) { // try the user who saved the change
 35+ $author = User::newFromId( $rev->getUser() );
 36+ $pOut = $parserCache->get( $article, $article->makeParserOptions( $author ) );
5537 }
5638 }
5739 // ParserOutput::mImageTimeKeys wasn't always there
5840 if ( $pOut == false || !FlaggedRevs::parserOutputIsVersioned( $pOut ) ) {
 41+ $title = $article->getTitle();
 42+ $pOpts = ParserOptions::newFromUser( $user ); // Note: tidy off
5943 $pOut = $wgParser->parse(
60 - $rev->getText(),
61 - $article->getTitle(),
62 - ParserOptions::newFromUser( $user ), // Note: tidy off
63 - true,
64 - true,
65 - $rev->getId()
66 - );
 44+ $rev->getText(), $title, $pOpts, true, true, $rev->getId() );
6745 }
6846 # Get the template/file versions used...
6947 $versions = array( $pOut->getTemplateIds(), $pOut->getFileSearchOptions() );
7048 # Save to cache (check cache expiry for dynamic elements)...
7149 $data = FlaggedRevs::makeMemcObj( $versions );
7250 $wgMemc->set( $key, $data, $pOut->getCacheExpiry() );
73 - }
74 -
75 - wfProfileOut( __METHOD__ );
76 - return $versions;
77 - }
78 -
79 - protected static function templatesStale( array $tVersions ) {
80 - # Do a link batch query for page_latest...
81 - $lb = new LinkBatch();
82 - foreach ( $tVersions as $ns => $tmps ) {
83 - foreach ( $tmps as $dbKey => $revIdDraft ) {
84 - $lb->add( $ns, $dbKey );
85 - }
86 - }
87 - $lb->execute();
88 - # Check if any of these templates have a newer version
89 - foreach ( $tVersions as $ns => $tmps ) {
90 - foreach ( $tmps as $dbKey => $revIdDraft ) {
91 - $title = Title::makeTitle( $ns, $dbKey );
92 - if ( $revIdDraft != $title->getLatestRevID() ) {
93 - return true;
 51+ } else {
 52+ $tVersions =& $versions[0]; // templates
 53+ # Do a link batch query for page_latest...
 54+ $lb = new LinkBatch();
 55+ foreach ( $tVersions as $ns => $tmps ) {
 56+ foreach ( $tmps as $dbKey => $revIdDraft ) {
 57+ $lb->add( $ns, $dbKey );
9458 }
9559 }
96 - }
97 - return false;
98 - }
99 -
100 - protected static function filesStale( array $fVersions ) {
101 - # Check if any of these files have a newer version
102 - foreach ( $fVersions as $name => $timeAndSHA1 ) {
103 - $file = wfFindFile( $name );
104 - if ( $file ) {
105 - if ( $file->getTimestamp() != $timeAndSHA1['time'] ) {
106 - return true;
 60+ $lb->execute();
 61+ # Update array with the current page_latest values.
 62+ # This kludge is there since $newTemplates (thus $revIdDraft) is cached.
 63+ foreach ( $tVersions as $ns => &$tmps ) {
 64+ foreach ( $tmps as $dbKey => &$revIdDraft ) {
 65+ $title = Title::makeTitle( $ns, $dbKey );
 66+ $revIdDraft = (int)$title->getLatestRevID();
10767 }
108 - } else {
109 - if ( $timeAndSHA1['time'] ) {
110 - return true;
111 - }
11268 }
11369 }
114 - return false;
 70+ wfProfileOut( __METHOD__ );
 71+ return $versions;
11572 }
11673
11774 /**
Index: trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php
@@ -228,7 +228,10 @@
229229
230230 public function isAllowed() {
231231 // Basic permission check
232 - return ( $this->page && $this->page->userCan( 'review' ) );
 232+ return ( $this->page
 233+ && $this->page->userCan( 'review' )
 234+ && $this->page->userCan( 'edit' )
 235+ );
233236 }
234237
235238 // implicit dims for binary flag case
Index: trunk/extensions/FlaggedRevs/business/PageStabilityForm.php
@@ -87,7 +87,7 @@
8888 $value = $this->expirySelection;
8989 }
9090 if ( $value == 'infinite' || $value == 'indefinite' || $value == 'infinity' ) {
91 - $time = 'infinity';
 91+ $time = Block::infinity();
9292 } else {
9393 $unix = strtotime( $value );
9494 # On error returns -1 for PHP <5.1 and false for PHP >=5.1
@@ -188,7 +188,7 @@
189189 */
190190 public function doPreloadParameters() {
191191 $oldConfig = $this->getOldConfig();
192 - if ( $oldConfig['expiry'] == 'infinity' ) {
 192+ if ( $oldConfig['expiry'] == Block::infinity() ) {
193193 $this->expirySelection = 'infinite'; // no settings set OR indefinite
194194 } else {
195195 $this->expirySelection = 'existing'; // settings set and NOT indefinite
@@ -217,7 +217,7 @@
218218 $expiry = $this->getExpiry();
219219 if ( $expiry === false ) {
220220 return 'stabilize_expiry_invalid';
221 - } elseif ( $expiry !== 'infinity' && $expiry < wfTimestampNow() ) {
 221+ } elseif ( $expiry !== Block::infinity() && $expiry < wfTimestampNow() ) {
222222 return 'stabilize_expiry_old';
223223 }
224224 # Update the DB row with the new config...
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.setup.php
@@ -211,7 +211,7 @@
212212
213213 # ######## Other #########
214214 # Determine what pages can be moved and patrolled
215 - $wgHooks['getUserPermissionsErrors'][] = 'FlaggedRevsHooks::onGetUserPermissionsErrors';
 215+ $wgHooks['getUserPermissionsErrors'][] = 'FlaggedRevsHooks::onUserCan';
216216 # Implicit autoreview rights group
217217 $wgHooks['AutopromoteCondition'][] = 'FlaggedRevsHooks::checkAutoPromoteCond';
218218 $wgHooks['UserLoadAfterLoadFromSession'][] = 'FlaggedRevsHooks::setSessionKey';

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r112773(bug 33353) Sanity check template/file versions to decide if non-current vers...aaron05:27, 1 March 2012
r112941[FlaggedRevs] Fixed various deprecation notices, cleaning up block expiry han...aaron11:54, 3 March 2012
r112942[FlaggedRevs]...aaron12:00, 3 March 2012
r113389* Renamed misleading onUserCan fuction to onGetUserPermissionsErrors as it ho...aaron19:42, 8 March 2012

Status & tagging log