r60533 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60532‎ | r60533 | r60534 >
Date:01:35, 1 January 2010
Author:aaron
Status:ok
Tags:
Comment:
* Changed 2-stage parsing to 1-state parsing for review. Expanded text isn't stored anymore, so this step isn't needed.
* Broke long lines
Modified paths:
  • /trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php
@@ -31,7 +31,8 @@
3232
3333 public function execute( $par ) {
3434 global $wgRequest, $wgUser, $wgOut;
35 - $confirm = $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) );
 35+ $confirm = $wgRequest->wasPosted()
 36+ && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) );
3637 if( $wgUser->isAllowed( 'review' ) ) {
3738 if( $wgUser->isBlocked( !$confirm ) ) {
3839 $wgOut->blockedPage();
@@ -150,7 +151,8 @@
151152
152153 private function retrieveNotes( $notes = '' ) {
153154 global $wgUser;
154 - $this->notes = ( FlaggedRevs::allowComments() && $wgUser->isAllowed('validate') ) ? $notes : '';
 155+ $this->notes = ( FlaggedRevs::allowComments() && $wgUser->isAllowed('validate') ) ?
 156+ $notes : '';
155157 }
156158
157159 public static function AjaxReview( /*$args...*/ ) {
@@ -252,7 +254,8 @@
253255 return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' );
254256 }
255257 // Doesn't match up?
256 - $k = self::validationKey( $form->templateParams, $form->imageParams, $form->fileVersion, $form->oldid );
 258+ $k = self::validationKey( $form->templateParams, $form->imageParams,
 259+ $form->fileVersion, $form->oldid );
257260 if( $form->validatedParams !== $k ) {
258261 return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' );
259262 }
@@ -361,7 +364,8 @@
362365 $form .= Xml::hidden( 'wpApprove', $this->approve ) . "\n";
363366 $form .= Xml::hidden( 'rcid', $this->rcid ) . "\n";
364367 # Special token to discourage fiddling...
365 - $checkCode = self::validationKey( $this->templateParams, $this->imageParams, $this->fileVersion, $rev->getId() );
 368+ $checkCode = self::validationKey( $this->templateParams, $this->imageParams,
 369+ $this->fileVersion, $rev->getId() );
366370 $form .= Xml::hidden( 'validatedParams', $checkCode );
367371 $form .= '</fieldset>';
368372
@@ -379,7 +383,8 @@
380384 $difflink = '(' . $this->skin->makeKnownLinkObj( $this->page, wfMsgHtml('diff'),
381385 '&diff=' . $rev->getId() . '&oldid=prev' ) . ')';
382386 $revlink = $this->skin->makeLinkObj( $this->page, $date, 'oldid=' . $rev->getId() );
383 - return "<li>$difflink $revlink " . $this->skin->revUserLink($rev) . " " . $this->skin->revComment($rev) . "</li>";
 387+ return "<li>$difflink $revlink " . $this->skin->revUserLink($rev) . " " .
 388+ $this->skin->revComment($rev) . "</li>";
384389 }
385390
386391 public function isApproval() {
@@ -482,7 +487,7 @@
483488 # Our flags
484489 $flags = $this->dims;
485490 # Some validation vars to make sure nothing changed during
486 - $lastTempID = 0;
 491+ $lastTempId = 0;
487492 $lastImgTime = "0";
488493 # Our template version pointers
489494 $tmpset = $tmpParams = array();
@@ -501,8 +506,8 @@
502507 if( is_null($tmp_title) )
503508 continue; // Page must be valid!
504509
505 - if( $rev_id > $lastTempID )
506 - $lastTempID = $rev_id;
 510+ if( $rev_id > $lastTempId )
 511+ $lastTempId = $rev_id;
507512
508513 $tmpset[] = array(
509514 'ft_rev_id' => $rev->getId(),
@@ -563,33 +568,33 @@
564569
565570 # Is this rev already flagged?
566571 $flaggedOutput = false;
567 - if( $oldfrev = FlaggedRevision::newFromTitle( $this->page, $rev->getId(), FR_TEXT | FR_MASTER ) ) {
568 - $flaggedOutput = FlaggedRevs::parseStableText( $article, $oldfrev->getRevText(), $oldfrev->getRevId() );
 572+ $oldfrev = FlaggedRevision::newFromTitle( $this->page, $rev->getId(),
 573+ FR_TEXT | FR_MASTER );
 574+ if( $oldfrev ) {
 575+ $flaggedOutput = FlaggedRevs::parseStableText( $article, $oldfrev->getRevText(),
 576+ $oldfrev->getRevId() );
569577 }
570578
571579 # Be looser on includes for templates, since they don't matter much
572580 # and strict checking breaks randomized images/metatemplates...(bug 14580)
573581 global $wgUseCurrentTemplates, $wgUseCurrentImages;
574 - $noMatch = ($rev->getTitle()->getNamespace() == NS_TEMPLATE && $wgUseCurrentTemplates && $wgUseCurrentImages);
 582+ $noMatch = ($rev->getTitle()->getNamespace() == NS_TEMPLATE
 583+ && $wgUseCurrentTemplates && $wgUseCurrentImages);
575584
576585 # Set our versioning params cache
577586 FlaggedRevs::setIncludeVersionCache( $rev->getId(), $tmpParams, $imgParams );
578 - # Get the expanded text and resolve all templates.
579 - # Store $templateIDs and add it to final parser output later...
580 - list($fulltext,$tmps,$tmpIDs,$err,$maxID) = FlaggedRevs::expandText( $rev->getText(), $rev->getTitle(), $rev->getId() );
581 - if( !$noMatch && (!empty($err) || $maxID > $lastTempID) ) {
582 - wfProfileOut( __METHOD__ );
583 - return $err;
584 - }
585 - # Parse the rest and check if it matches up
586 - $stableOutput = FlaggedRevs::parseStableText( $article, $fulltext, $rev->getId() );
 587+ # Parse the text and check if all templates/files match up
 588+ $stableOutput = FlaggedRevs::parseStableText( $article, $rev->getText(), $rev->getId() );
587589 $err =& $stableOutput->fr_includeErrors;
588 - if( !$noMatch && (!empty($err) || $stableOutput->fr_newestImageTime > $lastImgTime) ) {
589 - wfProfileOut( __METHOD__ );
590 - return $err;
 590+ if( !$noMatch ) { // template/files must all be specified
 591+ if( !empty($err)
 592+ || $stableOutput->fr_newestImageTime > $lastImgTime
 593+ || $stableOutput->fr_newestTemplateID > $lastTempId )
 594+ {
 595+ wfProfileOut( __METHOD__ );
 596+ return $err; // return templates/files with no version specified
 597+ }
591598 }
592 - # Merge in template params from first phase of parsing...
593 - $this->mergeTemplateParams( $stableOutput, $tmps, $tmpIDs, $maxID );
594599 # Clear our versioning params cache
595600 FlaggedRevs::clearIncludeVersionCache( $rev->getId() );
596601
@@ -644,7 +649,9 @@
645650 # Try using the parser cache first since we didn't actually edit the current version.
646651 $parserCache = ParserCache::singleton();
647652 $poutput = $parserCache->get( $article, $wgUser );
648 - if( !$poutput || !isset($poutput->fr_newestTemplateID) || !isset($poutput->fr_newestImageTime) ) {
 653+ if( !$poutput || !isset($poutput->fr_newestTemplateID)
 654+ || !isset($poutput->fr_newestImageTime) )
 655+ {
649656 $text = $article->getContent();
650657 $options = FlaggedRevs::makeParserOptions();
651658 $poutput = $wgParser->parse( $text, $article->mTitle, $options );

Follow-up revisions

RevisionCommit summaryAuthorDate
r60821* Removed secondary form. Almost never comes up and makes things harder to ma...aaron01:31, 8 January 2010

Status & tagging log