r26983 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r26982‎ | r26983 | r26984 >
Date:19:05, 27 October 2007
Author:aaron
Status:old
Tags:
Comment:
*Random OOP cleanup
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -104,7 +104,7 @@
105105 # Autopromote Editors
106106 $wgHooks['ArticleSaveComplete'][] = array( $wgFlaggedRevs, 'autoPromoteUser' );
107107 # Adds table link references to include ones from the stable version
108 - $wgHooks['LinksUpdateConstructed'][] = array( $wgFlaggedRevs, 'extraLinksUpdate' );
 108+ $wgHooks['LinksUpdateConstructed'][] = array( $wgFlaggedArticle, 'extraLinksUpdate' );
109109 # Empty flagged page settings row on delete
110110 $wgHooks['ArticleDeleteComplete'][] = array( $wgFlaggedArticle, 'deleteVisiblitySettings' );
111111 # Check on undelete/merge/revisiondelete for changes to stable version
@@ -124,7 +124,7 @@
125125 # Page review on edit
126126 $wgHooks['ArticleUpdateBeforeRedirect'][] = array($wgFlaggedArticle, 'injectReviewDiffURLParams');
127127 $wgHooks['DiffViewHeader'][] = array($wgFlaggedArticle, 'addDiffNoticeAfterEdit' );
128 - $wgHooks['DiffViewHeader'][] = array($wgFlaggedRevs, 'addPatrolLink' );
 128+ $wgHooks['DiffViewHeader'][] = array($wgFlaggedArticle, 'addPatrolLink' );
129129 # Autoreview stuff
130130 $wgHooks['ArticleInsertComplete'][] = array( $wgFlaggedArticle, 'maybeMakeNewPageReviewed' );
131131 $wgHooks['ArticleSaveComplete'][] = array( $wgFlaggedArticle, 'maybeMakeEditReviewed' );
@@ -373,7 +373,7 @@
374374 * @param int $rev_id
375375 * @param bool $getText, fetch fr_text and fr_flags too?
376376 * @return Revision
377 - * Will not return if deleted
 377+ * Will not return a revision if deleted
