r44045 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44044‎ | r44045 | r44046 >
Date:19:16, 29 November 2008
Author:aaron
Status:deferred
Tags:
Comment:
*(bug 16495) FlaggedRevs should not unavoidably disable core RC patrolling
*Fixes for $wgFlaggedRevsReviewForDefault
*Various code cleanup
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -147,13 +147,29 @@
148148 */
149149 public function isReviewable( $titleOnly = false ) {
150150 global $wgFlaggedRevsReviewForDefault;
151 - if( !FlaggedRevs::isPageReviewable( $this->parent->getTitle() ) )
 151+ if( !FlaggedRevs::isPageReviewable( $this->parent->getTitle() ) ) {
152152 return false;
153 - if( !$titleOnly && $wgFlaggedRevsReviewForDefault && !$this->showStableByDefault() )
 153+ } else if( !$titleOnly && $wgFlaggedRevsReviewForDefault && !$this->showStableByDefault() ) {
154154 return false;
 155+ }
155156 return true;
156157 }
157158
 159+ /**
 160+ * Is this page in patrolable?
 161+ * @param bool $titleOnly, only check if title is in reviewable namespace
 162+ * @return bool
 163+ */
 164+ public function isPatrollable( $titleOnly = false ) {
 165+ global $wgFlaggedRevsReviewForDefault;
 166+ if( FlaggedRevs::isPagePatrollable( $this->parent->getTitle() ) ) {
 167+ return true;
 168+ } else if( !$titleOnly && $wgFlaggedRevsReviewForDefault && !$this->showStableByDefault() ) {
 169+ return true;
 170+ }
 171+ return false;
 172+ }
 173+
