r37158 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37157‎ | r37158 | r37159 >
Date:11:01, 6 July 2008
Author:aaron
Status:old
Tags:
Comment:
FlaggedRevs refactoring:
* Permalink Id hook redundant; output Id set
* Use output Id for lastmod link to remove duplication
* Combine some hooked functions
* Mark visibility
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Skin.php
@@ -1204,8 +1204,11 @@
12051205
12061206 function lastModified() {
12071207 global $wgLang, $wgArticle;
1208 -
1209 - $timestamp = $wgArticle->getTimestamp();
 1208+ if( $this->mRevisionId ) {
 1209+ $timestamp = Revision::getTimestampFromId( $this->mRevisionId, $wgArticle->getId() );
 1210+ } else {
 1211+ $timestamp = $wgArticle->getTimestamp();
 1212+ }
12101213 if ( $timestamp ) {
12111214 $d = $wgLang->date( $timestamp, true );
12121215 $t = $wgLang->time( $timestamp, true );
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -24,7 +24,7 @@
2525 $wgExtensionCredits['specialpage'][] = array(
2626 'name' => 'Flagged Revisions',
2727 'author' => array( 'Aaron Schulz', 'Joerg Baach' ),
28 - 'version' => '1.09',
 28+ 'version' => '1.091',
2929 'url' => 'http://www.mediawiki.org/wiki/Extension:FlaggedRevs',
3030 'descriptionmsg' => 'flaggedrevs-desc',
3131 );
@@ -201,6 +201,7 @@
202202 # Flagged revisions are always visible to users with rights below.
203203 # Use '*' for non-user accounts.
204204 $wgFlaggedRevsVisible = array();
 205+# If $wgFlaggedRevsVisible is populated, it is applied to talk pages too
205206 $wgFlaggedRevsTalkVisible = true;
206207
207208 # End of configuration variables.
@@ -280,7 +281,6 @@
281282 # Check on undelete/merge/revisiondelete for changes to stable version
282283 $wgHooks['ArticleRevisionVisiblitySet'][] = 'FlaggedRevs::titleLinksUpdate';
283284 $wgHooks['ArticleMergeComplete'][] = 'FlaggedRevs::updateFromMerge';
284 -# Clean up after undeletion
285285 $wgHooks['ArticleRevisionUndeleted'][] = 'FlaggedRevs::updateFromRestore';
286286 # Parser hooks, selects the desired images/templates
287287 $wgHooks['ParserClearState'][] = 'FlaggedRevs::parserAddFields';
@@ -297,17 +297,13 @@
298298 $wgHooks['userCan'][] = 'FlaggedRevs::userCanMove';
299299 # Log parameter
300300 $wgHooks['LogLine'][] = 'FlaggedRevs::reviewLogLine';
301 -# Disable auto-promotion
 301+# Disable auto-promotion for demoted users
302302 $wgHooks['UserRights'][] = 'FlaggedRevs::recordDemote';
303303 # Local user account preference
304304 $wgHooks['RenderPreferencesForm'][] = 'FlaggedRevs::injectPreferences';
305305 $wgHooks['InitPreferencesForm'][] = 'FlaggedRevs::injectFormPreferences';
306306 $wgHooks['ResetPreferences'][] = 'FlaggedRevs::resetPreferences';
307307 $wgHooks['SavePreferences'][] = 'FlaggedRevs::savePreferences';
308 -# Special page CSS
309 -$wgHooks['BeforePageDisplay'][] = 'FlaggedRevs::InjectStyleForSpecial';
310 -# Image version display
311 -$wgHooks['ImagePageFindFile'][] = 'FlaggedRevs::imagePageFindFile';
312308 # Show unreviewed pages links
313309 $wgHooks['CategoryPageView'][] = 'FlaggedRevs::unreviewedPagesLinks';
314310 # Backlog notice
@@ -318,19 +314,15 @@
319315
320316 # Override current revision, add patrol links, set cache...
321317 $wgHooks['ArticleViewHeader'][] = 'FlaggedRevs::onArticleViewHeader';
 318+$wgHooks['ImagePageFindFile'][] = 'FlaggedRevs::imagePageFindFile';
322319 # Override redirect behavoir...
323320 $wgHooks['InitializeArticleMaybeRedirect'][] = 'FlaggedRevs::overrideRedirect';
324321 # Sets tabs and permalink
325322 $wgHooks['SkinTemplateTabs'][] = 'FlaggedRevs::setActionTabs';
326 -# Change last-modified footer
327 -$wgHooks['SkinTemplateOutputPageBeforeExec'][] = 'FlaggedRevs::setLastModified';
328 -# Add page notice
329 -$wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = 'FlaggedRevs::setPermaLink';
330323 # Add tags do edit view
331324 $wgHooks['EditPage::showEditForm:initial'][] = 'FlaggedRevs::addToEditView';
332 -# Add review form
333 -$wgHooks['BeforePageDisplay'][] = 'FlaggedRevs::addReviewForm';
334 -$wgHooks['BeforePageDisplay'][] = 'FlaggedRevs::addVisibilityLink';
 325+# Add review form and visiblity settings link
 326+$wgHooks['BeforePageDisplay'][] = 'FlaggedRevs::onBeforePageDisplay';
335327 # Mark of items in page history
336328 $wgHooks['PageHistoryPager::getQueryInfo'][] = 'FlaggedRevs::addToHistQuery';
337329 $wgHooks['PageHistoryLineEnding'][] = 'FlaggedRevs::addToHistLine';
@@ -341,10 +333,12 @@
342334 $wgHooks['DiffViewHeader'][] = 'FlaggedRevs::onDiffViewHeader';
343335 # Autoreview stuff
344336 $wgHooks['EditPage::showEditForm:fields'][] = 'FlaggedRevs::addRevisionIDField';
345 -# Add CSS/JS
 337+
 338+# Add CSS/JS as needed
346339 $wgHooks['OutputPageParserOutput'][] = 'FlaggedRevs::injectStyleAndJS';
347340 $wgHooks['EditPage::showEditForm:initial'][] = 'FlaggedRevs::injectStyleAndJS';
348341 $wgHooks['PageHistoryBeforeList'][] = 'FlaggedRevs::injectStyleAndJS';
 342+$wgHooks['BeforePageDisplay'][] = 'FlaggedRevs::InjectStyleForSpecial';
349343
350344 # Set aliases
351345 $wgHooks['LanguageGetSpecialPageAliases'][] = 'FlaggedRevs::addLocalizedSpecialPageNames';
@@ -381,6 +375,7 @@
382376 # B/C ...
383377 $wgLogActions['rights/erevoke'] = 'rights-editor-revoke';
384378
 379+# Schema changes
385380 $wgHooks['LoadExtensionSchemaUpdates'][] = 'efFlaggedRevsSchemaUpdates';
386381
387382 function efFlaggedRevsSchemaUpdates() {
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -1387,72 +1387,6 @@
13881388 }
13891389 return true;
13901390 }
1391 -
1392 - /**
1393 - * Set permalink to stable version if we are viewing a stable version.
1394 - * Also sets the citation link if that extension is on.
1395 - */
1396 - public function setPermaLink( $skin, &$navUrls, &$revId, &$id ) {
1397 - # Non-content pages cannot be validated
1398 - if( !$this->pageOverride() )
1399 - return true;
1400 - # Check for an overridabe revision
1401 - $frev = $this->getStableRev( true );
1402 - if( !$frev )
1403 - return true;
1404 - # Replace "permalink" with an actual permanent link
1405 - $navUrls['permalink'] = array(
1406 - 'text' => wfMsg( 'permalink' ),
1407 - 'href' => $this->parent->getTitle()->getFullURL( "stableid={$frev->getRevId()}" )
1408 - );
1409 - # Are we using the popular cite extension?
1410 - global $wgHooks;
1411 - if( in_array('wfSpecialCiteNav',$wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink']) ) {
1412 - if( $this->isReviewable() && $revId !== 0 ) {
1413 - $navUrls['cite'] = array(
1414 - 'text' => wfMsg( 'cite_article_link' ),
1415 - 'href' => $skin->makeSpecialUrl( 'Cite', "page=" . wfUrlencode( "{$skin->thispage}" ) . "&id={$frev->getRevId()}" )
1416 - );
1417 - }
1418 - }
1419 - return true;
1420 - }
1421 -
1422 - /**
1423 - * If viewing a stable version, adjust the last modified header
1424 - */
1425 - public function setLastModified( $skin, &$tpl ) {
1426 - global $wgLang, $wgRequest;
1427 - # Non-content pages cannot be validated
1428 - if( !$this->isReviewable() )
1429 - return true;
1430 - # Old stable versions
1431 - if( $wgRequest->getIntOrNull('stableid') ) {
1432 - $tpl->set('lastmod', false);
1433 - return true;
1434 - }
1435 - # Check for an overridabe revision
1436 - if( !$this->pageOverride() )
1437 - return true;
1438 - $frev = $this->getStableRev( true );
1439 - if( !$frev || $frev->getRevId() == $this->parent->getLatest() )
1440 - return true;
1441 - # Get the timestamp of this revision
1442 - $timestamp = $frev->getRevTimestamp();
1443 - if( $timestamp ) {
1444 - $d = $wgLang->date( $timestamp, true );
1445 - $t = $wgLang->time( $timestamp, true );
1446 - $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1447 - } else {
1448 - $s = '';
1449 - }
1450 - if( wfGetLB()->getLaggedSlaveMode() ) {
1451 - $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1452 - }
1453 - $tpl->set( 'lastmod', $s );
1454 -
1455 - return true;
1456 - }
14571391
14581392 /**
14591393 * Updates parser cache output to included needed versioning params.
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -1985,7 +1985,7 @@
19861986 return true;
19871987 }
19881988
1989 - static function setActionTabs( $skin, &$contentActions ) {
 1989+ public static function setActionTabs( $skin, &$contentActions ) {
19901990 $fa = FlaggedArticle::getGlobalInstance();
19911991 if ( $fa ) {
19921992 $fa->setActionTabs( $skin, $contentActions );
@@ -1993,15 +1993,7 @@
19941994 return true;
19951995 }
19961996
1997 - static function setLastModified( $skin, &$tpl ) {
1998 - $fa = FlaggedArticle::getGlobalInstance();
1999 - if ( $fa ) {
2000 - $fa->setLastModified( $skin, $tpl );
2001 - }
2002 - return true;
2003 - }
2004 -
2005 - static function onArticleViewHeader( $article, &$outputDone, &$pcache ) {
 1997+ public static function onArticleViewHeader( $article, &$outputDone, &$pcache ) {
20061998 $flaggedArticle = FlaggedArticle::getInstance( $article );
20071999 $flaggedArticle->maybeUpdateMainCache( $outputDone, $pcache );
20082000 $flaggedArticle->addStableLink( $outputDone, $pcache );
@@ -2010,7 +2002,7 @@
20112003 return true;
20122004 }
20132005
2014 - static function overrideRedirect( &$title, $request, &$ignoreRedirect, &$target ) {
 2006+ public static function overrideRedirect( &$title, $request, &$ignoreRedirect, &$target ) {
20152007 if( $request->getVal( 'stableid' ) ) {
20162008 $ignoreRedirect = true;
20172009 } else {
@@ -2029,39 +2021,24 @@
20302022 return true;
20312023 }
20322024
2033 - static function setPermaLink( $skin, &$navUrls, &$revId, &$id ) {
2034 - $fa = FlaggedArticle::getGlobalInstance();
2035 - if ( $fa ) {
2036 - $fa->setPermaLink( $skin, $navUrls, $revId, $id );
2037 - }
2038 - return true;
2039 - }
2040 -
2041 - static function addToEditView( $editPage ) {
 2025+ public static function addToEditView( $editPage ) {
20422026 return FlaggedArticle::getInstance( $editPage->mArticle )->addToEditView( $editPage );
20432027 }
20442028
2045 - static function unreviewedPagesLinks( $category ) {
 2029+ public static function unreviewedPagesLinks( $category ) {
20462030 return FlaggedArticle::getInstance( $category )->addToCategoryView();
20472031 }
20482032
2049 - static function addReviewForm( $out ) {
 2033+ public static function onBeforePageDisplay( $out ) {
20502034 $fa = FlaggedArticle::getGlobalInstance();
20512035 if ( $fa && $out->isArticleRelated() ) {
20522036 $fa->addReviewForm( $out );
2053 - }
2054 - return true;
2055 - }
2056 -
2057 - static function addVisibilityLink( $out ) {
2058 - $fa = FlaggedArticle::getGlobalInstance();
2059 - if ( $fa && $out->isArticleRelated() ) {
20602037 $fa->addVisibilityLink( $out );
20612038 }
20622039 return true;
20632040 }
20642041
2065 - static function addToHistQuery( $pager, &$queryInfo ) {
 2042+ public static function addToHistQuery( $pager, &$queryInfo ) {
20662043 $flaggedArticle = FlaggedArticle::getTitleInstance( $pager->mPageHistory->getTitle() );
20672044 if( $flaggedArticle->isReviewable() ) {
20682045 $queryInfo['tables'][] = 'flaggedrevs';
@@ -2072,7 +2049,7 @@
20732050 return true;
20742051 }
20752052
2076 - static function addToFileHistQuery( $file, &$tables, &$fields, &$conds, &$opts, &$join_conds ) {
 2053+ public static function addToFileHistQuery( $file, &$tables, &$fields, &$conds, &$opts, &$join_conds ) {
20772054 if( $file->isLocal() ) {
20782055 $tables[] = 'flaggedrevs';
20792056 $fields[] = 'fr_quality';
@@ -2081,19 +2058,19 @@
20822059 return true;
20832060 }
20842061
2085 - static function addToHistLine( $history, $row, &$s ) {
 2062+ public static function addToHistLine( $history, $row, &$s ) {
20862063 return FlaggedArticle::getInstance( $history->getArticle() )->addToHistLine( $history, $row, $s );
20872064 }
20882065
2089 - static function addToFileHistLine( $hist, $file, &$s, &$rowClass ) {
 2066+ public static function addToFileHistLine( $hist, $file, &$s, &$rowClass ) {
20902067 return FlaggedArticle::getInstance( $hist->getImagePage() )->addToFileHistLine( $hist, $file, $s, $rowClass );
20912068 }
20922069
2093 - static function injectReviewDiffURLParams( $article, &$sectionAnchor, &$extraQuery ) {
 2070+ public static function injectReviewDiffURLParams( $article, &$sectionAnchor, &$extraQuery ) {
20942071 return FlaggedArticle::getInstance( $article )->injectReviewDiffURLParams( $sectionAnchor, $extraQuery );
20952072 }
20962073
2097 - static function onDiffViewHeader( $diff, $oldRev, $newRev ) {
 2074+ public static function onDiffViewHeader( $diff, $oldRev, $newRev ) {
20982075 self::injectStyleAndJS();
20992076 $flaggedArticle = FlaggedArticle::getTitleInstance( $diff->getTitle() );
21002077 $flaggedArticle->addPatrolAndDiffLink( $diff, $oldRev, $newRev );
@@ -2101,11 +2078,11 @@
21022079 return true;
21032080 }
21042081
2105 - static function addRevisionIDField( $editPage, $out ) {
 2082+ public static function addRevisionIDField( $editPage, $out ) {
21062083 return FlaggedArticle::getInstance( $editPage->mArticle )->addRevisionIDField( $editPage, $out );
21072084 }
21082085
2109 - static function addBacklogNotice( &$notice ) {
 2086+ public static function addBacklogNotice( &$notice ) {
21102087 global $wgUser, $wgTitle, $wgFlaggedRevsBacklog;
21112088 $watchlist = SpecialPage::getTitleFor( 'Watchlist' );
21122089 $recentchanges = SpecialPage::getTitleFor( 'Recentchanges' );
@@ -2120,7 +2097,7 @@
21212098 return true;
21222099 }
21232100
2124 - static function addLocalizedSpecialPageNames( &$extendedSpecialPageAliases, $code ) {
 2101+ public static function addLocalizedSpecialPageNames( &$extendedSpecialPageAliases, $code ) {
21252102 wfLoadExtensionMessages( 'FlaggedRevsAliases' );
21262103 # The localized title of the special page is among the messages of the extension:
21272104 $specialPages = array( 'QualityOversight', 'DepreciationOversight', 'UnreviewedPages',

Follow-up revisions

RevisionCommit summaryAuthorDate
r37385Fix regression from r37158, Article::lastModified() now works on non-mySQL sc...demon12:27, 9 July 2008

Status & tagging log