378378 */
379379 public function getFlaggedRev( $title, $rev_id, $getText=false ) {
380380 $selectColumns = array('fr_rev_id','fr_user','fr_timestamp','fr_comment','rev_timestamp');
@@ -413,17 +413,6 @@
414414
415415 return $count;
416416 }
417 -
418 - /**
419 - * Get latest quality rev, if not, the latest reviewed one.
420 - * @param Title $title, page title
421 - * @param bool $getText, fetch fr_text and fr_flags too?
422 - * @param bool $forUpdate, use master DB and avoid using page_ext_stable?
423 - * @return Row
424 - */
425 - public function getStableRev( $title, $getText=false, $forUpdate=false ) {
426 - return $this->getStablePageRev( $title, $getText, $forUpdate );
427 - }
428417
429418 /**
430419 * Get latest quality rev, if not, the latest reviewed one.
@@ -457,7 +446,7 @@
458447 return null;
459448 } else {
460449 // Get visiblity settings...
461 - $config = $this->getVisibilitySettings( $title, $forUpdate );
 450+ $config = $this->getPageVisibilitySettings( $title, $forUpdate );
462451 $dbw = wfGetDB( DB_MASTER );
463452 // Look for the latest quality revision
464453 if( $config['select'] !== FLAGGED_VIS_LATEST ) {
@@ -488,16 +477,6 @@
489478 }
490479 return $row;
491480 }
492 -
493 - /**
494 - * Get visiblity restrictions on page
495 - * @param Title $title, page title
496 - * @param bool $forUpdate, use master DB?
497 - * @returns Array
498 - */
499 - public function getVisibilitySettings( $title, $forUpdate=false ) {
500 - return $this->getPageVisibilitySettings( $title, $forUpdate );
501 - }
502481
503482 /**
504483 * Get visiblity restrictions on page
@@ -525,15 +504,6 @@
526505 * @param int $rev_id
527506 * @return Array
528507 */
529 - public function getFlagsForRevision( $rev_id ) {
530 - return $this->getRevisionTags( $rev_id );
531 - }
532 -
533 - /**
534 - * Get flags for a revision
535 - * @param int $rev_id
536 - * @return Array
537 - */
538508 public function getRevisionTags( $rev_id ) {
539509 # Set all flags to zero
540510 $flags = array();
@@ -604,7 +574,7 @@
605575 * @param Title, $title
606576 * @return bool
607577 */
608 - public function isReviewable( $title ) {
 578+ public function isPageReviewable( $title ) {
609579 global $wgFlaggedRevsNamespaces;
610580
611581 return ( in_array($title->getNamespace(),$wgFlaggedRevsNamespaces)
@@ -899,10 +869,10 @@
900870 public function extraLinksUpdate( $linksUpdate ) {
901871 wfProfileIn( __METHOD__ );
902872
903 - if( !$this->isReviewable( $linksUpdate->mTitle ) )
 873+ if( !$this->isPageReviewable( $linksUpdate->mTitle ) )
904874 return true;
905875 # Check if this page has a stable version
906 - $sv = $this->getStableRev( $linksUpdate->mTitle, true, true );
 876+ $sv = $this->getStablePageRev( $linksUpdate->mTitle, true, true );
907877 if( !$sv )
908878 return true;
909879 # Parse the revision
@@ -1043,9 +1013,9 @@
10441014 * Add a link to patrol non-reviewable pages
10451015 */
10461016 public function addPatrolLink( $diff, $OldRev, $NewRev ) {
1047 - global $wgUser, $wgOut, $wgFlaggedRevs;
 1017+ global $wgUser, $wgOut;
10481018
1049 - if( $wgFlaggedRevs->isReviewable( $NewRev->getTitle() ) )
 1019+ if( $this->isPageReviewable( $NewRev->getTitle() ) )
10501020 return true;
10511021 // Prepare a change patrol link, if applicable
10521022 if( $wgUser->isAllowed( 'patrolother' ) ) {
@@ -1108,7 +1078,7 @@
11091079 $prev_id = $article->mTitle->getPreviousRevisionID( $rev->getID() );
11101080 if( !$prev_id )
11111081 return true;
1112 - $frev = $this->getStableRev( $article->mTitle );
 1082+ $frev = $this->getStablePageRev( $article->mTitle );
11131083 # Is this an edit directly to the stable version?
11141084 if( is_null($frev) || $prev_id != $frev->fr_rev_id )
11151085 return true;
@@ -1135,7 +1105,7 @@
11361106 if( $action != 'move' )
11371107 return true;
11381108 # See if there is a stable version
1139 - $frev = $this->getStableRev( $title );
 1109+ $frev = $this->getStablePageRev( $title );
11401110 if( !$frev )
11411111 return true;
11421112 # Allow for only editors/reviewers to move this
@@ -1154,12 +1124,12 @@
11551125 * are autopatrolled.
11561126 */
11571127 public function autoMarkPatrolled( $article, $user, $text, $c, $m, $a, $b, $flags, $rev ) {
1158 - global $wgUser, $wgFlaggedRevs;
 1128+ global $wgUser;
11591129
11601130 if( !$rev )
11611131 return true;
11621132
1163 - if( !$wgFlaggedRevs->isReviewable( $article->getTitle() ) && $wgUser->isAllowed('patrolother') ) {
 1133+ if( !$this->isPageReviewable( $article->getTitle() ) && $wgUser->isAllowed('patrolother') ) {
11641134 $dbw = wfGetDB( DB_MASTER );
11651135 $dbw->update( 'recentchanges',
11661136 array( 'rc_patrolled' => 1 ),
@@ -1292,7 +1262,7 @@
12931263 # Only trigger on article view for content pages, not for protect/delete/hist
12941264 if( $action !='view' || !$wgUser->isAllowed( 'review' ) )
12951265 return true;
1296 - if( !$article || !$article->exists() || !$this->isReviewable( $article->mTitle ) )
 1266+ if( !$article || !$article->exists() || !$this->isPageReviewable( $article->mTitle ) )
12971267 return true;
12981268
12991269 $parserCache = ParserCache::singleton();
@@ -1307,11 +1277,29 @@
13081278 }
13091279
13101280 ######### Stub functions, overridden by subclass #########
 1281+
 1282+ public function pageOverride() { return false; }
13111283
1312 - function pageOverride() { return false; }
 1284+ public function showStableByDefault() { return false; }
13131285
1314 - function showStableByDefault() { return false; }
 1286+ public function addTagRatings( $flags, $prettyBox = false, $css='' ) {}
13151287
 1288+ public function prettyRatingBox( $tfrev, $flags, $revs_since, $stable=true ) {}
 1289+
 1290+ public function ReviewNotes( $row ) {}
 1291+
 1292+ public function injectReviewDiffURLParams( $article, &$sectionanchor, &$extraq ) {}
 1293+
 1294+ public function addDiffNoticeAfterEdit( $diff, $OldRev, $NewRev ) {}
 1295+
 1296+ public function getStableRev( $getText=false, $forUpdate=false ) {}
 1297+
 1298+ public function getVisibilitySettings( $forUpdate=false ) {}
 1299+
 1300+ public function getFlagsForRevision( $rev_id ) {}
 1301+
 1302+ public function isReviewable() {}
 1303+
13161304 function setPageContent( $article, &$outputDone, &$pcache ) {}
13171305
13181306 function addToEditView( $editform ) {}
@@ -1328,16 +1316,6 @@
13291317
13301318 function addVisibilityLink( $out ) {}
13311319
1332 - public function addTagRatings( $flags, $prettyBox = false, $css='' ) {}
1333 -
1334 - public function prettyRatingBox( $tfrev, $flags, $revs_since, $stable=true ) {}
1335 -
1336 - public function ReviewNotes( $row ) {}
1337 -
1338 - public function injectReviewDiffURLParams( $article, &$sectionanchor, &$extraq ) {}
1339 -
1340 - public function addDiffNoticeAfterEdit( $diff, $OldRev, $NewRev ) {}
1341 -
13421320 #########
13431321
13441322 }
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -5,16 +5,16 @@
66 * Does the config and current URL params allow
77 * for overriding by stable revisions?
88 */
9 - function pageOverride() {
 9+ public function pageOverride() {
1010 global $wgFlaggedRevs, $wgTitle, $wgUser, $wgRequest, $action;
1111 # This only applies to viewing content pages
12 - if( $action !='view' || !$this->isReviewable( $wgTitle ) )
 12+ if( $action !='view' || !$this->isReviewable() )
1313 return false;
1414 # Does not apply to diffs/old revisions
1515 if( $wgRequest->getVal('oldid') || $wgRequest->getVal('diff') )
1616 return false;
1717 # Get page configuration
18 - $config = $wgFlaggedRevs->getVisibilitySettings( $wgTitle );
 18+ $config = $wgFlaggedRevs->getVisibilitySettings();
1919 # Does the stable version override the current one?
2020 if( $config['override'] ) {
2121 global $wgFlaggedRevsExceptions;
@@ -39,7 +39,7 @@
4040 /**
4141 * Is this user shown the stable version by default for this page?
4242 */
43 - function showStableByDefault() {
 43+ public function showStableByDefault() {
4444 global $wgFlaggedRevsOverride, $wgFlaggedRevsExceptions, $wgUser;
4545 # Get page configuration
4646 $config = $this->getVisibilitySettings();
@@ -56,6 +56,15 @@
5757 }
5858 return true;
5959 }
 60+
 61+ /**
 62+ * Is this article reviewable?
 63+ */
 64+ public function isReviewable() {
 65+ global $wgTitle;
 66+
 67+ return $this->isPageReviewable( $wgTitle );
 68+ }
6069
6170 /**
6271 * Replaces a page with the last stable version if possible
@@ -67,7 +76,7 @@
6877
6978 $skin = $wgUser->getSkin();
7079 # For unreviewable pages, allow for basic patrolling
71 - if( !$this->isReviewable( $article->mTitle ) ) {
 80+ if( !$this->isPageReviewable( $article->mTitle ) ) {
7281 # If we have been passed an &rcid= parameter, we want to give the user a
7382 # chance to mark this new article as patrolled.
7483 $rcid = $wgRequest->getIntOrNull( 'rcid' );
@@ -96,7 +105,7 @@
97106 $vis_id = $revid;
98107 $tag = $notes = '';
99108 # Check the newest stable version...
100 - $tfrev = $this->getStableRev( null, true );
 109+ $tfrev = $this->getStableRev( true );
101110 $simpleTag = false;
102111 if( $wgRequest->getVal('diff') || $wgRequest->getVal('oldid') ) {
103112 // Do not clutter up diffs any further...
@@ -209,7 +218,7 @@
210219 function addToEditView( $editform ) {
211220 global $wgRequest, $wgTitle, $wgOut;
212221 # Talk pages cannot be validated
213 - if( !$editform->mArticle || !$this->isReviewable( $wgTitle ) )
 222+ if( !$editform->mArticle || !$this->isReviewable() )
214223 return false;
215224 # Find out revision id
216225 if( $editform->mArticle->mRevision ) {
@@ -266,7 +275,7 @@
267276 function addReviewForm( $out ) {
268277 global $wgArticle, $wgRequest, $action;
269278
270 - if( !$wgArticle || !$wgArticle->exists() || !$this->isReviewable( $wgArticle->mTitle ) )
 279+ if( !$wgArticle || !$wgArticle->exists() || !$this->isReviewable() )
271280 return true;
272281 # Check if page is protected
273282 if( $action !='view' || !$wgArticle->mTitle->quickUserCan( 'edit' ) ) {
@@ -293,7 +302,7 @@
294303 function addVisibilityLink( $out ) {
295304 global $wgUser, $wgRequest, $wgTitle, $action;
296305
297 - if( !$this->isReviewable( $wgTitle ) )
 306+ if( !$this->isReviewable() )
298307 return true;
299308
300309 if( $action=='protect' || $action=='unprotect' ) {
@@ -326,7 +335,7 @@
327336 # Are we using the popular cite extension?
328337 global $wgHooks;
329338 if( in_array('wfSpecialCiteNav',$wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink']) ) {
330 - if( $this->isReviewable( $sktmp->mTitle ) && $revid !== 0 ) {
 339+ if( $this->isPageReviewable( $sktmp->mTitle ) && $revid !== 0 ) {
331340 $nav_urls['cite'] = array(
332341 'text' => wfMsg( 'cite_article_link' ),
333342 'href' => $sktmp->makeSpecialUrl( 'Cite', "page=" . wfUrlencode( "{$sktmp->thispage}" ) . "&id={$tfrev->fr_rev_id}" )
@@ -343,7 +352,7 @@
344353 return true;
345354 $title = $sktmp->mTitle->getSubjectPage();
346355 # Non-content pages cannot be validated
347 - if( !$this->isReviewable( $title ) || !$title->exists() )
 356+ if( !$this->isPageReviewable( $title ) || !$title->exists() )
348357 return true;
349358 $article = new Article( $title );
350359 # If we are viewing a page normally, and it was overridden,
@@ -459,7 +468,7 @@
460469 function addToHistLine( $row, &$s ) {
461470 global $wgUser, $wgTitle;
462471 # Non-content pages cannot be validated
463 - if( !$this->isReviewable( $wgTitle ) )
 472+ if( !$this->isReviewable() )
464473 return true;
465474
466475 if( !isset($this->dbw) ) {
@@ -705,7 +714,7 @@
706715 if( !$wgUser->isAllowed( 'review') || !$wgRequest->getBool('editreview') || !$NewRev->isCurrent() )
707716 return true;
708717
709 - $frev = $this->getStableRev( $diff->mTitle );
 718+ $frev = $this->getStableRev();
710719 if( !$frev || $frev->fr_rev_id != $OldRev->getID() )
711720 return true;
712721
@@ -765,7 +774,7 @@
766775 public function injectReviewDiffURLParams( $article, &$sectionanchor, &$extraq ) {
767776 global $wgUser, $wgReviewChangesAfterEdit;
768777
769 - $frev = $this->getStableRev( $article->getTitle() );
 778+ $frev = $this->getStableRev();
770779 # Was this already autoreviewed, are we allowed?
771780 if( $this->skipReviewDiff || !$wgReviewChangesAfterEdit || !$wgUser->isAllowed('review') ) {
772781 if( $frev ) {
@@ -784,7 +793,7 @@
785794 * Same params for the sake of inheritance
786795 * @return Row
787796 */
788 - function getStableRev( $t=null, $getText=false, $forUpdate=false ) {
 797+ public function getStableRev( $getText=false, $forUpdate=false ) {
789798 global $wgTitle, $wgFlaggedRevs;
790799 # Cached results available?
791800 if( $getText ) {
@@ -814,7 +823,7 @@
815824 * Same params for the sake of inheritance
816825 * @returns Array
817826 */
818 - public function getVisibilitySettings( $t=null, $forUpdate=false ) {
 827+ public function getVisibilitySettings( $forUpdate=false ) {
819828 global $wgTitle;
820829 # Cached results available?
821830 if( isset($this->pageconfig) ) {
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.php
@@ -48,7 +48,7 @@
4949 $this->page = Title::newFromUrl( $this->target );
5050 // Revision ID
5151 $this->oldid = $wgRequest->getIntOrNull( 'oldid' );
52 - if( !$this->target || !$this->oldid || !$wgFlaggedRevs->isReviewable( $this->page ) ) {
 52+ if( !$this->target || !$this->oldid || !$wgFlaggedRevs->isPageReviewable( $this->page ) ) {
5353 $wgOut->addHTML( wfMsgExt('revreview-main',array('parse')) );
5454 return;
5555 }
@@ -572,7 +572,7 @@
573573 function showStableList() {
574574 global $wgOut, $wgUser, $wgLang, $wgFlaggedRevs;
575575 // Must be a content page
576 - if( !$wgFlaggedRevs->isReviewable( $this->page ) ) {
 576+ if( !$wgFlaggedRevs->isPageReviewable( $this->page ) ) {
577577 $wgOut->addHTML( wfMsgExt('stableversions-none', array('parse'),
578578 $this->page->getPrefixedText() ) );
579579 return;
@@ -905,7 +905,7 @@
906906 $wgOut->addHTML( wfMsgExt( 'stabilization-notexists', array('parseinline'),
907907 $this->page->getPrefixedText() ) );
908908 $isValid = false;
909 - } else if( !$wgFlaggedRevs->isReviewable( $this->page ) ) {
 909+ } else if( !$wgFlaggedRevs->isPageReviewable( $this->page ) ) {
910910 $wgOut->addHTML( wfMsgExt( 'stabilization-notcontent', array('parseinline'),
911911 $this->page->getPrefixedText() ) );
912912 $isValid = false;
@@ -943,7 +943,7 @@
944944 function showSettings() {
945945 global $wgOut, $wgScript, $wgTitle, $wgUser, $wgFlaggedRevs;
946946 // Must be a content page
947 - if( !$wgFlaggedRevs->isReviewable( $this->page ) ) {
 947+ if( !$wgFlaggedRevs->isPageReviewable( $this->page ) ) {
948948 $wgOut->addHTML( wfMsgExt('stableversions-none', array('parse'),
949949 $this->page->getPrefixedText() ) );
950950 return;

Status & tagging log