r21999 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21998‎ | r21999 | r22000 >
Date:17:57, 8 May 2007
Author:aaron
Status:old
Tags:
Comment:
*Bumping up content overriding to ArticleViewHeader hook, this avoids parsing/saving, only to parse/save again and not use the previous data
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -587,7 +587,7 @@
588588 * Callback that autopromotes user according to the setting in
589589 * $wgFlaggedRevsAutopromote
590590 */
591 - private static function autoPromoteUser( $article, $user, $text, $summary, $isminor, $iswatch, $section ) {
 591+ private static function autoPromoteUser( &$article, &$user, &$text, &$summary, &$isminor, &$iswatch, &$section ) {
592592 global $wgUser, $wgFlaggedRevsAutopromote;
593593
594594 $groups = $user->getGroups();
@@ -603,8 +603,7 @@
604604 # Do not re-add status if it was previously removed...
605605 $fname = 'FlaggedRevs::autoPromoteUser';
606606 $db = wfGetDB( DB_SLAVE );
607 - $result = $db->select(
608 - array('logging'),
 607+ $result = $db->select('logging',
609608 array('log_user'),
610609 array("log_type='validate'", "log_action='revoke1'", 'log_namespace' => NS_USER, 'log_title' => $user->getName() ),
611610 $fname,
@@ -635,31 +634,32 @@
636635 * Adds stable version status/info tags and notes
637636 * Adds a quick review form on the bottom if needed
638637 */
639 - function setPageContent( &$out ) {
640 - global $wgArticle, $wgRequest, $wgTitle, $action;
 638+ function setPageContent( &$article, &$outputDone, &$pcache ) {
 639+ global $wgRequest, $wgTitle, $wgOut, $action;
641640 // Only trigger on article view, not for protect/delete/hist
642641 // Talk pages cannot be validated
643 - if( !$wgArticle || !$wgTitle->isContentPage() || $action !='view' ) return;
 642+ if( !$article || !$article->mTitle->isContentPage() || $action !='view' )
 643+ return;
644644 // Grab page and rev ids
645 - $pageid = $wgArticle->getId();
646 - $revid = ( $wgArticle->mRevision ) ? $wgArticle->mRevision->mId : $wgArticle->getLatest();
 645+ $pageid = $article->getId();
 646+ $revid = ( $article->mRevision ) ? $article->mRevision->mId : $article->getLatest();
647647 // There must be a valid rev ID
648648 if( !$revid ) return;
649649
650650 $vis_id = $revid;
651 - $tag = ''; $notes = ''; $newbody = $out->mBodytext;
 651+ $tag = ''; $notes = '';
652652 // Check the newest stable version...
653653 $quality = false; $featured = false;
654654 if ( $this->pageOverride() ) {
655655 // getLatestQualityRev() is slower, don't use it if we won't need to
656 - $tfrev = $this->getLatestQualityRev();
 656+ $tfrev = $this->getLatestQualityRev( $article );
657657 if ( is_null($tfrev) ) {
658 - $tfrev = $this->getLatestStableRev();
 658+ $tfrev = $this->getLatestStableRev( $article );
659659 } else {
660660 $quality = true;
661661 }
662662 } else {
663 - $tfrev = $this->getLatestStableRev();
 663+ $tfrev = $this->getLatestStableRev( $article );
664664 }
665665 if( $wgRequest->getVal('diff') ) {
666666 // Do not clutter up diffs any further...
@@ -700,27 +700,29 @@
701701 $vis_id = $tfrev->fr_rev_id;
702702 $revs_since = parent::getRevCountSince( $pageid, $vis_id );
703703 if ( $quality )
704 - $tag = wfMsgExt('revreview-quality', array('parse'), $vis_id, $wgArticle->getLatest(), $revs_since, $time);
 704+ $tag = wfMsgExt('revreview-quality', array('parse'), $vis_id, $article->getLatest(), $revs_since, $time);
705705 else
706 - $tag = wfMsgExt('revreview-basic', array('parse'), $vis_id, $wgArticle->getLatest(), $revs_since, $time);
 706+ $tag = wfMsgExt('revreview-basic', array('parse'), $vis_id, $article->getLatest(), $revs_since, $time);
707707 # Try the stable page cache
708 - $parserOutput = parent::getPageCache( $wgArticle );
709 - $newbody = $parserOutput ? $parserOutput->getText() : false;
 708+ $parserOutput = parent::getPageCache( $article );
710709 # If no cache is available, get the text and parse it
711 - if ( $newbody==false ) {
 710+ if ( $parserOutput==false ) {
712711 $text = parent::getFlaggedRevText( $vis_id );
713712 $options = ParserOptions::newFromUser($wgUser);
714713 $parserOutput = parent::parseStableText( $wgTitle, $text, $vis_id, $options, $tfrev->fr_timestamp );
715714 # Update the general cache
716 - parent::updatePageCache( $wgArticle, $parserOutput );
717 - $newbody = $parserOutput->getText();
 715+ parent::updatePageCache( $article, $parserOutput );
718716 }
 717+ $wgOut->addHTML( $parserOutput->getText() );
719718 # Show stable categories and interwiki links only
720 - $out->mCategoryLinks = array();
721 - $out->addCategoryLinks( $parserOutput->getCategories() );
722 - $out->mLanguageLinks = array();
723 - $out->addLanguageLinks( $parserOutput->getLanguageLinks() );
 719+ $wgOut->mCategoryLinks = array();
 720+ $wgOut->addCategoryLinks( $parserOutput->getCategories() );
 721+ $wgOut->mLanguageLinks = array();
 722+ $wgOut->addLanguageLinks( $parserOutput->getLanguageLinks() );
724723 $notes = parent::ReviewNotes( $tfrev );
 724+ // Tell MW that parser output is done
 725+ $outputDone = true;
 726+ $pcache = false;
725727 }
726728 // Construct some tagging
727729 $tag .= parent::addTagRatings( $flags );
@@ -732,14 +734,14 @@
733735 else
734736 $tag = '<div class="flaggedrevs_tag1 plainlinks">'.$tag.'</div>';
735737 // Set the new body HTML, place a tag on top
736 - $out->mBodytext = $tag . $newbody . $notes;
 738+ $wgOut->mBodytext = $tag . $wgOut->mBodytext . $notes;
737739 } else {
738740 $tag = '<div class="mw-warning plainlinks">'.wfMsgExt('revreview-noflagged', array('parse')).'</div>';
739 - $out->mBodytext = $tag . $out->mBodytext;
 741+ $wgOut->addHTML( $tag );
740742 }
741743 // Show review links for the VISIBLE revision
742744 // We cannot review deleted revisions
743 - if( is_object($wgArticle->mRevision) && $wgArticle->mRevision->mDeleted ) return;
 745+ if( is_object($article->mRevision) && $article->mRevision->mDeleted ) return;
744746 // Add quick review links IF we did not override, otherwise, they might
745747 // review a revision that parses out newer templates/images than what they say
746748 // Note: overrides are never done when viewing with "oldid="
@@ -818,7 +820,9 @@
819821 * per the $wgFlaggedRevTags variable
820822 * This passes rev_deleted revisions
821823 * This is based on the current article and caches results
822 - * @param Article $article, used when in edit mode
 824+ * Accepts an argument because of the fact that the article
 825+ * object for edit mode is part of the editform; insert only
 826+ * the article object for the current page!
823827 * @output array ( rev, flags )
824828 */
825829 function getLatestQualityRev( $article=NULL ) {
@@ -1049,7 +1053,7 @@
10501054
10511055 $flaggedrevs = new FlaggedRevs();
10521056 $flaggedarticle = new FlaggedArticle();
1053 -$wgHooks['BeforePageDisplay'][] = array($flaggedarticle, 'setPageContent');
 1057+$wgHooks['ArticleViewHeader'][] = array($flaggedarticle, 'setPageContent');
10541058 $wgHooks['DiffViewHeader'][] = array($flaggedarticle, 'addToDiff');
10551059 $wgHooks['EditPage::showEditForm:initial'][] = array($flaggedarticle, 'addToEditView');
10561060 $wgHooks['SkinTemplateTabs'][] = array($flaggedarticle, 'setCurrentTab');