158174 /**
159175 * Is this article rateable?
160176 */
@@ -209,7 +225,7 @@
210226 public function setPageContent( &$outputDone, &$pcache ) {
211227 global $wgRequest, $wgOut, $wgUser, $wgLang;
212228 # Only trigger for reviewable pages
213 - if( !$this->isReviewable(true) ) {
 229+ if( !$this->isReviewable() ) {
214230 return true;
215231 }
216232 # Only trigger on article view for content pages, not for protect/delete/hist...
@@ -728,13 +744,13 @@
729745 public function addPatrolLink( &$outputDone, &$pcache ) {
730746 global $wgRequest, $wgOut, $wgUser;
731747 # For unreviewable pages, allow for basic patrolling
732 - if( !FlaggedRevs::isPagePatrollable( $this->parent->getTitle() ) ) {
 748+ if( !$this->isPatrollable() ) {
733749 return true;
734750 }
735751 # If we have been passed an &rcid= parameter, we want to give the user a
736752 # chance to mark this new article as patrolled.
737753 $rcid = $wgRequest->getIntOrNull( 'rcid' );
738 - if( !is_null( $rcid ) && $rcid != 0 && $wgUser->isAllowed( 'review' ) ) {
 754+ if( !empty($rcid) && $wgUser->isAllowed( 'review' ) ) {
739755 wfLoadExtensionMessages( 'FlaggedRevs' );
740756 $reviewTitle = SpecialPage::getTitleFor( 'RevisionReview' );
741757 $token = $wgUser->editToken( $this->parent->getTitle()->getPrefixedText(), $rcid );
@@ -753,7 +769,7 @@
754770 public function addVisibilityLink( &$data ) {
755771 global $wgUser, $wgRequest, $wgOut;
756772 # Check only if the title is reviewable
757 - if( !$this->isReviewable(true) ) {
 773+ if( !$this->isReviewable() ) {
758774 return true;
759775 }
760776 $action = $wgRequest->getVal( 'action', 'view' );
@@ -784,8 +800,25 @@
785801 global $wgRequest, $wgUser, $wgFlaggedRevTabs;
786802 $title = $this->parent->getTitle()->getSubjectPage();
787803 # Non-content pages cannot be validated
788 - if( !FlaggedRevs::isPageReviewable( $title ) || !$title->exists() )
 804+ if( !$this->isReviewable(true) || !$title->exists() )
789805 return true;
 806+ # We can change the behavoir of stable version for this page to be different
 807+ # than the site default.
 808+ if( !$skin->mTitle->isTalkPage() && $wgUser->isAllowed('stablesettings') ) {
 809+ wfLoadExtensionMessages( 'Stabilization' );
 810+ $stableTitle = SpecialPage::getTitleFor( 'Stabilization' );
 811+ if( !isset($contentActions['protect']) && !isset($contentActions['unprotect']) ) {
 812+ wfLoadExtensionMessages( 'Stabilization' );
 813+ $contentActions['default'] = array(
 814+ 'class' => false,
 815+ 'text' => wfMsg('stabilization-tab'),
 816+ 'href' => $stableTitle->getLocalUrl('page='.$title->getPrefixedUrl())
 817+ );
 818+ }
 819+ }
 820+ # Check config
 821+ if( !$this->isReviewable() )
 822+ return true;
790823 # If we are viewing a page normally, and it was overridden,
791824 # change the edit tab to a "current revision" tab
792825 $srev = $this->getStableRev();
@@ -813,20 +846,6 @@
814847 $contentActions['viewsource']['href'] = $title->getLocalUrl( 'action=edit' );
815848 }
816849 }
817 - # We can change the behavoir of stable version for this page to be different
818 - # than the site default.
819 - if( !$skin->mTitle->isTalkPage() && $wgUser->isAllowed('stablesettings') ) {
820 - wfLoadExtensionMessages( 'Stabilization' );
821 - $stableTitle = SpecialPage::getTitleFor( 'Stabilization' );
822 - if( !isset($contentActions['protect']) && !isset($contentActions['unprotect']) ) {
823 - wfLoadExtensionMessages( 'Stabilization' );
824 - $contentActions['default'] = array(
825 - 'class' => false,
826 - 'text' => wfMsg('stabilization-tab'),
827 - 'href' => $stableTitle->getLocalUrl('page='.$title->getPrefixedUrl())
828 - );
829 - }
830 - }
831850 // Add auxillary tabs...
832851 if( !$wgFlaggedRevTabs || $synced )
833852 return true;
@@ -937,8 +956,7 @@
938957 */
939958 public function addDiffNoticeAndIncludes( $diff, $oldRev, $newRev ) {
940959 global $wgRequest, $wgUser, $wgOut, $wgMemc;
941 -
942 - if( $wgOut->isPrintable() || !FlaggedRevs::isPageReviewable( $newRev->getTitle() ) )
 960+ if( $wgOut->isPrintable() || !$this->isReviewable() )
943961 return true;
944962 # Load required messages
945963 wfLoadExtensionMessages( 'FlaggedRevs' );
@@ -1125,10 +1143,7 @@
11261144 public function addPatrolAndDiffLink( $diff, $oldRev, $newRev ) {
11271145 global $wgUser, $wgOut;
11281146 // Is there a stable version?
1129 - if( FlaggedRevs::isPageReviewable( $newRev->getTitle() ) ) {
1130 - if( !$oldRev ) {
1131 - return true;
1132 - }
 1147+ if( $oldRev && $this->isReviewable() ) {
11331148 wfLoadExtensionMessages( 'FlaggedRevs' );
11341149 $frev = $this->getStableRev();
11351150 if( $frev && $frev->getRevId() == $oldRev->getID() && $newRev->isCurrent() ) {
@@ -1145,19 +1160,18 @@
11461161 }
11471162 }
11481163 // Prepare a change patrol link, if applicable
1149 - } else if( FlaggedRevs::isPagePatrollable( $newRev->getTitle() ) && $wgUser->isAllowed( 'review' ) ) {
 1164+ } else if( $this->isPatrollable() && $wgUser->isAllowed( 'review' ) ) {
11501165 wfLoadExtensionMessages( 'FlaggedRevs' );
11511166 // If we've been given an explicit change identifier, use it; saves time
11521167 if( $diff->mRcidMarkPatrolled ) {
11531168 $rcid = $diff->mRcidMarkPatrolled;
11541169 } else {
11551170 # Look for an unpatrolled change corresponding to this diff
1156 - $dbr = wfGetDB( DB_SLAVE );
11571171 $change = RecentChange::newFromConds(
11581172 array(
11591173 # Add redundant user,timestamp condition so we can use the existing index
11601174 'rc_user_text' => $diff->mNewRev->getRawUserText(),
1161 - 'rc_timestamp' => $dbr->timestamp( $diff->mNewRev->getTimestamp() ),
 1175+ 'rc_timestamp' => wfGetDB( DB_SLAVE )->timestamp( $diff->mNewRev->getTimestamp() ),
11621176 'rc_this_oldid' => $diff->mNewid,
11631177 'rc_last_oldid' => $diff->mOldid,
11641178 'rc_patrolled' => 0

Status & tagging log