r36406 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36405‎ | r36406 | r36407 >
Date:06:56, 18 June 2008
Author:aaron
Status:old
Tags:
Comment:
* Tweak robot policy to skip the draft
* Split off some code
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -143,25 +143,14 @@
144144 return true;
145145 }
146146
 147+
147148 /**
148 - * Replaces a page with the last stable version if possible
149 - * Adds stable version status/info tags and notes
150 - * Adds a quick review form on the bottom if needed
 149+ * Add a stable link when viewing old versions of an article that
 150+ * have been reviewed. (e.g. for &oldid=x urls)
151151 */
152 - public function setPageContent( &$outputDone, &$pcache ) {
153 - global $wgRequest, $wgOut, $wgUser, $wgLang;
154 - # Only trigger for reviewable pages
155 - if( !FlaggedRevs::isPageReviewable( $this->parent->getTitle() ) ) {
156 - return true;
157 - }
158 - # Only trigger on article view for content pages, not for protect/delete/hist...
159 - $action = $wgRequest->getVal( 'action', 'view' );
160 - if( ($action !='view' && $action !='purge') || !$this->parent->exists() )
161 - return true;
162 - # Do not clutter up diffs any further...
163 - if( $wgRequest->getVal('diff') ) {
164 - return true;
165 - } else if( $wgRequest->getVal('oldid') ) {
 152+ public function addStableLink() {
 153+ global $wgRequest, $wgOut, $wgLang;
 154+ if( $wgRequest->getVal('oldid') ) {
166155 # We may have nav links like "direction=prev&oldid=x"
167156 $revID = $this->parent->getOldIDFromRequest();
168157 $frev = FlaggedRevision::newFromTitle( $this->parent->getTitle(), $revID );
@@ -183,8 +172,29 @@
184173 $tag = "<div id='mw-revisiontag-old' class='flaggedrevs_notice plainlinks noprint'>$tag</div>";
185174 $wgOut->addHTML( $tag );
186175 }
 176+ }
 177+ return true;
 178+ }
 179+
 180+ /**
 181+ * Replaces a page with the last stable version if possible
 182+ * Adds stable version status/info tags and notes
 183+ * Adds a quick review form on the bottom if needed
 184+ */
 185+ public function setPageContent( &$outputDone, &$pcache ) {
 186+ global $wgRequest, $wgOut, $wgUser, $wgLang;
 187+ # Only trigger for reviewable pages
 188+ if( !FlaggedRevs::isPageReviewable( $this->parent->getTitle() ) ) {
187189 return true;
188190 }
 191+ # Only trigger on article view for content pages, not for protect/delete/hist...
 192+ $action = $wgRequest->getVal( 'action', 'view' );
 193+ if( ($action !='view' && $action !='purge') || !$this->parent->exists() )
 194+ return true;
 195+ # Do not clutter up diffs any further and leave archived versions alone...
 196+ if( $wgRequest->getVal('diff') || $wgRequest->getVal('oldid') ) {
 197+ return true;
 198+ }
189199 $simpleTag = $old = $stable = false;
190200 $tag = $notes = $pending = '';
191201 # Check the newest stable version.
@@ -259,13 +269,13 @@
260270 $wgOut->addParserOutput( $parserOut );
261271 $wgOut->setRevisionId( $frev->getRevId() );
262272 $notes = $this->getReviewNotes( $frev );
 273+ # Index the stable version only
 274+ $wgOut->setRobotpolicy( 'noindex,nofollow' );
263275 # Tell MW that parser output is done
264276 $outputDone = true;
265277 $pcache = false;
266 - // Looking at some specific old revision or if FlaggedRevs is not
267 - // set to override given the relevant conditions. If the user is
268 - // requesting the stable revision ("&stableid=x"), defer to override
269 - // behavior below, since it is the same as ("&stable=1").
 278+ // Looking at some specific old revision (&oldid=x) or if FlaggedRevs is not
 279+ // set to override given the relevant conditions (like &action=protect).
270280 } else if( !$stable && !$this->pageOverride() ) {
271281 $revsSince = FlaggedRevs::getRevCountSince( $this->parent, $frev->getRevId() );
272282 $synced = false;
@@ -326,6 +336,8 @@
327337 }
328338 }
329339 }
 340+ # Index the stable version only
 341+ $wgOut->setRobotpolicy( 'noindex,nofollow' );
330342 // The relevant conditions are met to override the page with the stable version.
331343 } else {
332344 # We will be looking at the reviewed revision...
@@ -662,7 +674,7 @@
663675 return true;
664676
665677 $action = $wgRequest->getVal( 'action', 'view' );
666 - if( $action=='protect' || $action=='unprotect' ) {
 678+ if( $action == 'protect' || $action == 'unprotect' ) {
667679 # Check for an overridabe revision
668680 $frev = $this->getStableRev( true );
669681 if( !$frev )
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -2013,6 +2013,7 @@
20142014 static function onArticleViewHeader( $article, &$outputDone, &$pcache ) {
20152015 $flaggedArticle = FlaggedArticle::getInstance( $article );
20162016 $flaggedArticle->maybeUpdateMainCache( $outputDone, $pcache );
 2017+ $flaggedArticle->addStableLink( $outputDone, $pcache );
20172018 $flaggedArticle->setPageContent( $outputDone, $pcache );
20182019 $flaggedArticle->addPatrolLink( $outputDone, $pcache );
20192020 return true;

Status & tagging log